Merge pull request #11 from tswfi/GoogleCal/NothingToday

Small googlecal changes
This commit is contained in:
Ville Ranki 2020-01-02 12:23:50 +02:00 committed by GitHub
commit 1e96623408
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 13 additions and 7 deletions

View File

@ -77,6 +77,8 @@ class MatrixModule:
events = events + self.list_today(calid) events = events + self.list_today(calid)
if args[1] == 'list': if args[1] == 'list':
await bot.send_text(room, 'Calendars in this room: ' + str(self.calendar_rooms.get(room.room_id))) await bot.send_text(room, 'Calendars in this room: ' + str(self.calendar_rooms.get(room.room_id)))
return
elif len(args) == 3: elif len(args) == 3:
if args[1] == 'add': if args[1] == 'add':
bot.must_be_admin(room, event) bot.must_be_admin(room, event)
@ -98,6 +100,8 @@ class MatrixModule:
bot.save_settings() bot.save_settings()
await bot.send_text(room, 'Added new google calendar to this room') await bot.send_text(room, 'Added new google calendar to this room')
return
if args[1] == 'del': if args[1] == 'del':
bot.must_be_admin(room, event) bot.must_be_admin(room, event)
@ -112,17 +116,19 @@ class MatrixModule:
bot.save_settings() bot.save_settings()
await bot.send_text(room, 'Removed google calendar from this room') await bot.send_text(room, 'Removed google calendar from this room')
return
else: else:
for calid in calendars: for calid in calendars:
print('Listing events in cal', calid) print('Listing events in cal', calid)
events = events + self.list_upcoming(calid) events = events + self.list_upcoming(calid)
if len(events) == 0: if len(events) > 0:
await bot.send_text(room, 'No events found.')
if len(events):
print(f'Found {len(events)} events') print(f'Found {len(events)} events')
await self.send_events(bot, events, room) await self.send_events(bot, events, room)
else:
print(f'No events found')
await bot.send_text(room, 'No events found, try again later :)')
async def send_events(self, bot, events, room): async def send_events(self, bot, events, room):
for event in events: for event in events: