-
Notifications
You must be signed in to change notification settings - Fork 110
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #100 from PavanTeja2005/telebot
Added telegram bot feature.
- Loading branch information
Showing
1 changed file
with
23 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
from telegram import Update | ||
from telegram.ext import ApplicationBuilder, CommandHandler, MessageHandler, filters, CallbackContext | ||
|
||
def telebot(): | ||
async def start(update: Update, context: CallbackContext) -> None: | ||
"""Send a welcome message when the /start command is issued.""" | ||
await update.message.reply_text('Hello! I am your bot. Send me any message and I will echo it back!') | ||
|
||
async def echo(update: Update, context: CallbackContext) -> None: | ||
"""Echo the received message.""" | ||
await update.message.reply_text(update.message.text) | ||
|
||
def main() -> None: | ||
app = ApplicationBuilder().token("7854626087:AAF5ls0oB8XR3SvQhWkxmea42e7FSf0yKTE").build() | ||
|
||
app.add_handler(CommandHandler("start", start)) | ||
app.add_handler(MessageHandler(filters.TEXT & ~filters.COMMAND, echo)) | ||
|
||
app.run_polling() | ||
main() | ||
|
||
if __name__ == '__main__': | ||
telebot() |