wechaty / puppet-whatsapp

Wechaty Puppet for Whatsapp
https://npmjs.com/package/wechaty-puppet-whatsapp
Apache License 2.0
24 stars 17 forks source link

有時掃完 qrcode 後會收不到 login event,使用ding dong bot 也收不到。 #396

Open shihyihong opened 9 months ago

shihyihong commented 9 months ago

Important:Please file the issue follow the template, or we won't be able to help you to solve the problem.

0. Report Issue Guide

  1. Please run the following command and check whether the problem has been fixed:

    rm -rf package-lock.json
    rm -rf node_modules
    npm install
  2. Please search in FAQ List first, and make sure your problem has not been solved before.

  3. Please search in the issue first, and make sure your problem had not been reported before

1. Versions

What is your wechaty version?

Answer: 1.20.2

Which puppet are you using for wechaty? (hostie/puppeteer/padchat/...)

Answer: wechaty-puppet-whatsapp

What is your wechaty-puppet-XXX(padchat/puppeteer/) version?

Answer: 1.19.16

What is your node version? (run node --version)

Answer: v16.10.0

What os are you using

Answer: mac os

2. Describe the bug

掃完qrcode後手機顯示掃碼成功但wechaty bot無法收到 login event。 前幾天是可以順利收到的但昨天就突然開始無法收到。 memory-card產生的檔案都刪掉過測試,還是無法收到login event。

3. To Reproduce

This part is very important: if you can not provide any reproduce steps, then the problem will be very hard to be recognized.

How to create a Minimal, Reproducible Example

Steps to reproduce the behavior:

以下是我的程式碼

 const memoryCard = new MemoryCard('wechaty');
        await memoryCard.load();

        let bot: Wechaty;
        if (platform == 'whatsapp') {
            const MEMORY_SLOT = 'PUPPET_WHATSAPP_CLIENT_ID';
            const puppetMemoryCard = memoryCard.multiplex('puppet'); // DO NOT CHANGE IT!
            await puppetMemoryCard.set(MEMORY_SLOT, userID); // user defined
            const puppet = new PuppetWhatsapp();
            bot = WechatyBuilder.build({ puppet: puppet, memory: memoryCard });
        } else {
            await memoryCard.set('PUPPET_WECHAT_CLIENT_ID', userID);
            bot = WechatyBuilder.build({ memory: memoryCard });
        }

        bot.on('scan', async (qrcode: string, status: number) => {
            return await ScanHandler(qrcode, status, userID);
        });
        bot.on('login', async (user: Contact) => {
            return LoginHandler(user, userID);
        });

        bot.on('logout', async (user: Contact) => {
            return await LogoutHandler(user, userID, platform);
        });

        bot.on('message', async (msg: Message) => {
            await MsgHandler(userID, msg, platform);
        });

        bots.Set(userID, bot);
        await bot.start();

4. Expected behavior

應該要收到login event,且bot要順利連上

5. Actual behavior

If applicable, add screenshots to help explain your problem. But do not paste log screenshots here. 收到qrcode後,掃完碼 wechaty 就沒反應了

6. Full Output Logs

Set env WECHATY_LOG=silly in order to set log level to silly, then we can get the full log (If you dosen't set log env, log level is info as default, we cannot get the full log)

21:07:14 SILL Puppet Config: WECHATY_LOG set level to silly 21:07:14 INFO Config registering process.on("unhandledRejection") for development/debug 21:07:14 VERB Config constructor() 21:07:14 VERB PoolifyMixin poolifyMixin(EventEmitter) 21:07:14 VERB WechatifyMixin wechatifyMixin(AbstractPoolifyMixin) 21:07:14 VERB ValidationMixin validationMixin(ContactMixin) 21:07:14 VERB ValidationMixin validationMixin(ContactImplBase) 21:07:14 VERB PoolifyMixin poolifyMixin(ContactImpl) 21:07:14 VERB ValidationMixin validationMixin(ContactSelfMixin) 21:07:14 VERB WechatifyMixin wechatifyMixin(EmptyBase) 21:07:14 VERB ValidationMixin validationMixin(FavoriteMixin) 21:07:14 VERB WechatifyMixin wechatifyMixin(EventEmitter) 21:07:14 VERB ValidationMixin validationMixin(FriendshipMixin) 21:07:14 VERB WechatifyMixin wechatifyMixin(EmptyBase) 21:07:14 VERB ValidationMixin validationMixin(ImageMixin) 21:07:14 VERB WechatifyMixin wechatifyMixin(EmptyBase) 21:07:14 VERB ValidationMixin validationMixin(LocationMixin) 21:07:14 VERB WechatifyMixin wechatifyMixin(EmptyBase) 21:07:14 VERB ValidationMixin validationMixin(PostMixin) 21:07:14 VERB WechatifyMixin wechatifyMixin(EventEmitter) 21:07:14 VERB ValidationMixin validationMixin(MessageMixin) 21:07:14 VERB ValidationMixin validationMixin(MessageImplBase) 21:07:14 VERB WechatifyMixin wechatifyMixin(EmptyBase) 21:07:14 VERB ValidationMixin validationMixin(MiniProgramMixin) 21:07:14 VERB WechatifyMixin wechatifyMixin(EmptyBase) 21:07:14 VERB ValidationMixin validationMixin(MomentMixin) 21:07:14 VERB WechatifyMixin wechatifyMixin(EmptyBase) 21:07:14 VERB ValidationMixin validationMixin(MoneyMixin) 21:07:14 VERB PoolifyMixin poolifyMixin(EventEmitter) 21:07:14 VERB WechatifyMixin wechatifyMixin(AbstractPoolifyMixin) 21:07:14 VERB ValidationMixin validationMixin(RoomMixin) 21:07:14 VERB WechatifyMixin wechatifyMixin(EmptyBase) 21:07:14 VERB ValidationMixin validationMixin(RoomInvitationMixin) 21:07:14 VERB WechatifyMixin wechatifyMixin(EmptyBase) 21:07:14 VERB PoolifyMixin poolifyMixin(AbstractWechatifyMixin) 21:07:14 VERB ValidationMixin validationMixin(TagMixin) 21:07:14 VERB WechatifyMixin wechatifyMixin(EmptyBase) 21:07:14 VERB ValidationMixin validationMixin(UrlLinkMixin) 21:07:14 VERB WechatifyMixin wechatifyMixin(EmptyBase) 21:07:14 VERB ValidationMixin validationMixin(DelayMixin) 21:07:14 VERB WechatyGErrorMixin gErrorMixin(WechatySkeleton) 21:07:14 VERB WechatifyUserModuleMixin wechatifyUserModuleMixin(GErrorMixin) 21:07:14 VERB WechatyIoMixin ioMixin(WechatifyUserModuleMixin) 21:07:14 VERB WechatyPuppetMixin puppetMixin(IoMixin) 21:07:14 VERB WechatyLoginMixin loginMixin(PuppetMixin) 21:07:14 VERB WechatyMiscMixin miscMixin(LoginMixin) 21:07:14 VERB WechatyPluginMixin pluginMixin(MiscMixin) 21:07:14 VERB ValidationMixin validationMixin(WechatyBase) 21:07:14 VERB ValidationMixin validationMixin(WechatyImplBase) 21:07:14 VERB wechaty-puppet-service monkeyPatchMetadataFromHttp2Headers() [info][2023-08-24 21:07:14:714][Init]Server start with env: dev 21:07:14 VERB Wechaty init() Raven disabled (import("raven") failed) [info][2023-08-24 21:07:14:714][Init]Server is listening on port: 3080 [info][2023-08-24 21:07:21:721][Connect]create new socket io connection with userID: 2fdfda90-939d-4207-a0f3-fab25ffda0f2 [info][2023-08-24 21:07:23:723][CreateBot]get creat_bot event 21:07:23 VERB PuppetSkeleton constructor({}) 21:07:23 VERB PuppetMemoryMixin constructor() 21:07:23 VERB PuppetLoginMixin constructor() 21:07:23 VERB PuppetCacheMixin constructor() 21:07:23 VERB PuppetCacheAgent constructor() 21:07:23 VERB PuppetContactMixin constructor() 21:07:23 VERB PuppetRoomMemberMixin constructor() 21:07:23 VERB PuppetRoomMixin constructor() 21:07:23 VERB PuppetFriendshipMixin constructor() 21:07:23 VERB PuppetTagMixin constructor() 21:07:23 VERB PuppetRoomInvitationMixin constructor() 21:07:23 VERB PuppetMessageMixin constructor() 21:07:23 VERB PuppetMiscMixin constructor() 21:07:23 VERB ServiceCtl constructor() 21:07:23 VERB StateSwitch constructor(PuppetServiceMixin, "{"log":{"enableTimestamp":true,"logLevel":5,"prefixFilter":{}}}") 21:07:23 VERB StateSwitch constructor(PuppetServiceMixinReset, "{"log":{"enableTimestamp":true,"logLevel":5,"prefixFilter":{}}}") 21:07:23 VERB PuppetServiceMixin constructor() #0 21:07:23 VERB PuppetWatchdogAgent constructor(40a1fe42-2805-46f4-b7e3-37b92b898a6d) 21:07:23 VERB PuppetWatchdogAgent constructor() timeout 60 seconds 21:07:23 VERB ReadyMixin constructor() 21:07:23 VERB PuppetPostMixin constructor() 21:07:23 VERB PuppetSayableMixin constructor() 21:07:23 VERB TapMixin constructor() 21:07:23 VERB Puppet constructor({}) 21:07:23 VERB PuppetWhatsapp constructor() 21:07:23 VERB WechatyBuilder singleton() 21:07:23 VERB WechatyBuilder newInstance() 21:07:23 VERB WechatyLoginMixin constructor() 21:07:23 VERB WechatyPuppetMixin construct() 21:07:23 VERB WechatyIoMixin constructor() 21:07:23 VERB WechatifyUserModuleMixin constructor() 21:07:23 VERB WechatySkeleton constructor() 21:07:23 VERB StateSwitch constructor(WechatyReady, "{"log":{"enableTimestamp":true,"logLevel":5,"prefixFilter":{}}}") 21:07:23 VERB ServiceCtl constructor() 21:07:23 VERB StateSwitch constructor(Wechaty, "{"log":{"enableTimestamp":true,"logLevel":5,"prefixFilter":{}}}") 21:07:23 VERB StateSwitch constructor(WechatyReset, "{"log":{"enableTimestamp":true,"logLevel":5,"prefixFilter":{}}}") 21:07:23 VERB Wechaty constructor() 21:07:23 VERB WechatySkeleton on(scan, listener) registering... listenerCount: 0 21:07:23 VERB WechatySkeleton on(login, listener) registering... listenerCount: 0 21:07:23 VERB WechatySkeleton on(logout, listener) registering... listenerCount: 0 21:07:23 VERB WechatySkeleton on(message, listener) registering... listenerCount: 0 21:07:23 VERB Wechaty start() 21:07:23 VERB WechatyLoginMixin init() 21:07:23 VERB WechatyPuppetMixin init() 21:07:23 VERB WechatifyUserModuleMixin init() 21:07:23 VERB WechatySkeleton init() 21:07:23 VERB WechatifyUserModuleMixin init() initializing Wechaty User Module (WUM) ... 21:07:23 VERB WechatifyMixin wechatifyUserModule(ContactImpl) 21:07:23 VERB WechatifyMixin wechatifyUserModule(ContactImpl)(Wechaty#b7ab2291-254b-4404-8271-d4de3bece905<Puppet(NONAME)>(wechaty)) 21:07:23 VERB WechatifyMixin wechatifyUserModule(ContactSelfImpl) 21:07:23 VERB WechatifyMixin wechatifyUserModule(ContactSelfImpl)(Wechaty#b7ab2291-254b-4404-8271-d4de3bece905<Puppet(NONAME)>(wechaty)) 21:07:23 VERB WechatifyMixin wechatifyUserModule(DelayImpl) 21:07:23 VERB WechatifyMixin wechatifyUserModule(DelayImpl)(Wechaty#b7ab2291-254b-4404-8271-d4de3bece905<Puppet(NONAME)>(wechaty)) 21:07:23 VERB WechatifyMixin wechatifyUserModule(FriendshipImpl) 21:07:23 VERB WechatifyMixin wechatifyUserModule(FriendshipImpl)(Wechaty#b7ab2291-254b-4404-8271-d4de3bece905<Puppet(NONAME)>(wechaty)) 21:07:23 VERB WechatifyMixin wechatifyUserModule(ImageImpl) 21:07:23 VERB WechatifyMixin wechatifyUserModule(ImageImpl)(Wechaty#b7ab2291-254b-4404-8271-d4de3bece905<Puppet(NONAME)>(wechaty)) 21:07:23 VERB WechatifyMixin wechatifyUserModule(LocationImpl) 21:07:23 VERB WechatifyMixin wechatifyUserModule(LocationImpl)(Wechaty#b7ab2291-254b-4404-8271-d4de3bece905<Puppet(NONAME)>(wechaty)) 21:07:23 VERB WechatifyMixin wechatifyUserModule(MessageImpl) 21:07:23 VERB WechatifyMixin wechatifyUserModule(MessageImpl)(Wechaty#b7ab2291-254b-4404-8271-d4de3bece905<Puppet(NONAME)>(wechaty)) 21:07:23 VERB WechatifyMixin wechatifyUserModule(MiniProgramImpl) 21:07:23 VERB WechatifyMixin wechatifyUserModule(MiniProgramImpl)(Wechaty#b7ab2291-254b-4404-8271-d4de3bece905<Puppet(NONAME)>(wechaty)) 21:07:23 VERB WechatifyMixin wechatifyUserModule(PostImpl) 21:07:23 VERB WechatifyMixin wechatifyUserModule(PostImpl)(Wechaty#b7ab2291-254b-4404-8271-d4de3bece905<Puppet(NONAME)>(wechaty)) 21:07:23 VERB WechatifyMixin wechatifyUserModule(RoomImpl) 21:07:23 VERB WechatifyMixin wechatifyUserModule(RoomImpl)(Wechaty#b7ab2291-254b-4404-8271-d4de3bece905<Puppet(NONAME)>(wechaty)) 21:07:23 VERB WechatifyMixin wechatifyUserModule(RoomInvitationImpl) 21:07:23 VERB WechatifyMixin wechatifyUserModule(RoomInvitationImpl)(Wechaty#b7ab2291-254b-4404-8271-d4de3bece905<Puppet(NONAME)>(wechaty)) 21:07:23 VERB WechatifyMixin wechatifyUserModule(TagImpl) 21:07:23 VERB WechatifyMixin wechatifyUserModule(TagImpl)(Wechaty#b7ab2291-254b-4404-8271-d4de3bece905<Puppet(NONAME)>(wechaty)) 21:07:23 VERB WechatifyMixin wechatifyUserModule(UrlLinkImpl) 21:07:23 VERB WechatifyMixin wechatifyUserModule(UrlLinkImpl)(Wechaty#b7ab2291-254b-4404-8271-d4de3bece905<Puppet(NONAME)>(wechaty)) 21:07:23 VERB WechatifyUserModuleMixin init() initializing Wechaty User Module (WUM) ... done 21:07:23 VERB WechatyPuppetMixin init() instanciating puppet instance ... 21:07:23 VERB Puppet resolvePuppet({puppet: Puppet(NONAME), puppetOptions: {}}) 21:07:23 VERB WechatyPuppetMixin init() instanciating puppet instance ... done 21:07:23 VERB WechatyPuppetMixin init() setting memory ... 21:07:23 VERB PuppetMemoryMixin setMemory(wechaty) 21:07:23 VERB WechatyPuppetMixin init() setting memory ... done 21:07:23 VERB WechatyPuppetMixin init() setting up events ... 21:07:23 VERB WechatyPuppetMixin setupPuppetEvents(Puppet(wechaty)) 21:07:23 VERB PuppetMixin setupPuppetEvents() puppet.on(friendship) (listenerCount:0) registering... 21:07:23 VERB PuppetMixin setupPuppetEvents() puppet.on(login) (listenerCount:0) registering... 21:07:23 VERB PuppetMixin setupPuppetEvents() puppet.on(logout) (listenerCount:0) registering... 21:07:23 VERB PuppetMixin setupPuppetEvents() puppet.on(message) (listenerCount:0) registering... 21:07:23 VERB PuppetMixin setupPuppetEvents() puppet.on(post) (listenerCount:0) registering... 21:07:23 VERB PuppetMixin setupPuppetEvents() puppet.on(room-invite) (listenerCount:0) registering... 21:07:23 VERB PuppetMixin setupPuppetEvents() puppet.on(room-join) (listenerCount:0) registering... 21:07:23 VERB PuppetMixin setupPuppetEvents() puppet.on(room-leave) (listenerCount:0) registering... 21:07:23 VERB PuppetMixin setupPuppetEvents() puppet.on(room-topic) (listenerCount:0) registering... 21:07:23 VERB PuppetMixin setupPuppetEvents() puppet.on(scan) (listenerCount:0) registering... 21:07:23 VERB PuppetMixin setupPuppetEvents() puppet.on(dirty) (listenerCount:0) registering... 21:07:23 VERB PuppetMixin setupPuppetEvents() puppet.on(dong) (listenerCount:0) registering... 21:07:23 VERB PuppetMixin setupPuppetEvents() puppet.on(error) (listenerCount:0) registering... 21:07:23 VERB PuppetMixin setupPuppetEvents() puppet.on(heartbeat) (listenerCount:0) registering... 21:07:23 VERB PuppetMixin setupPuppetEvents() puppet.on(ready) (listenerCount:0) registering... 21:07:23 VERB PuppetMixin setupPuppetEvents() puppet.on(reset) (listenerCount:0) registering... 21:07:23 VERB WechatyPuppetMixin setupPuppetEvents() ... done 21:07:23 VERB WechatyPuppetMixin init() setting up events ... done 21:07:23 VERB WechatyPuppetMixin init() emitting "puppet" event ... 21:07:23 VERB WechatyPuppetMixin init() emitting "puppet" event ... done 21:07:23 VERB ServiceCtl start() 21:07:23 SILL StateSwitch active() is false 21:07:23 SILL StateSwitch inactive() is true 21:07:23 SILL StateSwitch active() is false 21:07:23 VERB StateSwitch active(pending) <- (false) 21:07:23 VERB ServiceCtl start() super.start() ... 21:07:23 VERB WechatyPuppetMixin start() 21:07:23 VERB WechatyPuppetMixin start() super.start() ... 21:07:23 VERB WechatyIoMixin start() 21:07:23 VERB WechatySkeleton start() 21:07:23 VERB WechatyLoginMixin init() 21:07:23 VERB WechatyPuppetMixin init() 21:07:23 VERB WechatifyUserModuleMixin init() 21:07:23 VERB WechatySkeleton init() 21:07:23 VERB WechatifyUserModuleMixin init() Wechaty User Module (WUM)s have already wechatified: skip 21:07:23 VERB WechatyPuppetMixin init() skipped because this puppet has already been inited before. 21:07:23 VERB WechatyPuppetMixin start() super.start() ... done 21:07:23 SILL StateSwitch active() is false 21:07:23 VERB WechatyPuppetMixin start() starting puppet ... 21:07:23 VERB ReadyMixin start() 21:07:23 VERB PuppetServiceMixin start() 21:07:23 VERB ServiceCtl start() 21:07:23 SILL StateSwitch active() is false 21:07:23 SILL StateSwitch inactive() is true 21:07:23 SILL StateSwitch active() is false 21:07:23 VERB StateSwitch active(pending) <- (false) 21:07:23 VERB ServiceCtl start() super.start() ... 21:07:23 VERB PuppetCacheMixin start() 21:07:23 VERB PuppetLoginMixin start() 21:07:23 VERB PuppetMemoryMixin start() 21:07:23 VERB PuppetSkeleton start() 21:07:23 VERB PuppetCacheAgent start() 21:07:23 VERB PuppetCacheMixin start() "dirty" event listener added 21:07:23 VERB ServiceCtl start() super.start() ... done 21:07:23 VERB ServiceCtl start() this.onStart() ... 21:07:23 VERB PuppetWhatsapp onStart() 21:07:23 VERB Manager start() 21:07:23 VERB WhatsAppManager initWhatsAppClient() 21:07:23 VERB WhatsAppManager initWhatsAppEvents() 21:07:23 VERB StateSwitch stable(inactive, noCross=false) 21:07:23 VERB ServiceCtl start() this.onStart() ... done 21:07:23 SILL StateSwitch active() is pending 21:07:23 VERB StateSwitch active(true) <- (pending) 21:07:23 VERB ServiceCtl start() ... done 21:07:23 VERB PuppetWatchdogAgent start() "heartbeat" event listener added 21:07:23 VERB PuppetWatchdogAgent start() "reset" event listener added 21:07:23 VERB WechatyPuppetMixin start() starting puppet ... done 21:07:23 VERB ServiceCtl start() super.start() ... done 21:07:23 VERB ServiceCtl start() this.onStart() ... 21:07:23 VERB Wechaty onStart() 21:07:23 VERB Wechaty <Puppet(wechaty)>() onStart() v1.20.2 is starting... 21:07:23 VERB Wechaty id: b7ab2291-254b-4404-8271-d4de3bece905 21:07:23 VERB Wechaty onStart() ... done 21:07:23 VERB ServiceCtl start() this.onStart() ... done 21:07:23 SILL StateSwitch active() is pending 21:07:23 VERB StateSwitch active(true) <- (pending) 21:07:23 VERB ServiceCtl start() ... done 21:07:27 INFO LoginEventHandler onQRCode(2@ThKS0djCX0mMKZkLGg6OVCxKaNxjn5py0YB65CB/48oIuxXXT8Chc3a2tqPqOE787mwLLWELpNP6/w==,c3aHG0M1Ul0AaTyz7z3KTjXABJKnR8SCewaQjKq5tUo=,5AEdRWb5OJ7a0nC7USHyVdn+FS2+X/4TbE8Ee1+eICg=,E5wY7raZ+F7tq4zrAWSw8A4lM0KFiypwchxKxU0PkA4=,1) 21:07:27 VERB PuppetWhatsapp onScan({"qrcode":"2@ThKS0djCX0mMKZkLGg6OVCxKaNxjn5py0YB65CB/48oIuxXXT8Chc3a2tqPqOE787mwLLWELpNP6/w==,c3aHG0M1Ul0AaTyz7z3KTjXABJKnR8SCewaQjKq5tUo=,5AEdRWb5OJ7a0nC7USHyVdn+FS2+X/4TbE8Ee1+eICg=,E5wY7raZ+F7tq4zrAWSw8A4lM0KFiypwchxKxU0PkA4=,1","status":2}) 21:07:27 INFO PuppetWhatsapp SCAN 21:07:27 SILL StateSwitch inactive() is true 21:07:27 VERB StateSwitch inactive(true) <- (true) [info][2023-08-24 21:07:27:727][ScanHandler]prepare to emit qrcode



</details>

## 7. Additional context

> Add any other context about the problem here.