Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

是否应该兼容空格为@分隔符的群聊信息 #60

Closed
brothertian opened this issue Aug 8, 2016 · 8 comments
Closed

是否应该兼容空格为@分隔符的群聊信息 #60

brothertian opened this issue Aug 8, 2016 · 8 comments
Labels

Comments

@brothertian
Copy link

brothertian commented Aug 8, 2016

群聊的时候,若@联系人,text和content属性的内容均包含了@信息,建议能够把text属性过滤为不包含@内容的,同时可以增加一个atContract属性,把@的联系人信息作为list存储(考虑@在文字前、中、后,以及多个@混合),这样程序能够更好的处理文字逻辑.
另,还有一个问题,某些微信版本发出的@联系人,系统不能正确识别,isAt为False,怀疑不同版本微信的默认分隔符不一样.

@littlecodersh
Copy link
Owner

littlecodersh commented Aug 8, 2016

@brothertian
我个人认为过滤掉@信息没有必要。

  1. 放进模块并非实现需求的唯一方法,这一操作在模块外处理也极为简单
  2. 造成部分信息的缺失,如第一部分的参与者:@111,第二部分的参与者:@222,第三部分的参与者@333”,过滤掉后信息会严重缺失
  3. 过滤也是一定的处理开销,特别是在群聊消息本身就较多的情况下
    所以,我并不建议过滤掉@信息
    另,Content键中的值是原始信息,Text键中的值是去除群聊都有的头部分的消息,并不重复

@联系人的信息存储这个需求过于小众,考虑相关处理开销,不会放进模块
如果有相关需求,可以自行修改

手动输入@联系人名的话,在我测试过的各客户端微信中本就不会被识别成@消息,建议充分测试后再提交相关bug

@brothertian
Copy link
Author

@littlecodersh 感谢答复,@联系人名的问题,检测下来是这样的,某些版本微信在某些时候(不是每次,没找到规律)发送的@联系人,分隔符不是\u2005,而是空格,因此将client.py的__produce_group_chat函数msg['isAt'] = u'@%s\u2005'改为(u'@%s\u2005'或者 u'@%s ')就可以识别啦,不知道有没有什么副作用。

@littlecodersh
Copy link
Owner

@brothertian 可以提供空格的微信版本吗?
这样修改会导致大量的误识别,如果能确定空格的微信版本,我们可以讨论一下这里怎么修改。

@brothertian
Copy link
Author

brothertian commented Aug 8, 2016

@littlecodersh 之前有问题的微信版本为6.3.16,安卓系统,未找到规律,有时候发出的正常,有时候发出的为空格,而且有问题的信息复制后粘贴也同样有问题。

@littlecodersh
Copy link
Owner

@brothertian 未能复现问题,读取为空格的消息在别的机器上是否能显示系统的@提示?

@brothertian
Copy link
Author

brothertian commented Aug 8, 2016

@littlecodersh 其它机器未显示有人@我的提示.

@littlecodersh
Copy link
Owner

@brothertian 所以我认为itchat这里也不应当显示为有人@我,你觉得呢?

@brothertian
Copy link
Author

@littlecodersh 对,我也这么认为,只是不清楚是否微信的bug还是什么其它原因,毕竟从使用者角度来看,他发出的@信息未得到相应的反馈,会产生疑惑。
看来这个问题也需要在模块外做二次检测比较合适。

@littlecodersh littlecodersh changed the title 群聊的问题 是否应该兼容空格为@分隔符的群聊信息 Aug 9, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants