-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
79 lines (65 loc) · 2.53 KB
/
main.py
File metadata and controls
79 lines (65 loc) · 2.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
"""Main entry point for the PGDN Discord Bot."""
import asyncio
import logging
import sys
import os
# Add src to path so we can import our modules
sys.path.insert(0, os.path.join(os.path.dirname(__file__), 'src'))
# Try to load environment variables from .env file
try:
from dotenv import load_dotenv
load_dotenv(dotenv_path='.env')
except ImportError:
print("WARNING - python-dotenv not installed, using system environment variables")
print("Install with: pip install python-dotenv")
# Configure logging
logging.basicConfig(
level=logging.INFO,
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s'
)
logger = logging.getLogger(__name__)
from src.services import ServiceProvider
from src.commands.start import setup_command as setup_start_command
from src.commands.list import setup_command as setup_list_command
from src.commands.help import setup_command as setup_help_command
from src.commands.info import setup_command as setup_info_command
from src.commands.claim import setup_command as setup_claim_command
from src.commands.add import setup_command as setup_add_command
from src.commands.rescan import setup_command as setup_rescan_command
from src.commands.privacy import setup_command as setup_privacy_command
from src.commands.recommendations import setup_command as setup_recommendations_command
from src.commands.feedback import setup_command as setup_feedback_command
async def main():
"""Main function to start the bot."""
try:
# Create service provider and initialize dependencies
services = ServiceProvider()
bot = services.create_bot()
# Register ALL commands
setup_start_command(bot)
setup_list_command(bot)
setup_help_command(bot)
setup_info_command(bot)
setup_claim_command(bot)
setup_add_command(bot)
setup_rescan_command(bot)
setup_privacy_command(bot)
setup_recommendations_command(bot)
setup_feedback_command(bot)
logger.info("ALL commands registered successfully - migration complete!")
# Start the bot
config = services.create_config()
await bot.start(config.discord_bot_token)
except KeyboardInterrupt:
logger.info("Bot stopped by user")
except Exception as e:
logger.error(f"Failed to start bot: {e}", exc_info=True)
return 1
return 0
if __name__ == "__main__":
try:
exit_code = asyncio.run(main())
sys.exit(exit_code)
except KeyboardInterrupt:
logger.info("Bot stopped by user")
sys.exit(0)