Implement Matrix -> Telegram formatted message bridging

This commit is contained in:
Tulir Asokan
2018-01-21 20:48:14 +02:00
parent f1d8312806
commit a8359441b0
6 changed files with 198 additions and 7 deletions
+8 -3
View File
@@ -13,10 +13,8 @@
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from telethon import TelegramClient
from telethon.tl.types import User as UserEntity, Chat as ChatEntity, Channel as ChannelEntity
import re
from .db import Puppet as DBPuppet
from . import portal as p
config = None
@@ -36,6 +34,10 @@ class Puppet:
self.cache[id] = self
@property
def tgid(self):
return self.id
def to_db(self):
return self.db.merge(
DBPuppet(id=self.id, username=self.username, displayname=self.displayname))
@@ -109,3 +111,6 @@ def init(context):
global config
Puppet.az, Puppet.db, log, config = context
Puppet.log = log.getChild("puppet")
localpart = config.get("bridge.alias_template", "telegram_{}").format("(.+)")
hs = config["homeserver"]["domain"]
Puppet.mxid_regex = re.compile(f"@{localpart}:{hs}")