From 0ad47ea6d838971ff557a01aa3e374a87e7e0527 Mon Sep 17 00:00:00 2001 From: Tulir Asokan <tulir@maunium.net> Date: Mon, 15 Jun 2020 19:00:17 +0300 Subject: [PATCH] Add reconnect as alias to connect command --- mautrix_facebook/commands/conn.py | 2 +- mautrix_facebook/commands/handler.py | 11 ++++++----- requirements.txt | 2 +- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/mautrix_facebook/commands/conn.py b/mautrix_facebook/commands/conn.py index 65b1b4f..c906f5a 100644 --- a/mautrix_facebook/commands/conn.py +++ b/mautrix_facebook/commands/conn.py @@ -38,7 +38,7 @@ async def disconnect(evt: CommandEvent) -> None: @command_handler(needs_auth=True, management_only=True, help_section=SECTION_CONNECTION, - help_text="Connect to Facebook Messenger") + help_text="Connect to Facebook Messenger", aliases=["reconnect"]) async def connect(evt: CommandEvent) -> None: if evt.sender.listen_task and not evt.sender.listen_task.done(): await evt.reply("You already have a Messenger MQTT connection") diff --git a/mautrix_facebook/commands/handler.py b/mautrix_facebook/commands/handler.py index 12b7e3b..1aa2144 100644 --- a/mautrix_facebook/commands/handler.py +++ b/mautrix_facebook/commands/handler.py @@ -13,7 +13,7 @@ # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see <https://www.gnu.org/licenses/>. -from typing import Awaitable, Callable, Dict, Optional, NamedTuple +from typing import Awaitable, Callable, Dict, Optional, NamedTuple, List from mautrix.bridge.commands import (HelpSection, CommandEvent as BaseCommandEvent, command_handler as base_command_handler, @@ -67,12 +67,13 @@ class CommandHandler(BaseCommandHandler): def command_handler(_func: Optional[Callable[[CommandEvent], Awaitable[Dict]]] = None, *, needs_auth: bool = True, needs_admin: bool = False, management_only: bool = False, name: Optional[str] = None, - help_text: str = "", help_args: str = "", help_section: HelpSection = None + help_text: str = "", help_args: str = "", help_section: HelpSection = None, + aliases: Optional[List[str]] = None ) -> Callable[[Callable[[CommandEvent], Awaitable[Optional[Dict]]]], CommandHandler]: - return base_command_handler(_func, management_only=management_only, name=name, - help_text=help_text, help_args=help_args, help_section=help_section, - needs_auth=needs_auth, needs_admin=needs_admin, + return base_command_handler(_func, management_only=management_only, name=name, aliases=aliases, + help_text=help_text, help_args=help_args, needs_admin=needs_admin, + help_section=help_section, needs_auth=needs_auth, _handler_class=CommandHandler) diff --git a/requirements.txt b/requirements.txt index 20c215e..fc740f1 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,5 +4,5 @@ alembic>=1,<2 ruamel.yaml>=0.15.94,<0.17 commonmark>=0.8,<0.10 python-magic>=0.4,<0.5 -mautrix>=0.5.5,<0.6 +mautrix>=0.5.6,<0.6 fbchat-asyncio>=0.6.1,<0.7 -- GitLab