Skip to content
This repository has been archived by the owner on Oct 24, 2024. It is now read-only.

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

Open
wuxin1030 opened this issue Apr 22, 2023 · 3 comments
Open

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

wuxin1030 opened this issue Apr 22, 2023 · 3 comments

Comments

@wuxin1030
Copy link

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

@simonwanghub
Copy link

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

请问这个问题解决了吗?

@CloudTronUSA
Copy link

CloudTronUSA commented Oct 22, 2023

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
Copy link

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants