Add logging

This commit is contained in:
Xiretza 2022-03-29 19:28:20 +02:00
parent b4e76b75e4
commit 834ea75fd8
2 changed files with 8 additions and 1 deletions

View file

@ -1,5 +1,6 @@
import asyncio
import datetime
import logging
from nio.rooms import MatrixRoom
from nio.events.room_events import RoomMessage
import simplematrixbotlib as botlib
@ -35,6 +36,7 @@ class ItSyndikatBot:
async def run(self):
async def poll_for_changes():
while True:
logging.debug("Polling open state")
try:
status = await self.its_api.status()
new_state = status["state"]["open"]
@ -45,7 +47,7 @@ class ItSyndikatBot:
await self.announce_open_change(new_state)
self.current_open_state = new_state
except Exception as e:
pass
logging.error(f"Polling for open state failed: {e}")
await asyncio.sleep(60)
@ -69,6 +71,8 @@ class ItSyndikatBot:
)
async def announce_open_change(self, now_open: bool):
logging.info("Open state changed: now " + ("open" if now_open else "closed"))
room_ids = self.config.isitopen_announce_rooms
if now_open:
message = "opening IT-Syndikat - Ohai!"

View file

@ -1,9 +1,12 @@
import asyncio
import argparse
import logging
from . import ItSyndikatBot
from .config import Config
logging.basicConfig(level=logging.DEBUG)
parser = argparse.ArgumentParser(description="IT-Syndikat matrix bot")
parser.add_argument(
"-c",