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 FILTER BOT TUTORIAL | |
GitHub: TraxDinosaur | |
Replit: TraxDinosaur | |
Instagram: @TraxDinosaur | |
YouTube: @TraxDinosaur | |
Blogger: TraxDinosaurs | |
''' | |
import logging | |
from telegram import Update | |
from telegram.ext import ApplicationBuilder, ContextTypes, CommandHandler, 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 TraxDinosaur") | |
async def send_hello(update:Update, context:ContextTypes.DEFAULT_TYPE): | |
await update.message.reply_text("Heyy Welcome Here!") # It will send this string to user. | |
print("Bot Is Working") | |
app = ApplicationBuilder().token("YOUR_BOT_TOKEN").build() | |
start_handler = CommandHandler('start', start) | |
app.add_handler(start_handler) | |
hello_handler = MessageHandler(filters.Regex(r'hi'),send_hello) # When User Will Send hi in Chat | |
app.add_handler(hello_handler) | |
app.run_polling() |
0 Comments