diff options
| author | ilotterytea <iltsu@alright.party> | 2025-10-10 22:55:02 +0500 |
|---|---|---|
| committer | ilotterytea <iltsu@alright.party> | 2025-10-10 22:55:02 +0500 |
| commit | 32b78779aab853df98dccf65afedaf3e77262a71 (patch) | |
| tree | 38bea7bd031d5c838ca4bb52f8060ef100d8e318 | |
| parent | bd4b7a66d161a8d1a89472f22d4857cd25de50dc (diff) | |
| -rw-r--r-- | main.py | 15 |
1 files changed, 13 insertions, 2 deletions
@@ -1,4 +1,6 @@ +import os.path import traceback +from configparser import ConfigParser from os import mkdir, unlink from os.path import exists @@ -61,8 +63,17 @@ async def download_file(update: Update, _: CallbackContext) -> None: def run(): - print("Starting the bot...") - app = ApplicationBuilder().token("xd").build() + if not os.path.exists("config.ini"): + raise Exception("config.ini not found. Look up in README for more info...") + + cfg = ConfigParser() + cfg.read("config.ini") + + if 'telegram' not in cfg or 'token' not in cfg['telegram']: + raise Exception("No Telegram token found. Set 'token' field in [telegram] section.") + + print("Bot is running...") + app = ApplicationBuilder().token(cfg['telegram']['token']).build() app.add_handler(MessageHandler( filters.PHOTO | filters.VIDEO | filters.VIDEO_NOTE | filters.VOICE | filters.AUDIO | filters.ANIMATION | |
