-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
69 lines (55 loc) · 1.76 KB
/
Copy pathmain.py
File metadata and controls
69 lines (55 loc) · 1.76 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
"""
Telegram Bot with AsterPay Payments
A complete template for monetizing your Telegram bot with crypto payments.
"""
import os
import logging
from dotenv import load_dotenv
from telegram import Update
from telegram.ext import (
Application,
CommandHandler,
MessageHandler,
CallbackQueryHandler,
filters,
)
from handlers import (
start_command,
help_command,
credits_command,
buy_command,
generate_command,
button_callback,
handle_message,
)
# Load environment variables
load_dotenv()
# Configure logging
logging.basicConfig(
format="%(asctime)s - %(name)s - %(levelname)s - %(message)s",
level=logging.INFO
)
logger = logging.getLogger(__name__)
def main() -> None:
"""Start the bot."""
# Get bot token
token = os.getenv("TELEGRAM_BOT_TOKEN")
if not token:
raise ValueError("TELEGRAM_BOT_TOKEN not set in environment")
# Create application
application = Application.builder().token(token).build()
# Add command handlers
application.add_handler(CommandHandler("start", start_command))
application.add_handler(CommandHandler("help", help_command))
application.add_handler(CommandHandler("credits", credits_command))
application.add_handler(CommandHandler("buy", buy_command))
application.add_handler(CommandHandler("generate", generate_command))
# Add callback handler for inline buttons
application.add_handler(CallbackQueryHandler(button_callback))
# Add message handler for AI responses
application.add_handler(MessageHandler(filters.TEXT & ~filters.COMMAND, handle_message))
# Start the bot
logger.info("Starting bot...")
application.run_polling(allowed_updates=Update.ALL_TYPES)
if __name__ == "__main__":
main()