Initial commit
Signed-off-by: Sphericalkat <me@kat.bio>
This commit is contained in:
commit
894d840e94
2
.env.sample
Normal file
2
.env.sample
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
BOT_TOKEN=your_bot_token_here
|
||||||
|
LOG_LEVEL=INFO # or CRITICAL, ERROR, WARNING, DEBUG, NOTSET
|
3
.gitignore
vendored
Normal file
3
.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
.env
|
||||||
|
.venv
|
||||||
|
*.pyc
|
28
main.py
Normal file
28
main.py
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
import logging
|
||||||
|
|
||||||
|
from telegram import Update
|
||||||
|
from telegram.ext import ContextTypes, ApplicationBuilder, CommandHandler
|
||||||
|
|
||||||
|
from settings import Settings
|
||||||
|
|
||||||
|
settings = Settings()
|
||||||
|
log_level = logging.getLevelNamesMapping().get(settings.log_level, logging.INFO)
|
||||||
|
|
||||||
|
|
||||||
|
logging.basicConfig(
|
||||||
|
format="%(asctime)s - %(name)s - %(levelname)s - %(message)s", level=log_level
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
async def start(update: Update, context: ContextTypes.DEFAULT_TYPE):
|
||||||
|
await context.bot.send_message(
|
||||||
|
chat_id=update.effective_chat.id, text="Hello, deez nuts on yo chin!"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
app = ApplicationBuilder().token(settings.bot_token).build()
|
||||||
|
start_handler = CommandHandler("start", start)
|
||||||
|
app.add_handler(start_handler)
|
||||||
|
|
||||||
|
app.run_polling()
|
8
settings.py
Normal file
8
settings.py
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
from pydantic_settings import BaseSettings, SettingsConfigDict
|
||||||
|
|
||||||
|
|
||||||
|
class Settings(BaseSettings):
|
||||||
|
model_config = SettingsConfigDict(env_file=".env", env_file_encoding="utf-8")
|
||||||
|
|
||||||
|
bot_token: str = "YOUR_BOT_TOKEN"
|
||||||
|
log_level: str = "INFO"
|
Loading…
Reference in New Issue
Block a user