wechaty / puppet-supports

Wechaty Puppet Services (WPS)
https://wechaty.js.org/docs/puppet-services/
Apache License 2.0
33 stars 4 forks source link

invalid toUser error when sending message #160

Closed atorber closed 1 year ago

atorber commented 1 year ago

Question

06:17:47 WARN GrpcManager initClient() TLS: disabled (INSECURE)
06:17:48 INFO StarterBot [object Object] login
06:17:49 INFO Starter Bot Started. 
/workspace/wechat-openai-qa-bot/node_modules/@grpc/grpc-js/src/call.ts:81
  const error = new Error(message);
                ^
Error: 13 INTERNAL: puppet_workpro_4185fc********ccadc287cd with invalid toUser: S:1688850326129606_0
    at callErrorFromStatus (/workspace/wechat-openai-qa-bot/node_modules/@grpc/grpc-js/src/call.ts:81:17)
    at Object.onReceiveStatus (/workspace/wechat-openai-qa-bot/node_modules/@grpc/grpc-js/src/client.ts:356:55)
    at Object.onReceiveStatus (/workspace/wechat-openai-qa-bot/node_modules/@grpc/grpc-js/src/client-interceptors.ts:455:34)
    at Object.onReceiveStatus (/workspace/wechat-openai-qa-bot/node_modules/@grpc/grpc-js/src/client-interceptors.ts:417:48)
    at /workspace/wechat-openai-qa-bot/node_modules/@grpc/grpc-js/src/resolving-call.ts:110:24
    at processTicksAndRejections (node:internal/process/task_queues:78:11)
for call at
    at ServiceClientImpl.makeUnaryRequest (/workspace/wechat-openai-qa-bot/node_modules/@grpc/grpc-js/src/client.ts:326:30)
    at ServiceClientImpl.messageSendText (/workspace/wechat-openai-qa-bot/node_modules/@grpc/grpc-js/src/make-client.ts:189:15)
    at node:internal/util:364:7
    at new Promise (<anonymous>)
    at bound  (node:internal/util:350:12)
    at PuppetService.messageSendText (file:///workspace/wechat-openai-qa-bot/node_modules/wechaty-puppet-service/src/client/puppet-service.ts:1104:6)
    at file:///workspace/wechat-openai-qa-bot/node_modules/wechaty/src/sayable/deliver-sayable.ts:27:19
    at WechatifiedUserClass.say (file:///workspace/wechat-openai-qa-bot/node_modules/wechaty/src/user-modules/contact.ts:338:87)
    at WechatyImpl.onLogin (file:///workspace/wechat-openai-qa-bot/index.ts:158:16)
    at WechatyImpl.emit (node:events:525:35) {
  code: 13,
  details: 'puppet_workpro_4185fc********ccadc287cd with invalid toUser: S:1688850326129606_0',
  metadata: Metadata {
    internalRepr: Map(2) { 'date' => [Array], 'authorization' => [Array] },
    options: {}
  },
  progress: 'PROCESSED'
}

image

windmemory commented 1 year ago

@atorber could you please provide specific versions for wechaty, wechaty-puppet-service and wechaty-puppet?

atorber commented 1 year ago

@atorber could you please provide specific versions for wechaty, wechaty-puppet-service and wechaty-puppet?

  "dependencies": {
    "@vikadata/vika": "^1.0.5",
    "chatgpt": "^1.1.3",
    "dotenv": "^16.0.0",
    "exceljs": "^4.3.0",
    "file-box": "^1.4.12",
    "fs": "^0.0.1-security",
    "moment": "^2.29.1",
    "mqtt": "^4.3.7",
    "njwt": "^1.2.0",
    "node-schedule": "^2.1.0",
    "node-xlsx": "^0.21.0",
    "openai-sdk": "^1.0.1",
    "pm2": "^5.2.0",
    "qrcode-terminal": "^0.12.0",
    "request": "^2.88.0",
    "request-promise": "^4.2.6",
    "socket.io": "^2.1.0",
    "socket.io-client": "^2.4.0",
    "uuid": "^8.3.2",
    "wechaty": "^1.20.2",
    "wechaty-plugin-contrib": "^1.0.18",
    "wechaty-puppet-padlocal": "^1.11.13",
    "wechaty-puppet-service": "^1.19.8",
    "wechaty-puppet-wechat": "^1.18.4",
    "wechaty-puppet-xp": "^1.12.7"
  },

image

hcfw007 commented 1 year ago

You are trying to send message to contact with id '0'. There should not be a contact with such ID. Could you check how did you get this id?

atorber commented 1 year ago

You are trying to send message to contact with id '0'. There should not be a contact with such ID. Could you check how did you get this id?

The code is like this, when the robot logs in, it will automatically send a message to itself.

async function onLogin(user: Contact) { log.info('StarterBot', '%s login', user.payload) const curDate = new Date().toLocaleString() await user.say('上线:' + curDate) }

atorber commented 1 year ago

Now it seems that this problem has been solved, just now I used the previous code to run normally, I did not make any changes to my code.

hcfw007 commented 1 year ago

After checking log, there is no more message request for contact id '0'. If next time such error happens, could you please log contact id before the say statement so that we can know if this is a problem with contact payload or with say. If you think this issue is solved, please close it. Thank you.

windmemory commented 1 year ago

Closing this issue since no further discussion needed.