实用脚本案例:自动回复
降低学习门槛,从这个简单的自动回复脚本开始。此案例展示了如何将日常繁琐的操作自动化,提供实际的效率提升。
import xchat
import time
__module_name__ = "AutoReply"
__module_version__ = "1.0"
__module_description__ = "自动回复特定关键字"
def on_private_message(word, word_eol, userdata):
# word[0] 是发送者昵称, word[1] 是消息内容
sender = word[0]
message = word[1]
if "在吗" in message:
# 模拟延迟,使其看起来更自然
xchat.command(f"timer 2 msg {sender} 自动回复:我现在不在电脑前,稍后联系。")
return xchat.EAT_NONE
# 挂载钩子监听 'Private Message' 事件
xchat.hook_print("Private Message", on_private_message)
xchat.prnt("AutoReply 脚本已加载!")