wechat-service icon indicating copy to clipboard operation
wechat-service copied to clipboard

无法接收纯数字的消息。

Open wuxin1030 opened this issue 1 year ago • 3 comments

任意用户发送纯数字, 比如:1 比如:019293834 都会无法接收,显示错误 on_error:expected string or bytes-like object

wuxin1030 avatar Apr 22 '23 14:04 wuxin1030

任意用户发送纯数字, 比如:1 比如:019293834 都会无法接收,显示错误 on_error:expected string or bytes-like object

请问这个问题解决了吗?

simonwanghub avatar Jun 02 '23 08:06 simonwanghub

In bot.py add this line before at_match = self.AT_PATTERN.match(str(msg['content'])): msg['content'] = str(msg['content'])

so that part should look like this after the fix:

if '@chatroom' in msg['wxid']:
            msg['roomid'] = msg['wxid'] #群id
            msg['senderid'] = msg['id1'] #个人id
        else:
            msg['roomid'] = None
            msg['senderid'] = msg['wxid'] #个人id
        msg['content'] = str(msg['content'])
        at_match = self.AT_PATTERN.match(str(msg['content']))
        if at_match:
            msg['at_nickname'] = at_match.groups()[0]
            msg['content'] = at_match.groups()[1]
            msg['at_bot'] = msg['at_nickname'] == self.name

CloudTronUSA avatar Oct 22 '23 09:10 CloudTronUSA

@wuxin1030 @simonwanghub @ChisBread

CloudTronUSA avatar Oct 22 '23 09:10 CloudTronUSA