From 0f702ff8ec93d3a600f5d2f0e47fba7e915cdddf Mon Sep 17 00:00:00 2001 From: Ville Ranki Date: Thu, 12 Dec 2019 22:10:25 +0200 Subject: [PATCH] List all events with teamup --- README.md | 1 + modules/teamup.py | 14 +++++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 430db06..758f32e 100644 --- a/README.md +++ b/README.md @@ -48,6 +48,7 @@ Howto: Commands: * !teamup apikey [apikey] - set api key +* !teamup - list upcoming events in calendar * !teamup add [calendar id] - add calendar to this room * !teamup del [calendar id] - delete calendar from this room * !teamup list - list calendars in this room diff --git a/modules/teamup.py b/modules/teamup.py index 0ac52c1..db905fa 100644 --- a/modules/teamup.py +++ b/modules/teamup.py @@ -18,7 +18,18 @@ class MatrixModule: async def matrix_message(self, bot, room, event): args = event.body.split() - if len(args) == 2: + if len(args) == 1: + if self.calendar_rooms.get(room.room_id): + for calendarid in self.calendar_rooms.get(room.room_id): + calendar = self.calendars[calendarid] + events = calendar.get_event_collection() + for event in events: + s = '' + str(event.start_dt.day) + '.' + str(event.start_dt.month) + if not event.all_day: + s = s + ' ' + event.start_dt.strftime("%H:%M") + ' (' + str(event.duration) + ' min)' + s = s + ' ' + event.title + " " + (event.notes or '') + await bot.send_html(room, s, s) + elif len(args) == 2: if args[1] == 'list': await bot.send_text(room, f'Calendars in this room: {self.calendar_rooms.get(room.room_id) or []}') elif args[1] == 'poll': @@ -72,6 +83,7 @@ class MatrixModule: for event in events: await bot.send_text(bot.get_room_by_id(roomid), 'Calendar: ' + self.eventToString(event)) + def poll_server(self, calendar): events, timestamp = calendar.get_changed_events(calendar.timestamp) return events, timestamp