diff --git a/eho_bot/bot.py b/eho_bot/bot.py new file mode 100644 index 0000000..e1a165f --- /dev/null +++ b/eho_bot/bot.py @@ -0,0 +1,39 @@ +import logging + +from telegram import Update +from telegram.ext import Application, CommandHandler, ContextTypes, MessageHandler, filters + +TELEGRAM_BOT_TOKEN = '' + +logging.basicConfig( + format="%(asctime)s - %(name)s - %(levelname)s - %(message)s", level=logging.INFO +) + +logger = logging.getLogger(__name__) + + +async def start(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None: + await update.message.reply_text("Привет, я эхо бот. Напиши мне сообщение и я повторю его") + + +async def help_command(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None: + await update.message.reply_text("Я эхо бот, напиши мне сообщение и я повторю его") + + +async def echo(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None: + await update.message.reply_text(update.message.text) + + +def main() -> None: + application = Application.builder().token(TELEGRAM_BOT_TOKEN).build() + + application.add_handler(CommandHandler("start", start)) + application.add_handler(CommandHandler("help", help_command)) + + application.add_handler(MessageHandler(filters.TEXT & ~filters.COMMAND, echo)) + + application.run_polling(allowed_updates=Update.ALL_TYPES) + + +if __name__ == "__main__": + main() diff --git a/eho_bot/requirements.txt b/eho_bot/requirements.txt new file mode 100644 index 0000000..11a50f9 --- /dev/null +++ b/eho_bot/requirements.txt @@ -0,0 +1 @@ +python-telegram-bot \ No newline at end of file