From 667b7f76d8a8805e21c3be0ae83e251d731050fe Mon Sep 17 00:00:00 2001 From: Harshil <37377066+harshil21@users.noreply.github.com> Date: Wed, 11 May 2022 15:35:55 +0530 Subject: [PATCH 1/2] adapt to v20.0a1 changes --- website/static/website/example.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/website/static/website/example.py b/website/static/website/example.py index cd900d8..cc43b5e 100644 --- a/website/static/website/example.py +++ b/website/static/website/example.py @@ -1,14 +1,13 @@ from telegram import Update -from telegram.ext import Updater, CommandHandler, CallbackContext +from telegram.ext import ApplicationBuilder, CommandHandler, ContextTypes -def hello(update: Update, context: CallbackContext) -> None: - update.message.reply_text(f'Hello {update.effective_user.first_name}') +async def hello(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None: + await update.message.reply_text(f'Hello {update.effective_user.first_name}') -updater = Updater('YOUR TOKEN HERE') +app = ApplicationBuilder().token("YOUR TOKEN HERE").build() -updater.dispatcher.add_handler(CommandHandler('hello', hello)) +app.add_handler(CommandHandler("hello", hello)) -updater.start_polling() -updater.idle() +app.run_polling() From 227e17b6c8715ca9d1bedabe85272f44919add7a Mon Sep 17 00:00:00 2001 From: Harshil <37377066+harshil21@users.noreply.github.com> Date: Wed, 11 May 2022 16:01:51 +0530 Subject: [PATCH 2/2] update index.html --- website/templates/website/index.html | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/website/templates/website/index.html b/website/templates/website/index.html index 0805d08..a052243 100644 --- a/website/templates/website/index.html +++ b/website/templates/website/index.html @@ -16,27 +16,26 @@

It's fun

from telegram import Update
-from telegram.ext import Updater, CommandHandler, CallbackContext
+from telegram.ext import ApplicationBuilder, CommandHandler, ContextTypes
 
 
-def hello(update: Update, context: CallbackContext) -> None:
-    update.message.reply_text(f'Hello {update.effective_user.first_name}')
+async def hello(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
+    await update.message.reply_text(f'Hello {update.effective_user.first_name}')
 
 
-updater = Updater('YOUR TOKEN HERE')
+app = ApplicationBuilder().token("YOUR TOKEN HERE").build()
 
-updater.dispatcher.add_handler(CommandHandler('hello', hello))
+app.add_handler(CommandHandler("hello", hello))
+
+app.run_polling()
+
-updater.start_polling() -updater.idle() - -

Easy to setup

-
$ pip install python-telegram-bot
+		
$ pip install python-telegram-bot --pre
 $ python bot.py

And it is free