Fix small mistakes

This commit is contained in:
Tulir Asokan
2019-02-12 20:57:14 +02:00
parent 16d3458e5a
commit 0d0b043bb8
2 changed files with 10 additions and 3 deletions
+6 -1
View File
@@ -74,7 +74,12 @@ async def id(evt: CommandEvent) -> Dict:
portal = po.Portal.get_by_mxid(evt.room_id)
if not portal:
return await evt.reply("This is not a portal room.")
await evt.reply(f"This room is bridged to Telegram chat ID `{portal.tgid}`.")
tgid = portal.tgid
if portal.peer_type == "chat":
tgid = -tgid
elif portal.peer_type == "channel":
tgid = f"-100{tgid}"
await evt.reply(f"This room is bridged to Telegram chat ID `{tgid}`.")
@command_handler(help_section=SECTION_PORTAL_MANAGEMENT,
+4 -2
View File
@@ -1841,9 +1841,11 @@ class Portal:
del self.by_tgid[self.tgid_full]
except KeyError:
pass
existing = self.by_tgid[(new_id, new_id)]
if existing:
try:
existing = self.by_tgid[(new_id, new_id)]
existing.delete()
except KeyError:
pass
self.db_instance.update(tgid=new_id, tg_receiver=new_id)
old_id = self.tgid
self.tgid = new_id