Code:
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
TELEGRAM REACTION BOT TUTORIAL | |
GitHub: TraxDinosaur | |
Replit: TraxDinosaur | |
Instagram: @TraxDinosaur | |
YouTube: @TraxDinosaur | |
Blog: TraxDinosaurs | |
''' | |
import logging | |
from telegram import Update, Bot, ReactionTypeEmoji | |
from telegram.ext import ApplicationBuilder, ContextTypes, CommandHandler, CallbackContext, MessageHandler, filters | |
logging.basicConfig( | |
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s', | |
level=logging.INFO | |
) | |
async def start(update:Update, context:ContextTypes.DEFAULT_TYPE): | |
await context.bot.send_message(chat_id=update.effective_chat.id,text="This is a reaction bot.") | |
async def reaction(update: Update, context: CallbackContext): | |
emoji = "😱" | |
chat_id = update.message.chat_id | |
message_id = update.message.message_id | |
await context.bot.set_message_reaction(chat_id,message_id,reaction=ReactionTypeEmoji(emoji)) | |
print("Bot Is Working") | |
app = ApplicationBuilder().token("YOUR_BOT_TOKEN").build() | |
start_handler = CommandHandler('start', start) # "Start" Is A Command Name We Use In Telegram Using / & The Second Is We Providing A Function To Perform | |
app.add_handler(start_handler) | |
react_handler = MessageHandler(filters.TEXT & ~filters.COMMAND, reaction) | |
app.add_handler(react_handler) | |
app.run_polling() |
0 Comments