Finalize Matrix support#55
Open
jfrederickson wants to merge 3 commits into
Open
Conversation
Previously you were only able to join a Matrix room using its room ID. This prevented us from doing some automated setup, and was just generally inconvenient as room IDs are cumbersome to work with.
d123431 to
7a76e1d
Compare
jahschwa
requested changes
Apr 2, 2019
| # Sibyl: A modular Python chat bot framework | ||
| # Copyright (c) 2015-2017 Joshua Haas <haas.josh.a@gmail.com> | ||
| # Copyright (c) 2016-2017 Jonathan Frederickson <jonathan@terracrypt.net> | ||
| # Copyright (c) 2016-2018 Jonathan Frederickson <jonathan@terracrypt.net> |
| # @return (User) the "real" User behind the specified nick/room | ||
| def get_real(self,room,nick): | ||
| raise NotImplementedError | ||
| return self.get_user().get_base() |
Owner
There was a problem hiding this comment.
This should be resolving display names to MXIDs.
| self.room_aliases[room_id_or_alias] = room | ||
| return room | ||
| else: | ||
| return MatrixRoom(self,room_id_or_alias,nick,pword) |
Owner
There was a problem hiding this comment.
[OPTIONAL] This can be more compactly written:
def new_room(self,room_id_or_alias,nick=None,pword=None):
if room_id_or_alias in self.room_aliases:
return self.room_aliases[room_id_or_alias]
room = MatrixRoom(self,room_id_or_alias,nick,pword)
if room_id_or_alias.startswith("#"):
self.room_aliases[room_id_or_alias] = room
return room
| elif self.room_alias: | ||
| room_id = self.protocol.client.api.get_room_id(self.room_alias) | ||
| self.room = mxRoom.Room(self.protocol.client, room_id) | ||
| return self.room |
Owner
There was a problem hiding this comment.
[OPTIONAL] We can do this more compactly:
def get_mx_room(self):
# We have a room alias but haven't resolved it yet
if not self.room:
room_id = self.protocol.client.api.get_room_id(self.room_alias)
self.room = mxRoom.Room(self.protocol.client, room_id)
return self.room
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Previously you were only able to join a Matrix room using its room ID.
This prevented us from doing some automated setup, and was just
generally inconvenient as room IDs are cumbersome to work with.