├── excel.png ├── run.png ├── README.md ├── dc_adspower.py └── dc_morelogin.py /excel.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0xlin888/discord_message/HEAD/excel.png -------------------------------------------------------------------------------- /run.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0xlin888/discord_message/HEAD/run.png -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Discord自动GM养号、自动领水 - 通过Morelogin、AdsPower 2 | 📢 我的推特 3 | 🔗[@0x零](https://x.com/0xlin168) 求个关注!如果有任何使用问题,可以通过推特联系我。 4 | ## 📌 1. 这个是什么脚本? 5 | 这个 Python 脚本可以帮助你通过Morelogin打开Discord指定的频道,自动发送指定消息,可以用于gm养号和领水。 6 | 7 | --- 8 | 9 | ## 🛠 2. 需要准备什么? 10 | 11 | ### ✅ 基础要求 12 | - 一台可以运行 Python 的电脑(Windows / Mac / Linux 都可以) 13 | - 安装 Python(建议使用 Python 3.8 及以上) 14 | - 使用Morelogin指纹浏览器或AdsPower指纹浏览器 15 | 16 | ### ✅ 安装 Python 17 | 如果你的电脑没有 Python,可以按照下面的方式安装: 18 | 1. **Windows 用户**: 19 | - 访问 [Python 官网](https://www.python.org/downloads/) 下载最新版本。 20 | - 安装时勾选“Add Python to PATH”。 21 | - 安装完成后,在终端(cmd)输入 `python --version`,如果出现 Python 版本号,说明安装成功。 22 | 23 | 2. **Mac 用户**: 24 | - 打开“终端”输入: 25 | ```sh 26 | brew install python 27 | ``` 28 | - 安装完成后,输入 `python3 --version` 检查是否成功。 29 | 30 | --- 31 | 32 | ## 📦 3. 安装必需的工具 33 | 34 | 打开终端(Windows 叫“命令提示符” CMD),输入以下命令安装所需的 Python 库: 35 | 36 | ```sh 37 | pip install requests pandas openpyxl playwright 38 | playwright install 39 | ``` 40 | 41 | 如果安装成功,你可以输入 `pip list` 来检查它们是否已经安装。 42 | 43 | --- 44 | 45 | ## 📊 4. 准备 Excel 文件 46 | 47 | 创建一个 Excel 文件,文件格式如下: 48 | 49 | ![](https://raw.githubusercontent.com/0xlin888/discord_message/refs/heads/main/excel.png?raw=true) 50 | 51 | - **第一列** 52 | - 如果你用的是**Morelogin**,第一列列名为unique_id:Morelogin环境序号 53 | - 如果你用的是**AdsPower**,第一列列名为serial_number:AdsPower环境编号 54 | - **第二列**(discord_url):需要发送消息的频道链接 55 | - **第三列**(message):消息内容 56 | --- 57 | 58 | ## 📜 5. 运行脚本 59 | 60 | **如果你是Morelogin** 61 | 62 | 修改dc_morelogin.py配置,找到大概第89行,修改EXCEL路径为你自己的 63 | 64 | **如果你是AdsPower** 65 | 66 | 修改dc_Adspower.py配置,找到大概第79行,修改EXCEL路径为你自己的 67 | 68 | 然后运行脚本,不会运行脚本看6常见问题 69 | 70 | ![](https://raw.githubusercontent.com/0xlin888/discord_message/refs/heads/main/run.png?raw=true) 71 | 72 | --- 73 | 74 | ## 🧐 6. 常见问题 75 | 76 | ### ❓ 如何确认 Python 是否安装正确? 77 | 打开终端输入: 78 | ```sh 79 | python --version 80 | ``` 81 | 如果出现类似 `Python 3.10.5`,说明安装成功。 82 | 83 | ### ❓ 运行 `pip install` 时出错? 84 | 尝试加 `--upgrade` 重新安装: 85 | ```sh 86 | pip install --upgrade requests pandas openpyxl 87 | ``` 88 | ### ❓ 如何运行脚本? 89 | 90 | **步骤 1: 打开命令行工具** 91 | 92 | Windows**:按 `Win + R`,输入 `cmd`,然后按回车。 93 | 94 | Mac/Linux**:打开终端(Terminal)。 95 | 96 | **步骤 2: 切换到脚本目录** 97 | 98 | 使用 `cd` 命令切换到存放 Python 脚本的目录。假设你的脚本在桌面上的 `my_project` 文件夹中,可以使用以下命令: 99 | 100 | ```bash 101 | cd ~/Desktop/my_project 102 | ``` 103 | **步步骤 3: 运行脚本** 104 | ```bash 105 | python3 script.py 106 | ``` 107 | script改为你要运行的脚本名 108 | --- 109 | 110 | ## 🛑 7. 免责声明 111 | 本脚本仅供学习交流,请自行承担使用风险!使用前请确保了解 OKX 的提现规则。 112 | 113 | 📌 **有问题?欢迎留言讨论!** 🚀 114 | -------------------------------------------------------------------------------- /dc_adspower.py: -------------------------------------------------------------------------------- 1 | import time 2 | import traceback 3 | import requests 4 | import pandas as pd 5 | from playwright.sync_api import sync_playwright 6 | 7 | def start(serial_number): 8 | print(f"[{serial_number}] 正在启动 AdsPower 环境") 9 | try: 10 | url = f"http://127.0.0.1:50325/api/v1/browser/start?serial_number={serial_number}" 11 | resp = requests.get(url, timeout=10).json() 12 | if resp.get("code") != 0: 13 | print(f"[{serial_number}] 启动失败: {resp.get('msg', '未知错误')}") 14 | return None 15 | ws = resp["data"].get("ws", {}) 16 | cdp_url = ws.get("puppeteer") 17 | if not cdp_url: 18 | print(f"[{serial_number}] 启动失败: 未返回 puppeteer 地址") 19 | return None 20 | print(f"[{serial_number}] CDP 地址获取成功") 21 | return cdp_url 22 | except Exception: 23 | print(f"[{serial_number}] 启动出错: {traceback.format_exc()}") 24 | return None 25 | 26 | def operation(cdp_url, discord_url, message, serial_number, playwright): 27 | try: 28 | browser = playwright.chromium.connect_over_cdp(cdp_url) 29 | page = browser.contexts[0].new_page() 30 | 31 | session = browser.contexts[0].new_cdp_session(page) 32 | session.send("Emulation.setDeviceMetricsOverride", { 33 | "width": 1280, "height": 800, 34 | "deviceScaleFactor": 1, "mobile": False 35 | }) 36 | 37 | # 打开页面 38 | page.goto(discord_url, timeout=30000) 39 | page.wait_for_selector('div[role="textbox"]', timeout=15000) 40 | 41 | # 详细的步骤日志 42 | print(f"[{serial_number}] 找到输入框") 43 | textbox = page.query_selector('div[role="textbox"]') 44 | 45 | print(f"[{serial_number}] 输入消息: {message}") 46 | textbox.click() 47 | textbox.type(message) 48 | 49 | print(f"[{serial_number}] 消息已发送") 50 | page.keyboard.press("Enter") 51 | 52 | # 小等待保证消息发出 53 | time.sleep(3) 54 | 55 | except Exception: 56 | print(f"[{serial_number}] 操作出错: {traceback.format_exc()}") 57 | 58 | def stop(serial_number): 59 | print(f"[{serial_number}] 正在关闭 AdsPower 环境") 60 | try: 61 | url = f"http://127.0.0.1:50325/api/v1/browser/stop?serial_number={serial_number}" 62 | resp = requests.get(url, timeout=10).json() 63 | if resp.get("code") != 0: 64 | print(f"[{serial_number}] 关闭失败: {resp.get('msg', '未知错误')}") 65 | else: 66 | print(f"[{serial_number}] 已关闭") 67 | except Exception: 68 | print(f"[{serial_number}] 关闭出错: {traceback.format_exc()}") 69 | 70 | def handle_task(row, playwright): 71 | sn = str(row["serial_number"]) 72 | cdp = start(sn) 73 | if not cdp: 74 | return 75 | operation(cdp, row["discord_url"], row["message"], sn, playwright) 76 | stop(sn) 77 | 78 | def main(): 79 | df = pd.read_excel(r"C:\脚本\gmgm\gm_list.xlsx") 80 | with sync_playwright() as pw: 81 | for _, row in df.sort_values("serial_number").iterrows(): 82 | time.sleep(3) 83 | handle_task(row, pw) 84 | 85 | if __name__ == "__main__": 86 | main() 87 | -------------------------------------------------------------------------------- /dc_morelogin.py: -------------------------------------------------------------------------------- 1 | import time 2 | import traceback 3 | import requests 4 | import pandas as pd 5 | from playwright.sync_api import sync_playwright 6 | 7 | def get_timestamp(): 8 | return time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) 9 | 10 | def start(unique_id): 11 | print(f"[{unique_id}] 正在启动浏览器环境") 12 | try: 13 | resp = requests.post( 14 | "http://localhost:40000/api/env/start", 15 | json={"envId": "", "uniqueId": unique_id} 16 | ) 17 | data = resp.json() 18 | if data["code"] != 0: 19 | print(f"[{unique_id}] 启动失败: {data['msg']} (code: {data['code']})") 20 | return None 21 | port = data["data"]["debugPort"] 22 | url = f"http://127.0.0.1:{port}" 23 | print(f"[{unique_id}] 浏览器环境已启动: {url}") 24 | return url 25 | except Exception: 26 | print(f"[{unique_id}] 启动出错: {traceback.format_exc()}") 27 | return None 28 | 29 | def operation(cdp_url, discord_url, message, unique_id, playwright): 30 | try: 31 | print(f"[{unique_id}] 连接到浏览器: {cdp_url}") 32 | browser = playwright.chromium.connect_over_cdp(cdp_url) 33 | ctx = browser.contexts[0] 34 | page = ctx.new_page() 35 | 36 | # 模拟视口大小 37 | session = ctx.new_cdp_session(page) 38 | session.send("Emulation.setDeviceMetricsOverride", { 39 | "width": 1280, "height": 800, 40 | "deviceScaleFactor": 1, "mobile": False 41 | }) 42 | print(f"[{unique_id}] 已设置视口为 1280×800") 43 | 44 | print(f"[{unique_id}] 打开页面: {discord_url}") 45 | page.goto(discord_url) 46 | page.wait_for_selector('div[role="textbox"]', timeout=15000) 47 | 48 | print(f"[{unique_id}] 输入消息: {message}") 49 | page.click('div[role="textbox"]') 50 | page.type('div[role="textbox"]', message) 51 | page.keyboard.press("Enter") 52 | print(f"[{unique_id}] 消息已发送") 53 | 54 | time.sleep(3) 55 | print(f"[{unique_id}] 已等待 3 秒") 56 | except Exception: 57 | print(f"[{unique_id}] 操作出错: {traceback.format_exc()}") 58 | 59 | def stop(unique_id): 60 | print(f"[{unique_id}] 正在关闭浏览器环境") 61 | try: 62 | resp = requests.post( 63 | "http://localhost:40000/api/env/close", 64 | json={"envId": "", "uniqueId": unique_id} 65 | ) 66 | data = resp.json() 67 | if data["code"] == -1: 68 | print(f"[{unique_id}] 关闭失败: {data['msg']}") 69 | return 70 | print(f"[{unique_id}] 浏览器环境已关闭") 71 | except Exception: 72 | print(f"[{unique_id}] 关闭出错: {traceback.format_exc()}") 73 | 74 | def handle_task(row, playwright): 75 | unique_id = int(row["unique_id"]) 76 | discord_url = str(row["discord_url"]) 77 | message = str(row["message"]) 78 | 79 | print(f"\n[{unique_id}] 开始处理: url={discord_url}, message={message}") 80 | cdp_url = start(unique_id) 81 | if not cdp_url: 82 | return 83 | operation(cdp_url, discord_url, message, unique_id, playwright) 84 | stop(unique_id) 85 | print(f"[{unique_id}] 任务完成") 86 | 87 | def main(): 88 | # 这里改为Excel文件的正确路径 89 | df = pd.read_excel(r"D:\脚本\gmgm\gm_list.xlsx") 90 | with sync_playwright() as playwright: 91 | # 按 unique_id 排序后,逐行同步处理 92 | for _, row in df.sort_values("unique_id").iterrows(): 93 | time.sleep(3) # 启动前间隔 94 | handle_task(row, playwright) 95 | 96 | if __name__ == "__main__": 97 | main() 98 | --------------------------------------------------------------------------------