From 5411de90fc76182ba1f462b6a54085694e756947 Mon Sep 17 00:00:00 2001 From: Tulir Asokan Date: Mon, 28 Oct 2019 01:09:37 +0200 Subject: [PATCH] Update some things --- .dockerignore | 4 ++++ mautrix_telegram/portal/base.py | 2 +- mautrix_telegram/portal/metadata.py | 16 ++++++++++++---- mautrix_telegram/puppet.py | 2 +- setup.py | 2 +- 5 files changed, 19 insertions(+), 7 deletions(-) diff --git a/.dockerignore b/.dockerignore index 1f625fe0..d7755966 100644 --- a/.dockerignore +++ b/.dockerignore @@ -4,3 +4,7 @@ *.md logs .venv +start +config.yaml +registration.yaml +*.db diff --git a/mautrix_telegram/portal/base.py b/mautrix_telegram/portal/base.py index 522b8e79..a0181d0f 100644 --- a/mautrix_telegram/portal/base.py +++ b/mautrix_telegram/portal/base.py @@ -305,7 +305,7 @@ class BasePortal(ABC): def save(self) -> None: self.db_instance.edit(mxid=self.mxid, username=self.username, title=self.title, - about=self.about, photo_id=self.photo_id, + about=self.about, photo_id=self.photo_id, megagroup=self.megagroup, config=json.dumps(self.local_config)) def delete(self) -> None: diff --git a/mautrix_telegram/portal/metadata.py b/mautrix_telegram/portal/metadata.py index b9a833ca..fcf6b3cb 100644 --- a/mautrix_telegram/portal/metadata.py +++ b/mautrix_telegram/portal/metadata.py @@ -479,16 +479,22 @@ class PortalMetadata(BasePortal, ABC): if puppet_id and puppet_id not in allowed_tgids: if self.bot and puppet_id == self.bot.tgid: self.bot.remove_chat(self.tgid) - await self.main_intent.kick_user(self.mxid, user_mxid, - "User had left this Telegram chat.") + try: + await self.main_intent.kick_user(self.mxid, user_mxid, + "User had left this Telegram chat.") + except MForbidden: + pass continue mx_user = u.User.get_by_mxid(user_mxid, create=False) if mx_user and mx_user.is_bot and mx_user.tgid not in allowed_tgids: mx_user.unregister_portal(self) if mx_user and not self.has_bot and mx_user.tgid not in allowed_tgids: - await self.main_intent.kick_user(self.mxid, mx_user.mxid, - "You had left this Telegram chat.") + try: + await self.main_intent.kick_user(self.mxid, mx_user.mxid, + "You had left this Telegram chat.") + except MForbidden: + pass continue async def _add_telegram_user(self, user_id: TelegramID, source: Optional['AbstractUser'] = None @@ -543,6 +549,8 @@ class PortalMetadata(BasePortal, ABC): changed = False if self.peer_type == "channel": + changed = self.megagroup != entity.megagroup or changed + self.megagroup = entity.megagroup changed = await self._update_username(entity.username) or changed if hasattr(entity, "about"): diff --git a/mautrix_telegram/puppet.py b/mautrix_telegram/puppet.py index 6723c321..b8f7c24f 100644 --- a/mautrix_telegram/puppet.py +++ b/mautrix_telegram/puppet.py @@ -194,7 +194,7 @@ class Puppet(CustomPuppetMixin): return "" whitespace = ("\t\n\r\v\f \u00a0\u034f\u180e\u2063\u202f\u205f\u2800\u3000\u3164\ufeff" "\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u200b" - "\u200c\u200d\u200e\u200f") + "\u200c\u200d\u200e\u200f\ufe0f") name = "".join(c for c in name.strip(whitespace) if unicodedata.category(c) != 'Cf') return name diff --git a/setup.py b/setup.py index 1e21ba78..fae715fa 100644 --- a/setup.py +++ b/setup.py @@ -32,7 +32,7 @@ setuptools.setup( install_requires=[ "aiohttp>=3.0.1,<4", - "mautrix>=0.4.0.dev75,<0.5", + "mautrix>=0.4.0.dev76,<0.5", "SQLAlchemy>=1.2.3,<2", "alembic>=1.0.0,<2", "commonmark>=0.8.1,<0.10",