chore: initial commit
This commit is contained in:
43
core/debug_bot.py
Normal file
43
core/debug_bot.py
Normal file
@@ -0,0 +1,43 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
调试脚本:查看与 BOT 的对话历史
|
||||
"""
|
||||
|
||||
import asyncio
|
||||
from telethon import TelegramClient
|
||||
|
||||
API_ID = 24660516
|
||||
API_HASH = "eae564578880a59c9963916ff1bbbd3a"
|
||||
SESSION_NAME = "funstat_bot_session"
|
||||
BOT_USERNAME = "@openaiw_bot"
|
||||
|
||||
async def debug_bot():
|
||||
client = TelegramClient(SESSION_NAME, API_ID, API_HASH)
|
||||
await client.start()
|
||||
|
||||
bot_entity = await client.get_entity(BOT_USERNAME)
|
||||
print(f"BOT: {bot_entity.first_name} (ID: {bot_entity.id})")
|
||||
print()
|
||||
|
||||
# 发送 /start 命令
|
||||
print("发送 /start...")
|
||||
await client.send_message(bot_entity, "/start")
|
||||
|
||||
# 等待一下
|
||||
await asyncio.sleep(3)
|
||||
|
||||
# 获取最近的消息
|
||||
print("\n最近的 10 条消息:")
|
||||
print("=" * 60)
|
||||
|
||||
async for message in client.iter_messages(bot_entity, limit=10):
|
||||
sender = "我" if message.out else "BOT"
|
||||
print(f"\n[{sender}] {message.date}")
|
||||
if message.text:
|
||||
print(message.text[:200])
|
||||
print("-" * 60)
|
||||
|
||||
await client.disconnect()
|
||||
|
||||
if __name__ == "__main__":
|
||||
asyncio.run(debug_bot())
|
||||
Reference in New Issue
Block a user