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

怎么实现自动回复呀,请问下有没有教程的,请喝奶茶呀 #33

Closed
Jsonka-log opened this issue Nov 21, 2023 · 9 comments

Comments

@Jsonka-log
Copy link

怎么实现自动回复呀,请问下有没有教程的,请喝奶茶呀

@LTEnjoy
Copy link
Owner

LTEnjoy commented Nov 21, 2023

你好,我已经完善了自动回复的代码。

你可以通过检查ui_auto_wechat.py文件里的check_new_msg函数。这个函数支持自动检测新消息并根据设定的联系人列表来决定是否需要自动回复。

你可以通过自定义一个定时代码 (例如,每10分钟执行一次循环,调用check_new_msg函数来自动回复新消息)。

有任何疑问欢迎进一步的交流!

@diguawl
Copy link

diguawl commented Nov 23, 2023

您好,方便写一个例子吗?非常感谢

@LTEnjoy
Copy link
Owner

LTEnjoy commented Nov 23, 2023

可以参考这个代码

wechat_path = "D:\Program Files (x86)\Tencent\WeChat\WeChat.exe"
wechat = WeChat(wechat_path)

# 设置自动回复的间隔时间
interval = 10
# 设置自动回复的对象
auto_reply_names = set(["爸"])
wechat.set_auto_reply(auto_reply_names)
# 设置自动回复的内容
wechat.auto_reply_msg = "我现在有事不在,稍后回复。"
# 开启自动回复
while True:
    wechat.check_new_msg(click_msg=True)
    time.sleep(interval)

@T-K-233
Copy link
Contributor

T-K-233 commented Nov 28, 2023

感谢作者

有个小问题就是如果 auto_reply_names 里面的 entry 在聊天框最上方的时候,double_click(chat_btn) 始终会使这个 entry 位于最上方,导致即使没有新消息的时候也会重复发送内容

不知道有没有办法来判断聊天头像的小红点来判定新消息?

@LTEnjoy
Copy link
Owner

LTEnjoy commented Nov 28, 2023

你好,你可以尝试一下将check_new_msg()中的click_msg参数设置为True。经过测试我发现可能是有些消息如果不点击用户会一直卡顿。

@T-K-233
Copy link
Contributor

T-K-233 commented Nov 28, 2023

你好,你可以尝试一下将check_new_msg()中的click_msg参数设置为True。经过测试我发现可能是有些消息如果不点击用户会一直卡顿。

我用的是上面的示例代码 ,设置 click_msg=True 也没有办法解决。

这似乎是逻辑上的 bug:
假设聊天界面有 [A, B, C] 三个聊天,如果 auto_reply_names = [A]check_new_msg() 里面的 first_namelast_name 都会等于 A,这时双击聊天按键,第一条显示的还是 A,不论 A 是否有新消息,if item.Name in self.auto_reply_contacts 这条就都会被判中,发送回复消息。

一个临时的 workaround 是置顶一个不在 auto_reply_names 列表里的聊天窗口,这样双击聊天返回最上方时就能确保不会读到列表里面的项

@LTEnjoy
Copy link
Owner

LTEnjoy commented Nov 28, 2023

你好,我刚刚也在检查这个问题。目前应该已经解决了。你可以重新下载一下ui_auto_wechat文件,或者复制check_new_msg这个函数再试一下。

@T-K-233
Copy link
Contributor

T-K-233 commented Nov 28, 2023

emmm 似乎还是没有解决.... 我开个新的 issue 吧

@LTEnjoy
Copy link
Owner

LTEnjoy commented Nov 28, 2023

嗯,可以的话麻烦给出一个可复现的例子我检查一下

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

No branches or pull requests

4 participants