First telegram bot in python.. Lets Create our first echo telegram bot… – Telegram Group

First telegram bot in python.

1. Register a new bot in BotFather

2. Lets Code

from telegram.ext import Updater, CommandHandler, MessageHandler, Filters
def start_bot(update,context):
# Your bot will send this message when users first talk to bot
#using /start command update.message.reply_text('Hi! Welcome. Please give me any text
and i will echo it for you')
def need_help(update, context):     
# on /help command
update.message.reply_text('Help!')
def echo(update, context):     
update.message.reply_text(update.message.text)
def main():
updater = Updater('YOUR_TOKEN')

#get dispatcher from updater to register handlers
dp = updater.dispatcher

# adding start command handler to dispatcher.
#handles /start command
dp.add_handler(CommandHandler('start',start_bot)) # calls help method on /help command
dp.add_handler(CommandHandler('help',need_help)) #on noncommand i.e for text other than start and help , echo
#the message on Telegram

dp.add_handler(MessageHandler(Filters.text, echo))

# Start the Bot
updater.start_polling() # Run the bot until you press Ctrl-C or the process receives
#SIGINT, SIGTERM or SIGABRT. This should be used most of the

# time, since,start_polling() is non-blocking and will stop
# the bot
updater.idle()

if __name__ == '__main__':
main()
python bot.py

Lets check our Echo ? in action

nohop python3 bot.py &

Ten articles before and after

Snap-It Find-It: Your Shopping Companion Bot – Telegram Group

Membuat MJPEG Stream Camera Menggunakan ESP32-CAM — Part 2 – Telegram Group

How to Write a Quick and Easy Telegram Bot that Posts Messages with Python – Telegram Group

Create Telegram Chatbot. In January 2022, Telegram announced… – Telegram Group

Telegram Secret Chat — Enable Now to be Secure – Telegram Group

How to use the MOONCLONE Bot. To being using MOONCLONE BOT open up… – Telegram Group

How to restart a python program from inside – Telegram Group

How my Telegram bot “Vaccination finder” helped community and scaled for large scale users. Problems to Solutions — journey ! – Telegram Group

How to Make a Telegram Pokédex Bot Using Python – Telegram Group

? How to create a Telegram Crypto Bot in Javascript – Telegram Group