Skip to content
Snippets Groups Projects
Commit 588b1def authored by psy's avatar psy
Browse files

accept dm invite, only respond to !help in dms

parent 05ae0d18
No related branches found
No related tags found
No related merge requests found
...@@ -63,13 +63,19 @@ class RssBot: ...@@ -63,13 +63,19 @@ class RssBot:
if config: if config:
self._handle_room_config(room, config) self._handle_room_config(room, config)
def _handle_invite(self, roomId, state): def _handle_invite(self, room_id, state):
# check if local room # check if local room or DM
if not roomId.endswith(self.client.user_id.split(':')[1]): is_dm = False
print('Ignoring invitation to', roomId) 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 return
room = self.client.join_room(roomId) room = self.client.join_room(room_id)
self._setup_room(room) self._setup_room(room)
def _handle_leave(self, room_id, room): def _handle_leave(self, room_id, room):
...@@ -78,8 +84,9 @@ class RssBot: ...@@ -78,8 +84,9 @@ class RssBot:
self._update_feeds_config() self._update_feeds_config()
def _handle_message(self, room, event): def _handle_message(self, room, event):
# check for room name to only reply in DMs (room.name == None => DM)
msg = str(event['content']['body']) 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> 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 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> <code>/devtools</code> to set the rss feeds:<br>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment