Skip to content
Snippets Groups Projects
Commit 99f1bc1d authored by Frederic Aust's avatar Frederic Aust
Browse files

Merge branch 'main' of https://gitlab.cvh-server.de/faust/signalbot into main

parents d69586be bdef8a02
Branches
No related tags found
No related merge requests found
......@@ -139,8 +139,6 @@ def handle_action(timestamp, source, groupID, message, attachments):
groupInfo = group
break
try:
message = message[1:].strip()
msg_splitted = message.split(" ")
......@@ -161,7 +159,8 @@ def handle_action(timestamp, source, groupID, message, attachments):
links(receiver, groupInfo)
elif action in FUN_DICT:
send(FUN_DICT[action], receiver)
elif (action in ["savequote", "addquote", "createquote"]) and (groupInfo is not None and action in groupInfo["COMMANDS"]):
elif (action in ["savequote", "addquote", "createquote"]) and (
groupInfo is not None and action in groupInfo["COMMANDS"]):
save_quote(receiver, " ".join(str(x) for x in msg_splitted[1:]), groupInfo)
elif action == "randomquote" and (groupInfo is not None and action in groupInfo["COMMANDS"]):
random_quote(receiver, groupInfo)
......@@ -179,13 +178,15 @@ def handle_action(timestamp, source, groupID, message, attachments):
request(receiver, " ".join(str(x) for x in msg_splitted[1:]))
elif action == "challenge" and (groupInfo is None or action in groupInfo["COMMANDS"]):
get_random_challenge(receiver)
elif action in ["savebirthday", "addbirthday", "createbirthday"] and (groupInfo is not None and action in groupInfo["COMMANDS"]):
elif action in ["savebirthday", "addbirthday", "createbirthday"] and (
groupInfo is not None and action in groupInfo["COMMANDS"]):
save_birthday(receiver, " ".join(str(x) for x in msg_splitted[1:]), groupInfo)
elif action == "allbirthdays" and (groupInfo is not None and action in groupInfo["COMMANDS"]):
get_all_birthdays(receiver, groupInfo)
elif action == "nextbirthday" and (groupInfo is not None and action in groupInfo["COMMANDS"]):
get_next_birthday(receiver, groupInfo)
elif action in ["saveevent", "addevent", "createevent"] and (groupInfo is not None and action in groupInfo["COMMANDS"]):
elif action in ["saveevent", "addevent", "createevent"] and (
groupInfo is not None and action in groupInfo["COMMANDS"]):
save_event(receiver, " ".join(str(x) for x in msg_splitted[1:]), groupInfo)
elif action == "allevents" and (groupInfo is not None and action in groupInfo["COMMANDS"]):
get_all_events(receiver, groupInfo)
......@@ -198,7 +199,8 @@ def handle_action(timestamp, source, groupID, message, attachments):
elif action == "kingscup" and (groupInfo is None or action in groupInfo["COMMANDS"]):
get_kings_cup(receiver)
else:
unknown_command(receiver, message) # wenn nicht berechtigt, dann "ich seh nix, ich weiss nix, ich hör nix" => unbekannter befehl
unknown_command(receiver,
message) # wenn nicht berechtigt, dann "ich seh nix, ich weiss nix, ich hör nix" => unbekannter befehl
except Exception as ex:
log.critical(f'Unknown error:"{ex}", timestamp="{timestamp}", source="{source}", groupID="{groupID}", '
f'message="{message}", attachments="{attachments}"')
......@@ -225,7 +227,8 @@ def send_a(message, receiver, attachment):
elif type(receiver) is list:
signal.sendGroupMessage(message, [attachment], receiver)
except Exception as ex:
log.error(f'Send Message with attachment Exception:"{ex}"", message="{message}", receiver="{receiver}", attachments="{attachment}"')
log.error(
f'Send Message with attachment Exception:"{ex}"", message="{message}", receiver="{receiver}", attachments="{attachment}"')
def help_func(receiver, message, groupInfo):
......@@ -248,6 +251,7 @@ def remus_feinste(receiver):
"Originalrezept von Onkel Remus\n"
send(message, receiver)
def true_american(receiver):
message = "True American Regeln: So funktioniert das Spiel aus New Girl\n\n" \
"- Sie nun folgende Utensilien: Mindestens zwei weitere Mitspieler, drei Dosen Bier pro Spieler, eine Flasche Schnaps, einen Mülleimer, sowie einen Raum mit Möbeln und einem großen Tisch, den Sie am nächsten Tag mit Sicherheit putzen müssen. \n\n" \
......@@ -294,7 +298,6 @@ def links(receiver, groupInfo):
if groupInfo is not None and "LINKS" in groupInfo:
links = groupInfo["LINKS"]
if len(links) == 0:
message = "Keine Links hinterlegt!"
else:
......@@ -438,6 +441,7 @@ def unknown_command(receiver, message):
def get_tex_formula(receiver, message):
send_a(message, receiver, tex.create_formula(message))
def get_deepl_translation(receiver, message):
if translator is None:
send("There is no translator available!", receiver)
......@@ -461,6 +465,7 @@ def get_deepl_translation(receiver, message):
send(answer, receiver)
def get_kings_cup(receiver):
send_a("Don't drink and derive!",receiver, "/home/pi/signalbot/kings_cup_regeln.png")
......@@ -502,6 +507,7 @@ def gg_remind_schichten():
send(f'Bitte tragt euch in die Planung ein:\n {group["LINKS"]["Planung"]}', group["ID"])
break
def gg_remind_stundenzettel():
today = date.today().day
gg_group = None
......@@ -515,6 +521,7 @@ def gg_remind_stundenzettel():
elif today == 30:
send("too late suckaaa", gg_group["ID"])
def start_schedule():
while True:
schedule.run_pending()
......@@ -553,5 +560,4 @@ if __name__ == "__main__":
schedule_thread.start()
print("schedule_thread started")
loop.run()
import requests # Apache 2.0
import numpy as np
callbacktable = {"myFunc": "hello_world"}
def hello_world():
print('Hello World!')
if __name__ == '__main__':
globals()[callbacktable["myFunc"]]()
response = requests.get(f"https://history.muffinlabs.com/date", headers={"Accept": "application/json"})
result = response.json()
print('Done')
facts = np.random.choice(result['data']['Events'], 5)
print('5 Random History Facts about today:')
for fact in facts:
print(f'In {fact["year"]}: {fact["text"]}')
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment