ChisBread / wechat-service

🤖Let your WeChat run as a service
GNU General Public License v3.0
375 stars 59 forks source link

无法接收纯数字的消息。 #4

Open wuxin1030 opened 1 year ago

wuxin1030 commented 1 year ago

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

simonwanghub commented 1 year ago

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

请问这个问题解决了吗?

CloudTronUSA commented 11 months ago

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 commented 11 months ago

@wuxin1030 @simonwanghub @ChisBread