Catch invalid integers passed to !tg create
This commit is contained in:
@@ -59,13 +59,18 @@ async def bridge(evt: CommandEvent) -> EventID:
|
|||||||
|
|
||||||
# The /id bot command provides the prefixed ID, so we assume
|
# The /id bot command provides the prefixed ID, so we assume
|
||||||
tgid_str = evt.args[0]
|
tgid_str = evt.args[0]
|
||||||
if tgid_str.startswith("-100"):
|
tgid = None
|
||||||
tgid = TelegramID(int(tgid_str[4:]))
|
try:
|
||||||
peer_type = "channel"
|
if tgid_str.startswith("-100"):
|
||||||
elif tgid_str.startswith("-"):
|
tgid = TelegramID(int(tgid_str[4:]))
|
||||||
tgid = TelegramID(-int(tgid_str))
|
peer_type = "channel"
|
||||||
peer_type = "chat"
|
elif tgid_str.startswith("-"):
|
||||||
else:
|
tgid = TelegramID(-int(tgid_str))
|
||||||
|
peer_type = "chat"
|
||||||
|
except ValueError:
|
||||||
|
# Invalid integer
|
||||||
|
pass
|
||||||
|
if not tgid:
|
||||||
return await evt.reply(
|
return await evt.reply(
|
||||||
"That doesn't seem like a prefixed Telegram chat ID.\n\n"
|
"That doesn't seem like a prefixed Telegram chat ID.\n\n"
|
||||||
"If you did not get the ID using the `/id` bot command, please "
|
"If you did not get the ID using the `/id` bot command, please "
|
||||||
|
|||||||
Reference in New Issue
Block a user