From 8a95bca91f68a3c5d9e5fe347b4b911a28836c78 Mon Sep 17 00:00:00 2001 From: Kosma Moczek Date: Fri, 25 Apr 2025 13:57:36 +0200 Subject: [PATCH] praniebot.py: load token from file --- praniebot.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) 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))