all rooms will get the same image every time now

This commit is contained in:
davidovski 2022-01-09 19:43:26 +00:00
parent 6f2cb5d19c
commit 5a37583596

View file

@ -27,14 +27,14 @@ def get_garfeed():
return url return url
def sendmsg(bot): def sendmsgs(bot):
for room in bot.rooms: get_garfeed()
print(type(room)) url = None
get_garfeed() with open("save.png", "rb") as file:
url = bot.client.upload(file, "image/png")
with open("save.png", "rb") as file: if url is not None:
url = bot.client.upload(file, "image/png") for room in bot.rooms:
room.send_image(url, "garfeeld.png") room.send_image(url, "garfeeld.png")
def main(): def main():
bot = MatrixBotAPI(USERNAME, PASSWORD, SERVER) bot = MatrixBotAPI(USERNAME, PASSWORD, SERVER)
@ -42,8 +42,10 @@ def main():
bot.client.api.upload_keys() bot.client.api.upload_keys()
print(f"up and running as {USERNAME}") print(f"up and running as {USERNAME}")
while True: while True:
sendmsg(bot) sendmsgs(bot)
timenext = random.randint(60, 60*60) timenext = random.randint(60, 60*60)
print(f"next in {timenext} seconds") print(f"next in {timenext} seconds")
time.sleep(timenext) time.sleep(timenext)