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

修复戳一戳 ,机器人误以为有人戳自己 #2844

Merged
merged 5 commits into from
Mar 30, 2024

Conversation

zhaodice
Copy link
Contributor

@zhaodice zhaodice commented Mar 21, 2024

如果按群成员,即Memebr找,因为众所周知的原因它并不能总是成功,那么我于是定义了一个findUser函数,它应该优先findMember,然后findFriendOrStranger(容错)
因为如果按原来的逻辑,findMember失败后,很有可能就把戳的对象当成了自己了(后面的”?:“导致默认为自己哦!)

PS:我现在群里一堆Mirai机器人,戳某个特定的人的时候,这些机器人tm的一呼百应,肯定是这里出了问题
PS:代码格式。。应该没问题吧,我瞅了好多次了(心虚)
PS:自己实现了`findUser`似乎不够优雅,违反了kotlin的美学?但是有更好的方法吗,我不是特别懂,请赐教!
PS:我把缺省值默认为bot这个逻辑干掉了,很容易让bot以为在戳自己,导致意料之外的事情发生,不如发个log更实惠!

@zhaodice
Copy link
Contributor Author

其他的部分,我没敢动,因为我不使用那些功能,没有BUG发言权(理论上,可能,也有跟这个一样的问题吧,可能)

@Him188
Copy link
Member

Him188 commented Mar 30, 2024

findUser 挺好的

默认 bot 已经忘了是为啥了, 不过我看你这个修改好像是没问题的

@Him188 Him188 merged commit f7649d2 into mamoe:dev Mar 30, 2024
1 check passed
@Him188 Him188 added the s:core 子系统: mirai-core label Mar 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
s:core 子系统: mirai-core
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants