diff --git a/praniebot.py b/praniebot.py index bb59d3e..5d50a53 100644 --- a/praniebot.py +++ b/praniebot.py @@ -1,11 +1,11 @@ import re +import sys from datetime import datetime, timedelta import pytz from apscheduler.schedulers.asyncio import AsyncIOScheduler from telegram import Update, User from telegram.ext import Application, CommandHandler, ContextTypes -TOKEN = "7769574344:AAH_90MxtZt-BpJraJbV5-qkD-z2x-LY3F4" # wiem, że zahardkodowane, ale w dupie mam elo reminders = {} # TODO: fix max delay 24h @@ -106,8 +106,16 @@ async def start(update: Update): def main(): + args = sys.argv[1:] + if len(args) != 1: + print(f"Usage: {sys.argv[0]} ", file=sys.stderr) + sys.exit(1) + + token_file, = args + token = open(token_file).read().strip() + context_types = ContextTypes(context=CustomContext) - application = Application.builder().token(TOKEN).context_types(context_types).build() + application = Application.builder().token(token).context_types(context_types).build() application.add_handler(CommandHandler("start", start)) application.add_handler(CommandHandler("pranie", pranie))