source: python-cinema-club-bot/app.py@ 50e04dd

Last change on this file since 50e04dd was 50e04dd, checked in by Mikhail Kirillov <w96k@…>, on Oct 7, 2024 at 10:39:28 PM

Add logging

  • Property mode set to 100644
File size: 1.1 KB
Line 
1# This file is part of python-cinema-club-bot
2# contributed in 2024 by Mikhail Kirillov (~w96k) <w96k@runbox.com>
3
4# To the extent possible under law, the author(s) have dedicated all copyright
5# and related and neighboring rights to this software to the public domain
6# worldwide. This software is distributed without any warranty.
7
8# You should have received a copy of the CC0 Public Domain Dedication along
9# with this software. If not, see:
10# <http://creativecommons.org/publicdomain/zero/1.0/>.
11
12from telegram import Update
13from telegram.ext import ApplicationBuilder, CommandHandler, ContextTypes
14from dotenv import load_dotenv
15import os
16import logging
17
18load_dotenv()
19
20logging.basicConfig(
21 level=logging.INFO,
22 format='%(asctime)s - %(name)s - %(levelname)s - %(message)s'
23)
24
25
26async def hello(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
27 await update.message.reply_text(f'Hello {update.effective_user.first_name}')
28
29app = ApplicationBuilder().token(
30 os.environ.get('TELEGRAM_TOKEN')
31).build()
32
33app.add_handler(CommandHandler("hello", hello))
34
35app.run_polling()
Note: See TracBrowser for help on using the repository browser.