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

Spotify config key fixed

parent bfcf293f
Branches
No related tags found
No related merge requests found
......@@ -66,7 +66,7 @@ def load_config(filename):
try:
CONFIG = {}
with open(filename, 'r') as file:
with open(filename, "r") as file:
CONFIG = json.load(file)
except FileNotFoundError:
......@@ -325,7 +325,9 @@ def roll(msgDict):
def request(msgDict):
answer = ""
request_group = next((group for group in GROUPS if group["NAME"] == "Requests"), None)
request_group = next(
(group for group in GROUPS if group["NAME"] == "Requests"), None
)
if not msgDict["content"]:
answer = "Was soll denn hinzugefügt werden?"
......@@ -336,8 +338,7 @@ def request(msgDict):
send(answer, msgDict["receiver"])
send(msgDict["content"], request_group["ID"])
else:
send('Der Befehl Requests funktioniert gerade nicht :(', msgDict["receiver"])
send("Der Befehl Requests funktioniert gerade nicht :(", msgDict["receiver"])
def get_random_challenge(msgDict):
......@@ -429,9 +430,9 @@ def add_song_to_playlist(msgDict):
spotify_config = CONFIG.get("Spotify", {})
if (
ModuleSpotify is None
or spotify_config.get('spotify_client_id', None) is None
or spotify_config.get('spotify_client_secret', None) is None
or spotify_config.get('redirect_uri', None) is None
or spotify_config.get("spotify_client_id", None) is None
or spotify_config.get("spotify_client_secret", None) is None
or spotify_config.get("redirect_uri", None) is None
): # TODO bereits in der INit berücksichtigen, wenn die Secrets nicht am start sind
send("There is no Spotify!", msgDict["receiver"])
return
......@@ -466,8 +467,14 @@ def mqtt_client():
client2 = mqtt.Client()
client2.on_message = on_mqtt_message
client2.username_pw_set(mqtt_local.get("MQTT_USER", ""), mqtt_local.get("MQTT_PWD", ''))
client2.connect(mqtt_local.get("MQTT_IP", ''), mqtt_local.get("MQTT_PORT", None), mqtt_local.get("MQTT_TIMEOUT", None))
client2.username_pw_set(
mqtt_local.get("MQTT_USER", ""), mqtt_local.get("MQTT_PWD", "")
)
client2.connect(
mqtt_local.get("MQTT_IP", ""),
mqtt_local.get("MQTT_PORT", None),
mqtt_local.get("MQTT_TIMEOUT", None),
)
# TODO Topics und receiver in config auslagern, um dynamischer zu subscriben
client2.subscribe("Sensoren/Arbeitszimmer/temperature")
client2.loop_forever()
......@@ -502,11 +509,13 @@ def remind_pflanzen():
send(f"Bitte gebt den armen Pflanzen etwas Lebenselixier!", tierwg["ID"])
def gg_remind_schichten():
gg_group = next((group for group in GROUPS if group["NAME"] == "GGOffiziell"), None)
if gg_group is not None:
send(f'Bitte tragt euch in die Planung ein:\n {gg_group["LINKS"]["Planung"]}', gg_group["ID"])
send(
f'Bitte tragt euch in die Planung ein:\n {gg_group["LINKS"]["Planung"]}',
gg_group["ID"],
)
def gg_remind_stundenzettel():
......@@ -573,10 +582,16 @@ if __name__ == "__main__":
challenges = ModuleChallenge("/home/pi/signalbot/challenge.json", log)
birthday_reminder = ModuleBirthdayReminder(GROUPS, send, log)
tex = ModuleTex(log)
commands = ModuleCommands("/home/pi/signalbot/commands.json", CONFIG.get("FUN_DICT", {}), log)
commands = ModuleCommands(
"/home/pi/signalbot/commands.json", CONFIG.get("FUN_DICT", {}), log
)
event_reminder = ModuleEventReminder(GROUPS, send, log)
spotify = ModuleSpotify(
send, spotify_config.get('spotify_client_id', ''), spotify_config.get('spotify_client_secret', ''), spotify_config.get('redirect_uri', ''), log
send,
spotify_config.get("client_id", ""),
spotify_config.get("client_secret", ""),
spotify_config.get("redirect_uri", ""),
log,
)
today = ModuleToday(log)
loop = GLib.MainLoop()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment