- Timestamp:
- Oct 8, 2024, 1:48:33 AM (5 weeks ago)
- Branches:
- master
- Children:
- 71efb80
- Parents:
- 50e04dd
- git-author:
- Mikhail Kirillov <w96k@…> (10/08/24 01:37:34)
- git-committer:
- Mikhail Kirillov <w96k@…> (10/08/24 01:48:33)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
app.py
r50e04dd r5179f7b 10 10 # <http://creativecommons.org/publicdomain/zero/1.0/>. 11 11 12 from telegram import Update 13 from telegram.ext import ApplicationBuilder, CommandHandler, ContextTypes 12 from telegram import Update, error 13 from telegram.ext import ApplicationBuilder, CommandHandler, ContextTypes, \ 14 MessageHandler, filters 14 15 from dotenv import load_dotenv 16 from rich import inspect 15 17 import os 16 18 import logging … … 23 25 ) 24 26 27 async def about(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None: 28 await update.message.reply_text(''' 29 Version 0.0 30 31 python-cinema-club-bot is a bot for Telegram specialized for managing cinema club activities. This software is released as Public Domain using CC0 license. 25 32 26 async def hello(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None: 27 await update.message.reply_text(f'Hello {update.effective_user.first_name}') 33 Project information: http://57.129.46.169/trac/wiki/python-cinema-club-bot 34 Source code: http://57.129.46.169/cgit/python-cinema-club-bot/ 35 36 Contributed in 2024 by Mikhail Kirillov (~w96k) <w96k@runbox.com> 37 38 To the extent possible under law, the author(s) have dedicated all copyright and related and neighboring rights to this software to the public domain worldwide. This software is distributed without any warranty. 39 40 You should have received a copy of the CC0 Public Domain Dedication along with this software. If not, see: 41 <http://creativecommons.org/publicdomain/zero/1.0/> 42 43 ''') 44 45 async def add_choose_cycle( 46 update: Update, 47 context: ContextTypes.DEFAULT_TYPE 48 ) -> None: 49 command = update.message.text 50 51 user = command.replace("/add", "") 52 53 inspect(user) 54 55 try: 56 if user == "": 57 raise error.TelegramError("User is not provided. Use /add @username") 58 except error.TelegramError as err: 59 await update.message.reply_text(err.message) 60 return 61 62 await update.message.reply_text(update.message.text) 63 64 65 async def unknown(update: Update, context: ContextTypes.DEFAULT_TYPE): 66 await context.bot.send_message(chat_id=update.effective_chat.id, text="Invalid command. Available commands: /add") 28 67 29 68 app = ApplicationBuilder().token( … … 31 70 ).build() 32 71 33 app.add_handler(CommandHandler("hello", hello)) 72 app.add_handler(CommandHandler("about", about)) 73 app.add_handler(CommandHandler("add", add_choose_cycle)) 74 75 app.add_handler(MessageHandler(filters.COMMAND, unknown)) 34 76 35 77 app.run_polling()
Note:
See TracChangeset
for help on using the changeset viewer.