deltabot-cli 6.2.0__tar.gz → 7.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {deltabot_cli-6.2.0/deltabot_cli.egg-info → deltabot_cli-7.0.0}/PKG-INFO +3 -3
- {deltabot_cli-6.2.0 → deltabot_cli-7.0.0}/deltabot_cli/cli.py +58 -13
- {deltabot_cli-6.2.0 → deltabot_cli-7.0.0/deltabot_cli.egg-info}/PKG-INFO +3 -3
- {deltabot_cli-6.2.0 → deltabot_cli-7.0.0}/deltabot_cli.egg-info/requires.txt +0 -1
- {deltabot_cli-6.2.0 → deltabot_cli-7.0.0}/pyproject.toml +0 -1
- {deltabot_cli-6.2.0 → deltabot_cli-7.0.0}/.github/workflows/python-ci.yml +0 -0
- {deltabot_cli-6.2.0 → deltabot_cli-7.0.0}/.gitignore +0 -0
- {deltabot_cli-6.2.0 → deltabot_cli-7.0.0}/LICENSE +0 -0
- {deltabot_cli-6.2.0 → deltabot_cli-7.0.0}/README.md +0 -0
- {deltabot_cli-6.2.0 → deltabot_cli-7.0.0}/deltabot_cli/__init__.py +0 -0
- {deltabot_cli-6.2.0 → deltabot_cli-7.0.0}/deltabot_cli/_utils.py +0 -0
- {deltabot_cli-6.2.0 → deltabot_cli-7.0.0}/deltabot_cli.egg-info/SOURCES.txt +0 -0
- {deltabot_cli-6.2.0 → deltabot_cli-7.0.0}/deltabot_cli.egg-info/dependency_links.txt +0 -0
- {deltabot_cli-6.2.0 → deltabot_cli-7.0.0}/deltabot_cli.egg-info/top_level.txt +0 -0
- {deltabot_cli-6.2.0 → deltabot_cli-7.0.0}/examples/echobot.py +0 -0
- {deltabot_cli-6.2.0 → deltabot_cli-7.0.0}/examples/echobot_advanced.py +0 -0
- {deltabot_cli-6.2.0 → deltabot_cli-7.0.0}/pylama.ini +0 -0
- {deltabot_cli-6.2.0 → deltabot_cli-7.0.0}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: deltabot-cli
|
|
3
|
-
Version:
|
|
3
|
+
Version: 7.0.0
|
|
4
4
|
Summary: Library to speedup Delta Chat bot development
|
|
5
5
|
Author-email: adbenitez <adb@merlinux.eu>
|
|
6
6
|
Project-URL: Homepage, https://github.com/deltachat-bot/deltabot-cli-py
|
|
@@ -15,7 +15,6 @@ License-File: LICENSE
|
|
|
15
15
|
Requires-Dist: deltachat2[full]>=0.5.0
|
|
16
16
|
Requires-Dist: appdirs>=1.4.4
|
|
17
17
|
Requires-Dist: rich>=12.6.0
|
|
18
|
-
Requires-Dist: qrcode>=7.4.2
|
|
19
18
|
Provides-Extra: dev
|
|
20
19
|
Requires-Dist: black; extra == "dev"
|
|
21
20
|
Requires-Dist: mypy; extra == "dev"
|
|
@@ -23,6 +22,7 @@ Requires-Dist: isort; extra == "dev"
|
|
|
23
22
|
Requires-Dist: pylint; extra == "dev"
|
|
24
23
|
Requires-Dist: pylama; extra == "dev"
|
|
25
24
|
Requires-Dist: pytest; extra == "dev"
|
|
25
|
+
Dynamic: license-file
|
|
26
26
|
|
|
27
27
|
# deltabot-cli for Python
|
|
28
28
|
|
|
@@ -10,7 +10,6 @@ from pathlib import Path
|
|
|
10
10
|
from threading import Thread
|
|
11
11
|
from typing import Callable, Set, Union
|
|
12
12
|
|
|
13
|
-
import qrcode
|
|
14
13
|
from appdirs import user_config_dir
|
|
15
14
|
from deltachat2 import Bot, CoreEvent, Event, EventType, IOTransport, JsonRpcError, Rpc
|
|
16
15
|
from deltachat2.events import EventFilter, HookCollection, HookDecorator, RawEvent
|
|
@@ -136,7 +135,8 @@ class BotCli:
|
|
|
136
135
|
import_parser.add_argument("path", help="path to the account backup", type=Path)
|
|
137
136
|
|
|
138
137
|
self.add_subcommand(_serve_cmd, name="serve")
|
|
139
|
-
self.add_subcommand(
|
|
138
|
+
self.add_subcommand(_link_cmd, name="link")
|
|
139
|
+
self.add_subcommand(_admin_cmd, name="admin")
|
|
140
140
|
self.add_subcommand(_list_cmd, name="list")
|
|
141
141
|
self.add_subcommand(_remove_cmd, name="remove")
|
|
142
142
|
|
|
@@ -172,6 +172,25 @@ class BotCli:
|
|
|
172
172
|
return rpc.get_config(accid, "configured_addr")
|
|
173
173
|
return rpc.get_config(accid, "addr")
|
|
174
174
|
|
|
175
|
+
def get_admin_chat(self, rpc: Rpc, accid: int) -> int:
|
|
176
|
+
"""Return the bot administration group.
|
|
177
|
+
If the account is not configured, zero is returned.
|
|
178
|
+
"""
|
|
179
|
+
if not rpc.is_configured(accid):
|
|
180
|
+
return 0
|
|
181
|
+
chatid = int(rpc.get_config(accid, "ui.admin_chat") or 0)
|
|
182
|
+
return chatid or self.reset_admin_chat(rpc, accid)
|
|
183
|
+
|
|
184
|
+
def reset_admin_chat(self, rpc: Rpc, accid: int) -> int:
|
|
185
|
+
"""Reset the bot administration group and return the new group id.
|
|
186
|
+
If the account is not configured, zero is returned.
|
|
187
|
+
"""
|
|
188
|
+
if not rpc.is_configured(accid):
|
|
189
|
+
return 0
|
|
190
|
+
chatid = rpc.create_group_chat(accid, "Bot Admins", True)
|
|
191
|
+
rpc.set_config(accid, "ui.admin_chat", str(chatid))
|
|
192
|
+
return chatid
|
|
193
|
+
|
|
175
194
|
def start(self) -> None:
|
|
176
195
|
"""Start running the bot and processing incoming messages."""
|
|
177
196
|
self.init_parser()
|
|
@@ -305,8 +324,38 @@ def _config_cmd_for_acc(bot: Bot, accid: int, args: Namespace) -> None:
|
|
|
305
324
|
print(f"{key}={value!r}")
|
|
306
325
|
|
|
307
326
|
|
|
308
|
-
def
|
|
309
|
-
"""
|
|
327
|
+
def _admin_cmd(cli: BotCli, bot: Bot, args: Namespace) -> None:
|
|
328
|
+
"""print the invitation link to the bot administration group.
|
|
329
|
+
WARNING: don't share this, anyone joining will become admin of the bot"""
|
|
330
|
+
if args.account:
|
|
331
|
+
accounts = [cli.get_account(bot.rpc, args.account)]
|
|
332
|
+
if not accounts[0]:
|
|
333
|
+
bot.logger.error(f"unknown account: {args.account!r}")
|
|
334
|
+
sys.exit(1)
|
|
335
|
+
else:
|
|
336
|
+
accounts = bot.rpc.get_all_account_ids()
|
|
337
|
+
for accid in accounts:
|
|
338
|
+
addr = cli.get_address(bot.rpc, accid)
|
|
339
|
+
print(f"Account #{accid} ({addr}):")
|
|
340
|
+
_admin_cmd_for_acc(cli, bot, accid)
|
|
341
|
+
print("")
|
|
342
|
+
if not accounts:
|
|
343
|
+
bot.logger.error("There are no accounts yet, add a new account using the init subcommand")
|
|
344
|
+
sys.exit(1)
|
|
345
|
+
|
|
346
|
+
|
|
347
|
+
def _admin_cmd_for_acc(cli: BotCli, bot: Bot, accid: int) -> None:
|
|
348
|
+
"""print bot's admin group invitation for the given account"""
|
|
349
|
+
if bot.rpc.is_configured(accid):
|
|
350
|
+
chatid = cli.get_admin_chat(bot.rpc, accid)
|
|
351
|
+
qrdata = bot.rpc.get_chat_securejoin_qr_code(accid, chatid)
|
|
352
|
+
print(qrdata)
|
|
353
|
+
else:
|
|
354
|
+
bot.logger.error("account not configured")
|
|
355
|
+
|
|
356
|
+
|
|
357
|
+
def _link_cmd(cli: BotCli, bot: Bot, args: Namespace) -> None:
|
|
358
|
+
"""print the bot's chat invitation link"""
|
|
310
359
|
if args.account:
|
|
311
360
|
accounts = [cli.get_account(bot.rpc, args.account)]
|
|
312
361
|
if not accounts[0]:
|
|
@@ -317,22 +366,18 @@ def _qr_cmd(cli: BotCli, bot: Bot, args: Namespace) -> None:
|
|
|
317
366
|
for accid in accounts:
|
|
318
367
|
addr = cli.get_address(bot.rpc, accid)
|
|
319
368
|
print(f"Account #{accid} ({addr}):")
|
|
320
|
-
|
|
369
|
+
_link_cmd_for_acc(bot, accid)
|
|
321
370
|
print("")
|
|
322
371
|
if not accounts:
|
|
323
372
|
bot.logger.error("There are no accounts yet, add a new account using the init subcommand")
|
|
324
373
|
sys.exit(1)
|
|
325
374
|
|
|
326
375
|
|
|
327
|
-
def
|
|
328
|
-
"""
|
|
376
|
+
def _link_cmd_for_acc(bot: Bot, accid: int) -> None:
|
|
377
|
+
"""print the bot's chat invitation link for the given account"""
|
|
329
378
|
if bot.rpc.is_configured(accid):
|
|
330
|
-
qrdata
|
|
331
|
-
|
|
332
|
-
code.add_data(qrdata)
|
|
333
|
-
code.print_ascii(invert=True)
|
|
334
|
-
fragment = qrdata.split(":", maxsplit=1)[1].replace("#", "&", 1)
|
|
335
|
-
print(f"https://i.delta.chat/#{fragment}")
|
|
379
|
+
qrdata = bot.rpc.get_chat_securejoin_qr_code(accid, None)
|
|
380
|
+
print(qrdata)
|
|
336
381
|
else:
|
|
337
382
|
bot.logger.error("account not configured")
|
|
338
383
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: deltabot-cli
|
|
3
|
-
Version:
|
|
3
|
+
Version: 7.0.0
|
|
4
4
|
Summary: Library to speedup Delta Chat bot development
|
|
5
5
|
Author-email: adbenitez <adb@merlinux.eu>
|
|
6
6
|
Project-URL: Homepage, https://github.com/deltachat-bot/deltabot-cli-py
|
|
@@ -15,7 +15,6 @@ License-File: LICENSE
|
|
|
15
15
|
Requires-Dist: deltachat2[full]>=0.5.0
|
|
16
16
|
Requires-Dist: appdirs>=1.4.4
|
|
17
17
|
Requires-Dist: rich>=12.6.0
|
|
18
|
-
Requires-Dist: qrcode>=7.4.2
|
|
19
18
|
Provides-Extra: dev
|
|
20
19
|
Requires-Dist: black; extra == "dev"
|
|
21
20
|
Requires-Dist: mypy; extra == "dev"
|
|
@@ -23,6 +22,7 @@ Requires-Dist: isort; extra == "dev"
|
|
|
23
22
|
Requires-Dist: pylint; extra == "dev"
|
|
24
23
|
Requires-Dist: pylama; extra == "dev"
|
|
25
24
|
Requires-Dist: pytest; extra == "dev"
|
|
25
|
+
Dynamic: license-file
|
|
26
26
|
|
|
27
27
|
# deltabot-cli for Python
|
|
28
28
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|