added requirements

added ENV variables for secrets
This commit is contained in:
menna 2023-05-15 18:44:08 +02:00
parent 8263516a88
commit 8ff8a24a0f
3 changed files with 52 additions and 11 deletions

4
.gitignore vendored
View File

@ -12,3 +12,7 @@ logs/app/*
database/exports/*
*.pyc
dev_utils.py
secrets
.jython_cache/**
# .jython_cache/packages
task-bot-old

View File

@ -1,10 +1,10 @@
#! /bin/env python3
import logging
import sqlite3
import json
from os import environ
from telegram.ext import CommandHandler, MessageHandler, Updater, PicklePersistence, Filters
import telegram.ext
import text_commands
import event_handlers
@ -16,17 +16,41 @@ logging.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s - %(message)s
filename="logs/app/info")
# authentication and proxy
with open("secrets/proxy") as proxyfile:
proxy_url = proxyfile.readline().strip()
with open("secrets/telegram_token_test") as tokenfile:
telegram_bot_token = tokenfile.readline().strip()
# authentication and proxy
proxy_url:str
try:
proxy_url = environ['TASKBOT_PROXY']
except KeyError:
try:
with open("secrets/proxy") as proxyfile:
proxy_url = proxyfile.readline().strip()
except FileNotFoundError:
proxy_url = "" # no proxy configured
try:
telegram_bot_token = environ['TASKBOT_TOKEN']
except KeyError:
try:
with open("secrets/telegram_token_test") as tokenfile:
telegram_bot_token = tokenfile.readline().strip()
except FileNotFoundError:
#TODO log, STDERR
exit(-1)
# persistence
with open("app/config.json") as config:
persistence_path = json.load(config)["persistence_path"]
persistence = PicklePersistence(filename=persistence_path)
persistence_path:str
try:
persistence_path = environ['TASKBOT_PERSISTENCE_FILE']
except KeyError:
try:
with open("app/config.json") as config:
persistence_path = json.load(config)["persistence_path"]
except FileNotFoundError:
persistence_path = "./persistence"
finally:
persistence = PicklePersistence(filename=persistence_path)
#TODO why there is a database AND persistence?
updater_request_kwargs = {'proxy_url': proxy_url} if proxy_url else dict()
updater = Updater(token=telegram_bot_token, request_kwargs=updater_request_kwargs, persistence=persistence)

13
requirements.txt Normal file
View File

@ -0,0 +1,13 @@
-i https://pypi.org/simple
apscheduler==3.6.3
certifi==2020.12.5
cffi==1.14.5
cryptography==3.4.4
pycparser==2.20
pysocks==1.7.1
python-telegram-bot==13.2
pytz==2021.1
six==1.15.0
tornado==6.1
tzlocal==2.1
xlsxwriter==1.3.7