Add support for Telethon's catch_up() (ref #124)

This commit is contained in:
Tulir Asokan
2018-05-13 11:22:20 +03:00
parent fd763b953d
commit 79341b8d28
5 changed files with 13 additions and 1 deletions
+3
View File
@@ -112,6 +112,9 @@ bridge:
#
# Remember that proper sticker support always requires Pillow to convert webp into png.
native_stickers: true
# Whether or not to fetch and handle Telegram updates at startup from the time the bridge was down.
# WARNING: Probably buggy, might get stuck in infinite loop.
catch_up: false
# The prefix for commands. Only required in non-management rooms.
command_prefix: "!tg"
+6
View File
@@ -86,6 +86,12 @@ class Bot(AbstractUser):
except (ChannelPrivateError, ChannelInvalidError):
self.remove_chat(id.channel_id)
if config["bridge.catch_up"]:
try:
await self.client.catch_up()
except Exception:
self.log.exception("Failed to run catch_up() for bot")
def register_portal(self, portal: po.Portal):
self.add_chat(portal.tgid, portal.peer_type)
+1
View File
@@ -179,6 +179,7 @@ class Config(DictWithRecursion):
copy("bridge.plaintext_highlights")
copy("bridge.public_portals")
copy("bridge.native_stickers")
copy("bridge.catch_up")
copy("bridge.command_prefix")
+2
View File
@@ -150,6 +150,8 @@ class User(AbstractUser):
await self.update_info(info)
await self.sync_dialogs()
await self.sync_contacts()
if config["bridge.catch_up"]:
await self.client.catch_up()
except Exception:
self.log.exception("Failed to run post-login functions")
+1 -1
View File
@@ -26,7 +26,7 @@ setuptools.setup(
install_requires=[
"aiohttp>=3.0.1,<4",
"mautrix-appservice>=0.1.4,<0.2.0",
"mautrix-appservice>=0.2.3,<0.3.0",
"SQLAlchemy>=1.2.3,<2",
"alembic>=0.9.8,<0.10",
"Markdown>=2.6.11,<3",