-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtele_utils.py
28 lines (22 loc) · 976 Bytes
/
tele_utils.py
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
from telegram import Update
from telegram.ext import ApplicationBuilder, CommandHandler, ContextTypes
import os
from dotenv import load_dotenv
load_dotenv()
TELEGRAM_BOT_PYTHON_GUIDANCE_API_KEY = os.getenv("TELEGRAM_BOT_PYTHON_GUIDANCE_API_KEY")
async def start(update: Update, context: ContextTypes.DEFAULT_TYPE):
"""
Handler for the /start command. Prints the chat_id when the command is received.
"""
chat_id = update.effective_chat.id
await update.message.reply_text(f"Your chat ID is: {chat_id}")
print(f"Chat ID: {chat_id}")
if __name__ == "__main__":
# Create the application and pass the bot token
application = ApplicationBuilder().token(TELEGRAM_BOT_PYTHON_GUIDANCE_API_KEY).build()
# Register the /start command handler
start_handler = CommandHandler('start', start)
application.add_handler(start_handler)
# Start the bot
print("Bot is running...")
application.run_polling()