65 lines
1.8 KiB
Python
65 lines
1.8 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
测试AI Bots状态
|
|
"""
|
|
import asyncio
|
|
import discord
|
|
import sys
|
|
import os
|
|
from pathlib import Path
|
|
|
|
# 添加项目根目录到Python路径
|
|
sys.path.append(str(Path(__file__).parent.parent))
|
|
from utils.token_reader import TokenReader
|
|
|
|
async def test_bot_connection(token, bot_name):
|
|
"""测试bot连接状态"""
|
|
try:
|
|
intents = discord.Intents.default()
|
|
client = discord.Client(intents=intents)
|
|
|
|
@client.event
|
|
async def on_ready():
|
|
print(f"✅ {bot_name} 连接成功!")
|
|
print(f" Bot名称: {client.user}")
|
|
print(f" Bot ID: {client.user.id}")
|
|
print(f" 在 {len(client.guilds)} 个服务器中")
|
|
|
|
for guild in client.guilds:
|
|
print(f" - {guild.name} (ID: {guild.id})")
|
|
|
|
await client.close()
|
|
|
|
await client.start(token)
|
|
|
|
except Exception as e:
|
|
print(f"❌ {bot_name} 连接失败: {e}")
|
|
|
|
async def main():
|
|
"""主函数"""
|
|
token_reader = TokenReader("/home/will/docker/tokens.txt")
|
|
|
|
print("🤖 测试AI Bots连接状态...")
|
|
print("=" * 50)
|
|
|
|
# 测试ChatGPT Bot
|
|
chatgpt_token = token_reader.get_token('chatgpt_discord_token')
|
|
if chatgpt_token:
|
|
await test_bot_connection(chatgpt_token, "ChatGPT Bot")
|
|
|
|
print()
|
|
|
|
# 测试DeepSeek Bot
|
|
deepseek_token = token_reader.get_token('deepseek_discord_token')
|
|
if deepseek_token:
|
|
await test_bot_connection(deepseek_token, "DeepSeek Bot")
|
|
|
|
print()
|
|
|
|
# 测试Claude Bot
|
|
claude_token = token_reader.get_token('claude_discord_token')
|
|
if claude_token:
|
|
await test_bot_connection(claude_token, "Claude Bot")
|
|
|
|
if __name__ == "__main__":
|
|
asyncio.run(main()) |