Telegram 消息监听与自动化推送工具。
tgsender/
├── config/
│ └── bot.template.ini # 机器人配置文件模板
├── src/tgsender/
│ └── main-proxy-sql1.py # 消息监听机器人(Telethon + MySQL)
├── get_session.py # Telegram StringSession 获取工具
├── requirements.txt
└── .gitignore
pip install -r requirements.txtpython get_session.py按提示输入 Telegram API ID 和 API Hash(在 https://my.telegram.org 获取),支持代理登录,登录后即可得到 Session 字符串。
cp config\bot.template.ini config\bot.ini编辑 config\bot.ini,填入 Telegram 凭证、数据库连接信息和代理配置。
python src/tgsender/main-proxy-sql1.py config/bot.ini机器人会:
- 监听指定用户的私聊消息(余额回复、余额不足通知)
- 定时查询数据库中的待推送
betResult记录并发送 - 每小时定时发送「流水」查询并记录余额变化
| 字段 | 说明 |
|---|---|
api_id |
Telegram API ID |
api_hash |
Telegram API Hash |
session |
Session 字符串(用 get_session.py 获取) |
target |
目标对话(用户 ID 或 @用户名) |
支持 SOCKS5 代理,设置 enabled = True 并填入地址、端口、用户名和密码。
| 字段 | 说明 |
|---|---|
acc_id |
账号标识 |
acc_user |
监控的用户名 |
interval |
主循环间隔(秒,默认 30) |
MySQL 数据库连接配置。程序使用连接池管理数据库连接。
- Telethon — Telegram MTProto 客户端
- mysql-connector-python — MySQL 数据库驱动