吾爱破解 - 52pojie.cn

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

查看: 2169|回复: 44
收起左侧

[Python 转载] 利用ai写的LOL聊天一键喊话

[复制链接]
whz1998 发表于 2026-3-30 09:42
本帖最后由 whz1998 于 2026-3-30 09:46 编辑

昨天打完LOL后 跟队友进行了一番国粹聊天,可能对方没尽兴,还加我好友要继续和我沟通

可能是个人魅力吧,想要找我再续前缘

但是我哪那么多时间跟他干劈情操

于是 顺手ai生成了一键喊话

然后放在那 我吃饭去了,截图就不放了,审核过不去,放一个拿我朋友测试的吧

在这个代码同级目录新建个messages.txt]文件 里面一行一行写好你要发送的话就行了

import pyautogui, pyperclip, pygetwindow as gw, time, random, json, threading, tkinter as tk
from tkinter import filedialog, messagebox

CONFIG_FILE = "config.json"
config = {"txt_file":"messages.txt","avg_delay":0.1}
RUNNING = False
messages = []

def save_config():
    with open(CONFIG_FILE,"w",encoding="utf-8") as f: json.dump(config,f,indent=4)

def load_config():
    global config
    try:
        with open(CONFIG_FILE,"r",encoding="utf-8") as f: config=json.load(f)
    except: save_config()

def load_messages():
    global messages
    try:
        with open(config["txt_file"],"r",encoding="utf-8") as f:
            messages=[line.strip() for line in f if line.strip()]
        if not messages: messagebox.showwarning("警告","消息文件为空!")
    except Exception as e: messagebox.showerror("错误",f"读取文件失败: {e}")

def focus_lol_client():
    windows = gw.getWindowsWithTitle("League of Legends")
    if windows: windows[0].activate(); time.sleep(0.15); return True
    else: print("没找到LOL客户端窗口"); return False

def smart_delay():
    avg=config.get("avg_delay",0.1)
    while True:
        t=random.expovariate(1/avg)
        if t<=1.3: return t

def send_message(msg):
    pyperclip.copy(msg)
    time.sleep(0.01)
    pyautogui.hotkey('ctrl','v')
    time.sleep(0.01)
    pyautogui.press('enter')
    time.sleep(0.02)

def start_loop_thread():
    global RUNNING
    RUNNING=True
    if not messages: load_messages()
    if not messages: return
    i=0
    while RUNNING:
        if focus_lol_client():
            send_message(messages[i])
            print("发送:",messages[i])
            i=(i+1)%len(messages)
        time.sleep(smart_delay())
    print("已停止发送")

def start_loop(): threading.Thread(target=start_loop_thread,daemon=True).start()
def stop_loop(): global RUNNING; RUNNING=False

def choose_file():
    file_path=filedialog.askopenfilename(filetypes=[("Text files","*.txt")])
    if file_path: config["txt_file"]=file_path; save_config(); load_messages(); file_label.config(text=file_path)

def update_delay(): config["avg_delay"]=delay_var.get(); save_config()

# ===== GUI =====
load_config()
load_messages()
root=tk.Tk()
root.title("LOL 客户端消息助手")
root.geometry("500x400")  # 窗口高度加大,保证按钮可见

tk.Label(root,text="消息文件:").pack(pady=5)
file_label=tk.Label(root,text=config["txt_file"])
file_label.pack(fill='x', padx=20)
tk.Button(root,text="选择文件",command=choose_file).pack(fill='x', padx=20, pady=5)

tk.Label(root,text="消息平均间隔(秒):").pack(pady=5)
delay_var=tk.DoubleVar(value=config.get("avg_delay",0.1))
tk.Entry(root,textvariable=delay_var).pack(fill='x', padx=20)
tk.Button(root,text="保存间隔",command=update_delay).pack(fill='x', padx=20, pady=5)

start_button=tk.Button(root,text="开始发送",command=start_loop,bg="green",fg="white")
start_button.pack(fill='x', padx=20, pady=5)

stop_button=tk.Button(root,text="停止发送",command=stop_loop,bg="red",fg="white")
stop_button.pack(fill='x', padx=20, pady=5)

root.mainloop()
image.png
image.png

免费评分

参与人数 6吾爱币 +4 热心值 +5 收起 理由
TWYX + 1 + 1 用心讨论,共获提升!
menyu001 + 1 我很赞同!
weidechan + 1 感谢发布原创作品,吾爱破解论坛因你更精彩!
WantWithMe + 1 + 1 用心讨论,共获提升!
gNehcx + 1 + 1 谢谢@Thanks!
amateur150 + 1 我很赞同!

查看全部评分

发帖前要善用论坛搜索功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。

 楼主| whz1998 发表于 2026-3-30 09:47
qqqasdwx 发表于 2026-3-30 09:46
为啥不直接用ai实时生成对话

ai哪有我骂的脏
TWYX 发表于 2026-5-19 11:14
whz1998 发表于 2026-5-19 09:55
哈哈哈 这你也卷是吧,该说不说 确实好看了

哈哈哈,楼主的思路更重要,我只是站在巨人肩膀上,做了点小小美化
qqqasdwx 发表于 2026-3-30 09:46
fwbx529 发表于 2026-3-30 09:47
笑死,以后会不会发展到游戏里两个人对线,最后发现都是AI自动发的
ahyun 发表于 2026-3-30 09:48
有趣,这不会被封号或者禁言吧。毕竟有三方程序在运行
 楼主| whz1998 发表于 2026-3-30 09:48
fwbx529 发表于 2026-3-30 09:47
笑死,以后会不会发展到游戏里两个人对线,最后发现都是AI自动发的

哈哈哈,星际大战第一次触发
 楼主| whz1998 发表于 2026-3-30 09:50
ahyun 发表于 2026-3-30 09:48
有趣,这不会被封号或者禁言吧。毕竟有三方程序在运行

我昨天跟那个人试了一下,大概我用了一顿饭工夫, 好像20分钟吧 晚上正常登录
FCGkitty 发表于 2026-3-30 09:57
qqqasdwx 发表于 2026-3-30 09:46
为啥不直接用ai实时生成对话

虚空索敌么,好吓人
gNehcx 发表于 2026-3-30 10:03
以后就演变成ai对轰了
 楼主| whz1998 发表于 2026-3-30 10:04
gNehcx 发表于 2026-3-30 10:03
以后就演变成ai对轰了

会利用工具的人 先轰炸
您需要登录后才可以回帖 登录 | 注册[Register]

本版积分规则

返回列表

RSS订阅|小黑屋|处罚记录|联系我们|吾爱破解 - 52pojie.cn ( 京ICP备16042023号 | 京公网安备 11010502030087号 )

GMT+8, 2026-6-10 10:13

Powered by Discuz!

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表