63 lines
1.6 KiB
Python
63 lines
1.6 KiB
Python
# [ IMPORTS ] #
|
|
from telegram import Update
|
|
from telegram.ext import ApplicationBuilder, CommandHandler, ContextTypes
|
|
import configparser
|
|
import json
|
|
import os
|
|
|
|
# other files in here
|
|
from errors import *
|
|
from commands_admin import *
|
|
from commands_user import *
|
|
from handler_participant_lists import *
|
|
from log import *
|
|
|
|
#############################################
|
|
# [ CONFIG FILES ] #
|
|
|
|
# Konfiguration
|
|
config = configparser.ConfigParser()
|
|
config.read('telegram_bot_token.cfg')
|
|
config.read('telegram_bot_config.cfg')
|
|
print("Configs loaded.")
|
|
|
|
#############################################
|
|
# [ MAIN LOOP ] #
|
|
|
|
def main():
|
|
app = ApplicationBuilder().token(config['telegram']['bot_token']).build()
|
|
|
|
# Admin commands
|
|
app.add_handler(CommandHandler("liste", liste))
|
|
app.add_handler(CommandHandler("reset", reset))
|
|
|
|
# User commands
|
|
app.add_handler(CommandHandler("start", hilfe))
|
|
app.add_handler(CommandHandler("hilfe", hilfe))
|
|
app.add_handler(CommandHandler("anmeldung", anmeldung))
|
|
app.add_handler(CommandHandler("abmeldung", abmeldung))
|
|
app.add_handler(CommandHandler("status", status))
|
|
app.add_handler(CommandHandler("error", error))
|
|
|
|
print("Bot läuft...")
|
|
app.run_polling()
|
|
|
|
if __name__ == "__main__":
|
|
main()
|
|
|
|
|
|
|
|
|
|
######### NEEDS TO BE MOVED #####
|
|
# Lade die Liste, falls vorhanden
|
|
if os.path.exists(list_file):
|
|
with open(config['list']['default'], "r") as f:
|
|
event_list = json.load(f)
|
|
else:
|
|
event_list = []
|
|
|
|
# Hilfsfunktion zum Speichern
|
|
def save_list():
|
|
with open(config['list']['default'], "w") as f:
|
|
json.dump(event_list, f)
|