annotate libervia/cli/cmd_gateway.py @ 4308:472a938a46e3

cli (message/send): add arguments for message addressing: commands have been added to add `to`, `cc` and `bcc` metadata for sending copy of the message to several entities. Metadata such as `reply-to` `reply-room` and `no-reply` are also supported. rel 450
author Goffi <goffi@goffi.org>
date Thu, 26 Sep 2024 16:12:01 +0200
parents 9deb3ddb2921
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4301
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
1 #!/usr/bin/env python3
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
2
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
3 # Libervia CLI
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
4 # Copyright (C) 2009-2024 Jérôme Poisson (goffi@goffi.org)
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
5
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
6 # This program is free software: you can redistribute it and/or modify
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
7 # it under the terms of the GNU Affero General Public License as published by
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
8 # the Free Software Foundation, either version 3 of the License, or
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
9 # (at your option) any later version.
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
10
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
11 # This program is distributed in the hope that it will be useful,
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
14 # GNU Affero General Public License for more details.
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
15
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
16 # You should have received a copy of the GNU Affero General Public License
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
17 # along with this program. If not, see <http://www.gnu.org/licenses/>.
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
18
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
19
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
20 from libervia.backend.core.i18n import _
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
21 from libervia.backend.tools.common import data_format
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
22 from libervia.cli import xmlui_manager
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
23 from libervia.cli.constants import Const as C
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
24 from . import base
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
25 from rich.table import Table
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
26
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
27 __commands__ = ["Gateway"]
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
28
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
29
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
30 class List(base.CommandBase):
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
31 def __init__(self, host):
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
32 super().__init__(
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
33 host,
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
34 "list",
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
35 use_output=C.OUTPUT_COMPLEX,
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
36 extra_outputs={"default": self.default_output},
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
37 use_verbose=True,
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
38 help=_("list gateways of a server"),
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
39 )
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
40
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
41 def add_parser_options(self):
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
42 self.parser.add_argument(
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
43 "server_jid",
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
44 nargs="?",
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
45 metavar="JID",
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
46 default="",
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
47 help=_("JID of the server to check, use own server if not specified"),
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
48 )
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
49
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
50 def default_output(self, data: dict) -> None:
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
51 available_table = Table(
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
52 "JID",
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
53 _("Name"),
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
54 _("Category"),
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
55 _("Type"),
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
56 title=":white_check_mark: " + _("Available Gateways"),
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
57 title_justify="left",
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
58 )
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
59 for gateway in data["available"]:
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
60 identities = gateway["identities"]
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
61 names = "\n".join([identity["name"] for identity in identities])
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
62 categories = "\n".join([identity["category"] for identity in identities])
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
63 types = "\n".join([identity["type"] for identity in identities])
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
64 available_table.add_row(gateway["entity"], names, categories, types)
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
65
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
66 self.console.print(available_table)
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
67
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
68 if self.verbosity:
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
69 # In verbose mode, we show unavailable gateways too.
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
70 self.console.print()
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
71
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
72 if self.verbosity > 1:
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
73 self.console.print(
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
74 _("Following services are registered but don't answer:"),
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
75 "\n",
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
76 style="italic",
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
77 )
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
78
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
79 unavailable_table = Table(
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
80 "JID",
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
81 title=":x: " + _("Unavailable Services"),
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
82 title_justify="left",
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
83 )
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
84 for gateway_jid in data["unavailable"]:
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
85 unavailable_table.add_row(gateway_jid)
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
86
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
87 self.console.print(unavailable_table)
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
88
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
89 async def start(self):
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
90 try:
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
91 found_gateways = data_format.deserialise(
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
92 await self.host.bridge.gateways_find(self.args.server_jid, self.profile)
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
93 )
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
94 except Exception as e:
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
95 self.disp(f"can't find gateways for {self.args.server_jid}: {e}", error=True)
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
96 self.host.quit(C.EXIT_BRIDGE_ERRBACK)
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
97 else:
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
98 await self.output(found_gateways)
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
99 self.host.quit(C.EXIT_OK)
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
100
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
101
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
102 class Register(base.CommandBase):
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
103 def __init__(self, host):
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
104 super().__init__(
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
105 host,
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
106 "register",
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
107 help=_("register to a gateway"),
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
108 )
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
109
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
110 def add_parser_options(self):
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
111 self.parser.add_argument(
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
112 "gateway_jid",
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
113 metavar="JID",
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
114 help=_("JID of gateway to register to"),
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
115 )
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
116
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
117 async def start(self):
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
118 try:
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
119 xmlui_raw = await self.host.bridge.gateway_register(
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
120 self.args.gateway_jid, self.profile
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
121 )
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
122 except Exception as e:
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
123 self.disp(f"can't register to gateway: {e}", error=True)
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
124 self.host.quit(C.EXIT_BRIDGE_ERRBACK)
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
125 else:
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
126 xmlui = xmlui_manager.create(self.host, xmlui_raw)
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
127 await xmlui.show()
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
128 # FIXME: Registration errors are not correctly managed.
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
129 ret = await xmlui.submit_form()
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
130 self.host.quit(C.EXIT_OK)
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
131
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
132
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
133 class Unregister(base.CommandBase):
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
134 def __init__(self, host):
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
135 super().__init__(
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
136 host,
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
137 "unregister",
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
138 help=_("unregister from a gateway"),
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
139 )
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
140
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
141 def add_parser_options(self):
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
142 self.parser.add_argument(
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
143 "-f",
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
144 "--force",
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
145 action="store_true",
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
146 help=_("unregister without confirmation"),
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
147 )
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
148 self.parser.add_argument(
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
149 "gateway_jid",
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
150 metavar="JID",
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
151 help=_("JID of gateway to unregister from"),
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
152 )
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
153
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
154 async def start(self):
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
155 if not self.args.force:
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
156 await self.host.confirm_or_quit(
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
157 _(
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
158 "Are you sure that you want to unregister from {gateway_jid}?"
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
159 ).format(gateway_jid=self.args.gateway_jid),
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
160 _("Gateway unregistration cancelled.")
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
161 )
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
162
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
163 try:
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
164 await self.host.bridge.in_band_unregister(
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
165 self.args.gateway_jid, self.profile
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
166 )
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
167 except Exception as e:
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
168 self.disp(f"can't unregister from gateway: {e}", error=True)
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
169 self.host.quit(C.EXIT_BRIDGE_ERRBACK)
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
170 else:
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
171 self.host.quit(C.EXIT_OK)
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
172
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
173
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
174 class Gateway(base.CommandBase):
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
175 subcommands = (List, Register, Unregister)
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
176
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
177 def __init__(self, host):
9deb3ddb2921 CLI: add commands to handle gateways:
Goffi <goffi@goffi.org>
parents:
diff changeset
178 super().__init__(host, "gateway", use_profile=False, help=_("gateway handling"))