Handle RPCErrors in formatter and update mautrix-python
This commit is contained in:
@@ -26,6 +26,7 @@ from telethon.tl.types import (MessageEntityMention, MessageEntityMentionName, M
|
|||||||
MessageEntityBlockquote, MessageEntityStrike, MessageFwdHeader,
|
MessageEntityBlockquote, MessageEntityStrike, MessageFwdHeader,
|
||||||
MessageEntityUnderline, PeerUser)
|
MessageEntityUnderline, PeerUser)
|
||||||
from telethon.tl.custom import Message
|
from telethon.tl.custom import Message
|
||||||
|
from telethon.errors import RPCError
|
||||||
from telethon.helpers import add_surrogate, del_surrogate
|
from telethon.helpers import add_surrogate, del_surrogate
|
||||||
|
|
||||||
from mautrix.errors import MatrixRequestError
|
from mautrix.errors import MatrixRequestError
|
||||||
@@ -80,7 +81,7 @@ async def _add_forward_header(source: 'AbstractUser', content: TextMessageEventC
|
|||||||
if user:
|
if user:
|
||||||
fwd_from_text = pu.Puppet.get_displayname(user, False)
|
fwd_from_text = pu.Puppet.get_displayname(user, False)
|
||||||
fwd_from_html = f"<b>{escape(fwd_from_text)}</b>"
|
fwd_from_html = f"<b>{escape(fwd_from_text)}</b>"
|
||||||
except ValueError:
|
except (ValueError, RPCError):
|
||||||
fwd_from_text = fwd_from_html = "unknown user"
|
fwd_from_text = fwd_from_html = "unknown user"
|
||||||
elif fwd_from.channel_id:
|
elif fwd_from.channel_id:
|
||||||
portal = po.Portal.get_by_tgid(TelegramID(fwd_from.channel_id))
|
portal = po.Portal.get_by_tgid(TelegramID(fwd_from.channel_id))
|
||||||
@@ -97,7 +98,7 @@ async def _add_forward_header(source: 'AbstractUser', content: TextMessageEventC
|
|||||||
if channel:
|
if channel:
|
||||||
fwd_from_text = f"channel {channel.title}"
|
fwd_from_text = f"channel {channel.title}"
|
||||||
fwd_from_html = f"channel <b>{escape(channel.title)}</b>"
|
fwd_from_html = f"channel <b>{escape(channel.title)}</b>"
|
||||||
except ValueError:
|
except (ValueError, RPCError):
|
||||||
fwd_from_text = fwd_from_html = "unknown channel"
|
fwd_from_text = fwd_from_html = "unknown channel"
|
||||||
elif fwd_from.from_name:
|
elif fwd_from.from_name:
|
||||||
fwd_from_text = fwd_from.from_name
|
fwd_from_text = fwd_from.from_name
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ setuptools.setup(
|
|||||||
|
|
||||||
install_requires=[
|
install_requires=[
|
||||||
"aiohttp>=3.0.1,<4",
|
"aiohttp>=3.0.1,<4",
|
||||||
"mautrix>=0.4.0.dev59,<0.5",
|
"mautrix>=0.4.0.dev60,<0.5",
|
||||||
"SQLAlchemy>=1.2.3,<2",
|
"SQLAlchemy>=1.2.3,<2",
|
||||||
"alembic>=1.0.0,<2",
|
"alembic>=1.0.0,<2",
|
||||||
"commonmark>=0.8.1,<1",
|
"commonmark>=0.8.1,<1",
|
||||||
|
|||||||
Reference in New Issue
Block a user