Add None return type to functions
This commit is contained in:
@@ -27,7 +27,7 @@ from ..util import format_duration
|
||||
@command_handler(needs_auth=False,
|
||||
help_section=SECTION_AUTH,
|
||||
help_text="Check if you're logged into Telegram.")
|
||||
async def ping(evt: CommandEvent):
|
||||
async def ping(evt: CommandEvent) -> None:
|
||||
me = await evt.sender.client.get_me() if await evt.sender.is_logged_in() else None
|
||||
if me:
|
||||
return await evt.reply(f"You're logged in as @{me.username}")
|
||||
@@ -38,7 +38,7 @@ async def ping(evt: CommandEvent):
|
||||
@command_handler(needs_auth=False, needs_puppeting=False,
|
||||
help_section=SECTION_AUTH,
|
||||
help_text="Get the info of the message relay Telegram bot.")
|
||||
async def ping_bot(evt: CommandEvent):
|
||||
async def ping_bot(evt: CommandEvent) -> None:
|
||||
if not evt.tgbot:
|
||||
return await evt.reply("Telegram message relay bot not configured.")
|
||||
bot_info = await evt.tgbot.client.get_me()
|
||||
@@ -53,7 +53,7 @@ async def ping_bot(evt: CommandEvent):
|
||||
help_section=SECTION_AUTH,
|
||||
help_text="Revert your Telegram account's Matrix puppet to use the default Matrix "
|
||||
"account.")
|
||||
async def logout_matrix(evt: CommandEvent):
|
||||
async def logout_matrix(evt: CommandEvent) -> None:
|
||||
puppet = pu.Puppet.get(evt.sender.tgid)
|
||||
if not puppet.is_real_user:
|
||||
return await evt.reply("You are not logged in with your Matrix account.")
|
||||
@@ -65,7 +65,7 @@ async def logout_matrix(evt: CommandEvent):
|
||||
help_section=SECTION_AUTH,
|
||||
help_text="Replace your Telegram account's Matrix puppet with your own Matrix "
|
||||
"account")
|
||||
async def login_matrix(evt: CommandEvent):
|
||||
async def login_matrix(evt: CommandEvent) -> None:
|
||||
puppet = pu.Puppet.get(evt.sender.tgid)
|
||||
if puppet.is_real_user:
|
||||
return await evt.reply("You have already logged in with your Matrix account. "
|
||||
@@ -96,7 +96,7 @@ async def login_matrix(evt: CommandEvent):
|
||||
return await evt.reply("This bridge instance has been configured to not allow logging in.")
|
||||
|
||||
|
||||
async def enter_matrix_token(evt: CommandEvent):
|
||||
async def enter_matrix_token(evt: CommandEvent) -> None:
|
||||
evt.sender.command_status = None
|
||||
|
||||
puppet = pu.Puppet.get(evt.sender.tgid)
|
||||
@@ -117,7 +117,7 @@ async def enter_matrix_token(evt: CommandEvent):
|
||||
help_section=SECTION_AUTH,
|
||||
help_args="<_phone_> <_full name_>",
|
||||
help_text="Register to Telegram")
|
||||
async def register(evt: CommandEvent):
|
||||
async def register(evt: CommandEvent) -> None:
|
||||
if await evt.sender.is_logged_in():
|
||||
return await evt.reply("You are already logged in.")
|
||||
elif len(evt.args) < 1:
|
||||
@@ -136,7 +136,7 @@ async def register(evt: CommandEvent):
|
||||
})
|
||||
|
||||
|
||||
async def enter_code_register(evt: CommandEvent):
|
||||
async def enter_code_register(evt: CommandEvent) -> None:
|
||||
if len(evt.args) == 0:
|
||||
return await evt.reply("**Usage:** `$cmdprefix+sp <code>`")
|
||||
try:
|
||||
@@ -165,7 +165,7 @@ async def enter_code_register(evt: CommandEvent):
|
||||
@command_handler(needs_auth=False, management_only=True,
|
||||
help_section=SECTION_AUTH,
|
||||
help_text="Get instructions on how to log in.")
|
||||
async def login(evt: CommandEvent):
|
||||
async def login(evt: CommandEvent) -> None:
|
||||
if await evt.sender.is_logged_in():
|
||||
return await evt.reply("You are already logged in.")
|
||||
|
||||
@@ -196,7 +196,7 @@ async def login(evt: CommandEvent):
|
||||
return await evt.reply("This bridge instance has been configured to not allow logging in.")
|
||||
|
||||
|
||||
async def request_code(evt: CommandEvent, phone_number: str, next_status: Dict[str, str]):
|
||||
async def request_code(evt: CommandEvent, phone_number: str, next_status: Dict[str, str]) -> None:
|
||||
ok = False
|
||||
try:
|
||||
await evt.sender.ensure_started(even_if_no_session=True)
|
||||
@@ -228,7 +228,7 @@ async def request_code(evt: CommandEvent, phone_number: str, next_status: Dict[s
|
||||
|
||||
|
||||
@command_handler(needs_auth=False)
|
||||
async def enter_phone_or_token(evt: CommandEvent):
|
||||
async def enter_phone_or_token(evt: CommandEvent) -> None:
|
||||
if len(evt.args) == 0:
|
||||
return await evt.reply("**Usage:** `$cmdprefix+sp enter-phone-or-token <phone-or-token>`")
|
||||
elif not evt.config.get("bridge.allow_matrix_login", True):
|
||||
@@ -251,7 +251,7 @@ async def enter_phone_or_token(evt: CommandEvent):
|
||||
|
||||
|
||||
@command_handler(needs_auth=False)
|
||||
async def enter_code(evt: CommandEvent):
|
||||
async def enter_code(evt: CommandEvent) -> None:
|
||||
if len(evt.args) == 0:
|
||||
return await evt.reply("**Usage:** `$cmdprefix+sp enter-code <code>`")
|
||||
elif not evt.config.get("bridge.allow_matrix_login", True):
|
||||
@@ -266,7 +266,7 @@ async def enter_code(evt: CommandEvent):
|
||||
|
||||
|
||||
@command_handler(needs_auth=False)
|
||||
async def enter_password(evt: CommandEvent):
|
||||
async def enter_password(evt: CommandEvent) -> None:
|
||||
if len(evt.args) == 0:
|
||||
return await evt.reply("**Usage:** `$cmdprefix+sp enter-password <password>`")
|
||||
elif not evt.config.get("bridge.allow_matrix_login", True):
|
||||
@@ -284,7 +284,7 @@ async def enter_password(evt: CommandEvent):
|
||||
"Check console for more details.")
|
||||
|
||||
|
||||
async def sign_in(evt: CommandEvent, **sign_in_info):
|
||||
async def sign_in(evt: CommandEvent, **sign_in_info) -> None:
|
||||
try:
|
||||
await evt.sender.ensure_started(even_if_no_session=True)
|
||||
user = await evt.sender.client.sign_in(**sign_in_info)
|
||||
@@ -309,7 +309,7 @@ async def sign_in(evt: CommandEvent, **sign_in_info):
|
||||
@command_handler(needs_auth=True,
|
||||
help_section=SECTION_AUTH,
|
||||
help_text="Log out from Telegram.")
|
||||
async def logout(evt: CommandEvent):
|
||||
async def logout(evt: CommandEvent) -> None:
|
||||
if await evt.sender.log_out():
|
||||
return await evt.reply("Logged out successfully.")
|
||||
return await evt.reply("Failed to log out.")
|
||||
|
||||
Reference in New Issue
Block a user