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() 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 @@
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() - -
$ pip install python-telegram-bot
+ $ pip install python-telegram-bot --pre $ python bot.py