praniebot.py: load token from file
This commit is contained in:
parent
ac2fc32cf2
commit
8a95bca91f
12
praniebot.py
12
praniebot.py
|
|
@ -1,11 +1,11 @@
|
||||||
import re
|
import re
|
||||||
|
import sys
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
import pytz
|
import pytz
|
||||||
from apscheduler.schedulers.asyncio import AsyncIOScheduler
|
from apscheduler.schedulers.asyncio import AsyncIOScheduler
|
||||||
from telegram import Update, User
|
from telegram import Update, User
|
||||||
from telegram.ext import Application, CommandHandler, ContextTypes
|
from telegram.ext import Application, CommandHandler, ContextTypes
|
||||||
|
|
||||||
TOKEN = "7769574344:AAH_90MxtZt-BpJraJbV5-qkD-z2x-LY3F4" # wiem, że zahardkodowane, ale w dupie mam elo
|
|
||||||
reminders = {}
|
reminders = {}
|
||||||
|
|
||||||
# TODO: fix max delay 24h
|
# TODO: fix max delay 24h
|
||||||
|
|
@ -106,8 +106,16 @@ async def start(update: Update):
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
args = sys.argv[1:]
|
||||||
|
if len(args) != 1:
|
||||||
|
print(f"Usage: {sys.argv[0]} <path to token file>", file=sys.stderr)
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
token_file, = args
|
||||||
|
token = open(token_file).read().strip()
|
||||||
|
|
||||||
context_types = ContextTypes(context=CustomContext)
|
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("start", start))
|
||||||
application.add_handler(CommandHandler("pranie", pranie))
|
application.add_handler(CommandHandler("pranie", pranie))
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue