From 6b14d64aa4120b93f60b19f2443392d4a2c303e3 Mon Sep 17 00:00:00 2001 From: Huan LI Date: Sun, 17 Jun 2018 07:06:02 +0800 Subject: [PATCH] try selfId --- src/io.ts | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/src/io.ts b/src/io.ts index 13911672..4e25f62d 100644 --- a/src/io.ts +++ b/src/io.ts @@ -300,17 +300,21 @@ export class Io { case 'update': log.verbose('Io', 'on(update): %s', ioEvent.payload) - const userId = this.options.wechaty.puppet.selfId() - - if (userId) { - const loginEvent: IoEvent = { - name : 'login', - payload : { - id: userId, - name: this.options.wechaty.Contact.load(userId).name(), - }, + try { + const userId = this.options.wechaty.puppet.selfId() + + if (userId) { + const loginEvent: IoEvent = { + name : 'login', + payload : { + id: userId, + name: this.options.wechaty.Contact.load(userId).name(), + }, + } + await this.send(loginEvent) } - await this.send(loginEvent) + } catch (e) { + // not login } if (this.scanPayload) { -- GitLab