Add Matrix->Telegram kicking and fix and improve things. Fixes #36

This commit is contained in:
Tulir Asokan
2018-02-01 23:22:08 +02:00
parent 5311facf97
commit e38cf82c40
8 changed files with 112 additions and 61 deletions
+14 -2
View File
@@ -70,8 +70,8 @@ class Puppet:
"first name": info.first_name,
"last name": info.last_name,
}
preferences = config.get("bridge", {}).get("displayname_preference",
["full name", "username", "phone"])
preferences = config.get("bridge.displayname_preference",
["full name", "username", "phone"])
for preference in preferences:
name = data[preference]
if name:
@@ -136,6 +136,18 @@ class Puppet:
return None
@classmethod
def get_by_mxid(cls, mxid, create=True):
tgid = cls.get_id_from_mxid(mxid)
return cls.get(tgid, create) if tgid else None
@classmethod
def get_id_from_mxid(cls, mxid):
match = cls.mxid_regex.match(mxid)
if match:
return int(match.group(1))
return None
@classmethod
def find_by_username(cls, username):
for _, puppet in cls.cache.items():