List all events with teamup
This commit is contained in:
parent
8e7e47a4b5
commit
0f702ff8ec
|
@ -48,6 +48,7 @@ Howto:
|
||||||
Commands:
|
Commands:
|
||||||
|
|
||||||
* !teamup apikey [apikey] - set api key
|
* !teamup apikey [apikey] - set api key
|
||||||
|
* !teamup - list upcoming events in calendar
|
||||||
* !teamup add [calendar id] - add calendar to this room
|
* !teamup add [calendar id] - add calendar to this room
|
||||||
* !teamup del [calendar id] - delete calendar from this room
|
* !teamup del [calendar id] - delete calendar from this room
|
||||||
* !teamup list - list calendars in this room
|
* !teamup list - list calendars in this room
|
||||||
|
|
|
@ -18,7 +18,18 @@ class MatrixModule:
|
||||||
|
|
||||||
async def matrix_message(self, bot, room, event):
|
async def matrix_message(self, bot, room, event):
|
||||||
args = event.body.split()
|
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 = '<b>' + 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 + '</b> ' + event.title + " " + (event.notes or '')
|
||||||
|
await bot.send_html(room, s, s)
|
||||||
|
elif len(args) == 2:
|
||||||
if args[1] == 'list':
|
if args[1] == 'list':
|
||||||
await bot.send_text(room, f'Calendars in this room: {self.calendar_rooms.get(room.room_id) or []}')
|
await bot.send_text(room, f'Calendars in this room: {self.calendar_rooms.get(room.room_id) or []}')
|
||||||
elif args[1] == 'poll':
|
elif args[1] == 'poll':
|
||||||
|
@ -72,6 +83,7 @@ class MatrixModule:
|
||||||
for event in events:
|
for event in events:
|
||||||
await bot.send_text(bot.get_room_by_id(roomid), 'Calendar: ' + self.eventToString(event))
|
await bot.send_text(bot.get_room_by_id(roomid), 'Calendar: ' + self.eventToString(event))
|
||||||
|
|
||||||
|
|
||||||
def poll_server(self, calendar):
|
def poll_server(self, calendar):
|
||||||
events, timestamp = calendar.get_changed_events(calendar.timestamp)
|
events, timestamp = calendar.get_changed_events(calendar.timestamp)
|
||||||
return events, timestamp
|
return events, timestamp
|
||||||
|
|
Loading…
Reference in New Issue