public void start() {
        this.api = new WeChatApiImpl(this);
        log.info("wechat-bot: {}", Constant.VERSION);
        api.login(config.autoLogin());

        Thread msgHandle = new Thread(new Runnable() {
            @Override
            public void run() {
                while (true) {
                    if (hasMessage()) {
                        WeChatMessage weChatMessage = nextMessage();
                        callBack(mapping.get(MsgType.ALL), weChatMessage);
                        callBack(mapping.get(weChatMessage.getMsgType()), weChatMessage);
                    } else {
                        DateUtils.sleep(50);
                    }
                }
            }
        });
        msgHandle.setName("message-handle");
        msgHandle.setDaemon(true);
        msgHandle.start();

        this.other();
    }
public void start() {
        this.api = new WeChatApiImpl(this);
        log.info("wechat-bot: {}", Constant.VERSION);
        api.login(config.autoLogin());

        Thread msgHandle = new Thread(new Runnable() {
            @Override
            public void run() {
                while (true) {
                    if (hasMessage()) {
                        WeChatMessage weChatMessage = nextMessage();
                        callBack(mapping.get(MsgType.ALL), weChatMessage);
                        callBack(mapping.get(weChatMessage.getMsgType()), weChatMessage);
                    } else {
                        DateUtils.sleep(50);
                    }
                }
            }
        });
        msgHandle.setName("message-handle");
        msgHandle.setDaemon(true);
        msgHandle.start();

        this.other();
    }
public void start ( ) { this . api = new WeChatApiImpl ( this ) ; log . info ( "wechat-bot: {}" , Constant . VERSION ) ; api . login ( config . autoLogin ( ) ) ; Thread msgHandle = new Thread ( new Runnable ( ) { @ Override public void run ( ) { while ( true ) { if ( hasMessage ( ) ) { WeChatMessage weChatMessage = nextMessage ( ) ; callBack ( mapping . get ( MsgType . ALL ) , weChatMessage ) ; callBack ( mapping . get ( weChatMessage . getMsgType ( ) ) , weChatMessage ) ; } else { DateUtils . sleep ( 50 ) ; } } } } ) ; msgHandle . setName ( "message-handle" ) ; msgHandle . setDaemon ( true ) ; msgHandle . start ( ) ; this . other ( ) ; }
启动微信监听
启动微信监听