-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Feat: add Message.find
to search in cache.
#1534
Comments
@kis87988 Would you like to try this new method to see if it could help you to find someone who had said something in a room before? It had been published on Wechaty v0.19.145 or later versions. |
Sure, I will try and test it out. |
@zixia const room = bot.Room.load("chatroom@123456")
room.say("match[2]")
await delay(10000) //delay 10s
const match=["這是一個測試的文字1","這是一個測試的文字2","這是一個測試的文字3"]
const find_content = match[2]
console.log("find_content:", find_content)
const found_msg = await bot.Message.find({text:new RegExp(find_content,"igm"),
roomId:room.id,
type: Message.Type.Text})
if(found_msg)
{
console.log(found_msg)
console.log(found_msg.text())
console.log(found_msg.from())
}
else
{
console.log(`not found message${find_content}`)
}
|
Why there's a data like I do not think the |
um.. |
I have no idea about this problem, I will do a test by myself later. |
I had just tested with the following code, it works without any problem with Wechaty v0.19.149 if (msg.text() === 'find') {
console.log('find start')
const messageList = await this.Message.findAll({ text: /test/i })
console.log('length:', messageList.length)
for (const m of messageList) {
console.log(m.from() + '')
console.log(m.to() + '')
console.log(m.room() + '')
console.log(m.text() + '')
}
console.log('find done')
} |
Yes, it is working now. thanks! |
Did you found the reason of why it didn't work before? And please close this issue if you have no more questions. Thanks |
@zixia |
Ok, let me do this. :P |
您好,在onMessage中如何筛选聊天记录
|
@xmsz Please file a new issue and follow the template. This issue had already been closed. |
For some scenarios like find the recent messages by text.
This might be a workaround for #1531
The text was updated successfully, but these errors were encountered: