

本站全新内容似乎没有具体信息,我可以直接进行摘要。如果您能提供关于自动回复源码的详细内容或描述,我将能够帮助您生成相应的摘要。请提供更多信息,以便我能更好地协助您。
import time
import random
from tkinter import *
def auto_reply(message):
replies = [
"你好!",
"很高兴见到你!",
"请问有什么可以帮助你的?",
"谢谢你的提问!",
"祝你有个美好的一天!",
]
return random.choice(replies)
def send_message():
message = entry.get()
if message:
chat_history.insert(END, "你: " + message + "
")
entry.delete(0, END)
reply = auto_reply(message)
chat_history.insert(END, "机器人: " + reply + "
")
root = Tk()
root.title("自动回复聊天机器人")
chat_history = Text(root, wrap=WORD, width=50, height=10)
chat_history.pack(padx=10, pady=10)
entry = Entry(root, width=50)
entry.pack(padx=10, pady=10)
send_button = Button(root, text="发送", command=send_message)
send_button.pack(padx=10, pady=10)
root.mainloop()