返回列表 发布新帖

利用ai写的LOL聊天一键喊话

4340 1
邓小K 发表于 2026-3-31 02:27:48 | 查看全部 阅读模式 <

马上注册,结交更多好友,享用更多功能,让你轻松玩转小K网。

您需要 登录 才可以下载或查看,没有账号?立即注册 微信登录

×
昨天打完LOL后 跟队友进行了一番国粹聊天,可能对方没尽兴,还加我好友要继续和我沟通
可能是个人魅力吧,想要找我再续前缘
但是我哪那么多时间跟他干劈情操
于是 顺手ai生成了一键喊话
然后放在那 我吃饭去了,截图就不放了,审核过不去,放一个拿我朋友测试的吧
在这个代码同级目录新建个messages.txt]文件 里面一行一行写好你要发送的话就行了

利用ai写的LOL聊天一键喊话

利用ai写的LOL聊天一键喊话

利用ai写的LOL聊天一键喊话

利用ai写的LOL聊天一键喊话

Python代码:
  1. import pyautogui, pyperclip, pygetwindow as gw, time, random, json, threading, tkinter as tk
  2. from tkinter import filedialog, messagebox
  3. CONFIG_FILE = "config.json"
  4. config = {"txt_file":"messages.txt","avg_delay":0.1}
  5. RUNNING = False
  6. messages = []
  7. def save_config():
  8.     with open(CONFIG_FILE,"w",encoding="utf-8") as f: json.dump(config,f,indent=4)
  9. def load_config():
  10.     global config
  11.     try:
  12.         with open(CONFIG_FILE,"r",encoding="utf-8") as f: config=json.load(f)
  13.     except: save_config()
  14. def load_messages():
  15.     global messages
  16.     try:
  17.         with open(config["txt_file"],"r",encoding="utf-8") as f:
  18.             messages=[line.strip() for line in f if line.strip()]
  19.         if not messages: messagebox.showwarning("警告","消息文件为空!")
  20.     except Exception as e: messagebox.showerror("错误",f"读取文件失败: {e}")
  21. def focus_lol_client():
  22.     windows = gw.getWindowsWithTitle("League of Legends")
  23.     if windows: windows[0].activate(); time.sleep(0.15); return True
  24.     else: print("没找到LOL客户端窗口"); return False
  25. def smart_delay():
  26.     avg=config.get("avg_delay",0.1)
  27.     while True:
  28.         t=random.expovariate(1/avg)
  29.         if t<=1.3: return t
  30. def send_message(msg):
  31.     pyperclip.copy(msg)
  32.     time.sleep(0.01)
  33.     pyautogui.hotkey('ctrl','v')
  34.     time.sleep(0.01)
  35.     pyautogui.press('enter')
  36.     time.sleep(0.02)
  37. def start_loop_thread():
  38.     global RUNNING
  39.     RUNNING=True
  40.     if not messages: load_messages()
  41.     if not messages: return
  42.     i=0
  43.     while RUNNING:
  44.         if focus_lol_client():
  45.             send_message(messages[i])
  46.             print("发送:",messages[i])
  47.             i=(i+1)%len(messages)
  48.         time.sleep(smart_delay())
  49.     print("已停止发送")
  50. def start_loop(): threading.Thread(target=start_loop_thread,daemon=True).start()
  51. def stop_loop(): global RUNNING; RUNNING=False
  52. def choose_file():
  53.     file_path=filedialog.askopenfilename(filetypes=[("Text files","*.txt")])
  54.     if file_path: config["txt_file"]=file_path; save_config(); load_messages(); file_label.config(text=file_path)
  55. def update_delay(): config["avg_delay"]=delay_var.get(); save_config()
  56. # ===== GUI =====
  57. load_config()
  58. load_messages()
  59. root=tk.Tk()
  60. root.title("LOL 客户端消息助手")
  61. root.geometry("500x400")  # 窗口高度加大,保证按钮可见
  62. tk.Label(root,text="消息文件:").pack(pady=5)
  63. file_label=tk.Label(root,text=config["txt_file"])
  64. file_label.pack(fill='x', padx=20)
  65. tk.Button(root,text="选择文件",command=choose_file).pack(fill='x', padx=20, pady=5)
  66. tk.Label(root,text="消息平均间隔(秒):").pack(pady=5)
  67. delay_var=tk.DoubleVar(value=config.get("avg_delay",0.1))
  68. tk.Entry(root,textvariable=delay_var).pack(fill='x', padx=20)
  69. tk.Button(root,text="保存间隔",command=update_delay).pack(fill='x', padx=20, pady=5)
  70. start_button=tk.Button(root,text="开始发送",command=start_loop,bg="green",fg="white")
  71. start_button.pack(fill='x', padx=20, pady=5)
  72. stop_button=tk.Button(root,text="停止发送",command=stop_loop,bg="red",fg="white")
  73. stop_button.pack(fill='x', padx=20, pady=5)
  74. root.mainloop()
复制代码


请大家文明发帖,遵守法律法规!站长QQ460551

评论1

手机用户dr54227Lv.2 发表于 2026-3-31 14:15:59 | 查看全部 <
🆕占个楼, 不过分吧!
回复

使用道具 举报

回复

您需要登录后才可以回帖 登录 | 立即注册 微信登录

本版积分规则

您需要 登录 后才可以回复,轻松玩转社区,没有帐号?立即注册
快速回复
关灯 在本版发帖
扫一扫添加微信客服
QQ客服返回顶部
快速回复 返回顶部 返回列表