From 5a3758359675d5880607086db3258432a246312f Mon Sep 17 00:00:00 2001 From: davidovski Date: Sun, 9 Jan 2022 19:43:26 +0000 Subject: [PATCH] all rooms will get the same image every time now --- garfeef.py | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/garfeef.py b/garfeef.py index 1dfdb2f..1f56c8d 100755 --- a/garfeef.py +++ b/garfeef.py @@ -27,14 +27,14 @@ def get_garfeed(): return url -def sendmsg(bot): - for room in bot.rooms: - print(type(room)) - get_garfeed() - - with open("save.png", "rb") as file: - url = bot.client.upload(file, "image/png") - room.send_image(url, "garfeeld.png") +def sendmsgs(bot): + get_garfeed() + url = None + with open("save.png", "rb") as file: + url = bot.client.upload(file, "image/png") + if url is not None: + for room in bot.rooms: + room.send_image(url, "garfeeld.png") def main(): bot = MatrixBotAPI(USERNAME, PASSWORD, SERVER) @@ -42,8 +42,10 @@ def main(): bot.client.api.upload_keys() print(f"up and running as {USERNAME}") + while True: - sendmsg(bot) + sendmsgs(bot) + timenext = random.randint(60, 60*60) print(f"next in {timenext} seconds") time.sleep(timenext)