You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Failure to retrieve message ID after sending a message, leading to recall failure
When I try to recall a message after sending it, I find that I cannot find the message ID of the sent message anywhere.
My code:
contact.say(text).then((msg)=>{// this msg is undefinedif(msg){CacheHelper.getInstances().addUndoMessageCache(ctx.message.message_id,msg.id)}
...
})
The same issue occurs with room:
room.say(text).then(msg=>{// this msg is undefinedif(msg){CacheHelper.getInstances().addUndoMessageCache(ctx.message.message_id,msg.id)}
...
})
My Solution
When I tried to modify it, I successfully retrieved the message ID, but due to my limited understanding of the code and TypeScript, I hope someone can fix this issue.
overrideasyncmessageSendFile(conversationId: string,file: FileBox,): Promise<void|string>{log.verbose('PuppetWechat4u','messageSend(%s, %s)',conversationId,file)/** * Send emoticon through MD5 */// wechat4u.sendMsg({// emoticonMd5: '00c801cdf69127550d93ca52c3f853ff'// }, ToUserName)// .catch(err => {// bot.emit('error', err)// })/** * The following sends images, videos, attachments, etc., by uploading files * Common methods are as follows * file can be of multiple types * filename is required, mainly to determine the file type */constres=awaitthis.wechat4u.sendMsg({file: awaitfile.toStream(),filename: file.name,},conversationId);letextconstextMatch=file.name.match(/.*\.(.*)/)if(extMatch&&extMatch[1]){ext=extMatch[1].toLowerCase()}else{ext=''}letmsgTypeswitch(ext){case'bmp':
case'jpeg':
case'jpg':
case'png':
msgType=WebAppMsgType.IMGbreakcase'mp4':
msgType=WebAppMsgType.VIDEObreakdefault:
msgType=WebAppMsgType.ATTACH}constmsg: WebMessageRawPayload={Content: "",CreateTime: Math.floor(Date.now()/1000),FromUserName: this.wechat4u.user.UserName,ToUserName: conversationId,MsgId: res.MsgID,MsgType: msgType,SubMsgType: WebMessageType.ZERO,AppMsgType: msgType,OriginalContent: "",// ?Status: "3",FileName: file.name,FileSize: file.size,MMActualContent: "",MMActualSender: "",MMAppMsgDesc: "",MMAppMsgDownloadUrl: "",MMAppMsgFileExt: "",MMAppMsgFileSize: "",MMCategory: [],MMDigest: "",MMDisplayTime: 0,MMFileExt: "",MMFileStatus: 0,MMImgStyle: "",MMLocationDesc: "",MMLocationUrl: "",MMPeerUserName: "",MMPreviewSrc: "",MMStatus: 0,MMThumbSrc: "",MMUploadProgress: 0,MediaId: "",Signature: "",VoiceLength: 0,Url: ''}returnthis.sendMessageHandler(msg)}
privateasyncsendMessageHandler(msg: WebMessageRawPayload){if(!msg.MsgId){log.warn('PuppetWechat4u','sendMessageHandler() wechat4u.on(message) no message id: %s',JSON.stringify(msg))thrownewError('no id')}// If the creation time of the message is earlier than the bot startup time, discard it directlyif(msg.CreateTime<this.startTime){// log.warn('PuppetWechat4u', 'initHookEvents() wechat4u.on(message) is history message: %s', JSON.stringify(msg))return}this.cacheMessageRawPayload.set(msg.MsgId,msg)constevent=awaitparseEvent(this,msg)if(event.type===EventType.Message){this.emit('message',{messageId: msg.MsgId})}returnmsg.MsgId}
The text was updated successfully, but these errors were encountered:
Failure to retrieve message ID after sending a message, leading to recall failure
When I try to recall a message after sending it, I find that I cannot find the message ID of the sent message anywhere.
My code:
The same issue occurs with
room
:My Solution
When I tried to modify it, I successfully retrieved the message ID, but due to my limited understanding of the code and TypeScript, I hope someone can fix this issue.
File
puppet-wechat4u.ts
:The text was updated successfully, but these errors were encountered: