diff --git a/rssbot.py b/rssbot.py index 096859fe46637b71612676f7b9619868eb15a5a7..b322c3b304fe85be2a5e548370a8558015a7cb89 100755 --- a/rssbot.py +++ b/rssbot.py @@ -63,13 +63,19 @@ class RssBot: if config: self._handle_room_config(room, config) - def _handle_invite(self, roomId, state): - # check if local room - if not roomId.endswith(self.client.user_id.split(':')[1]): - print('Ignoring invitation to', roomId) + def _handle_invite(self, room_id, state): + # check if local room or DM + is_dm = False + for event in state['events']: + if event['content'].get('is_direct', False): + is_dm = True + break + + if not (room_id.endswith(self.client.user_id.split(':')[1]) or is_dm): + print('Ignoring invitation to', room_id) return - room = self.client.join_room(roomId) + room = self.client.join_room(room_id) self._setup_room(room) def _handle_leave(self, room_id, room): @@ -78,8 +84,9 @@ class RssBot: self._update_feeds_config() def _handle_message(self, room, event): + # check for room name to only reply in DMs (room.name == None => DM) msg = str(event['content']['body']) - if msg.startswith('!help'): + if msg.startswith('!help') and room.name is None: help_message = """I'm here to keep you updated on rss feeds!<br><br> Invite me to any room on {homeserver} and use the custom state event <code>de.eventscccde.rssbot</code> via <code>/devtools</code> to set the rss feeds:<br>