Skip to content

Commit

Permalink
Update some things
Browse files Browse the repository at this point in the history
  • Loading branch information
tulir committed Oct 27, 2019
1 parent f9a692b commit 5411de9
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 7 deletions.
4 changes: 4 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,7 @@
*.md
logs
.venv
start
config.yaml
registration.yaml
*.db
2 changes: 1 addition & 1 deletion mautrix_telegram/portal/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ def new_db_instance(self) -> DBPortal:

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:
Expand Down
16 changes: 12 additions & 4 deletions mautrix_telegram/portal/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -479,16 +479,22 @@ async def _sync_telegram_users(self, source: 'AbstractUser', users: List[User])
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
Expand Down Expand Up @@ -543,6 +549,8 @@ async def update_info(self, user: 'AbstractUser', entity: TypeChat = None) -> No
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"):
Expand Down
2 changes: 1 addition & 1 deletion mautrix_telegram/puppet.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ def _filter_name(name: str) -> str:
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

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

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",
Expand Down

0 comments on commit 5411de9

Please sign in to comment.