57 lines
2.0 KiB
Python
57 lines
2.0 KiB
Python
from telegram import Update
|
|
from telegram.ext import ApplicationBuilder, CommandHandler, ContextTypes
|
|
import configparser
|
|
import json
|
|
import os
|
|
|
|
# /anmeldung Handler
|
|
async def anmeldung(update: Update, context: ContextTypes.DEFAULT_TYPE):
|
|
if not context.args:
|
|
await update.message.reply_text("Bitte Namen angeben: /anmeldung Name")
|
|
return
|
|
name = " ".join(context.args)
|
|
if name in event_list:
|
|
await update.message.reply_text(f"{name}, du bist doch schon angemeldet.")
|
|
else:
|
|
event_list.append(name)
|
|
save_list()
|
|
await update.message.reply_text(f"{name} will unbedingt auch dabei sein!")
|
|
|
|
# /abmeldung Handler
|
|
async def abmeldung(update: Update, context: ContextTypes.DEFAULT_TYPE):
|
|
if not context.args:
|
|
await update.message.reply_text("Bitte Namen angeben: /abmeldung Name")
|
|
return
|
|
name = " ".join(context.args)
|
|
if name in event_list:
|
|
event_list.remove(name)
|
|
save_list()
|
|
await update.message.reply_text(f"{name} kann nich mehr oder hat kein Bock auf uns.")
|
|
else:
|
|
await update.message.reply_text(f"{name}, du warst eh nich auf der Liste.")
|
|
|
|
# /hilfe Handler
|
|
async def hilfe(update: Update, context: ContextTypes.DEFAULT_TYPE):
|
|
text = (
|
|
"Dude, ich erklär dir mal wie das hier läuft:\n\n"
|
|
"In der Gruppe:\n"
|
|
"/anmeldung Name - zum Anmelden\n"
|
|
"/abmeldung Name - zum Abmelden\n"
|
|
"/status - check wie viele Fussel dabei sind\n\n"
|
|
)
|
|
await update.message.reply_text(text)
|
|
|
|
# /status Handler (für alle)
|
|
async def status(update: Update, context: ContextTypes.DEFAULT_TYPE):
|
|
count = len(event_list)
|
|
if count == 0:
|
|
text = "Is noch keiner eingecheckt..."
|
|
elif count == 1:
|
|
text = "Es ist aktuell *1 Fussel* dabei!"
|
|
else:
|
|
text = f"Es sind aktuell *{count} Fussel* dabei!"
|
|
await update.message.reply_text(text, parse_mode="Markdown")
|
|
|
|
async def start(update: Update, context: ContextTypes.DEFAULT_TYPE):
|
|
await hilfe(update, context)
|