deltabot-cli 6.2.1__tar.gz → 7.1.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.1/deltabot_cli.egg-info → deltabot_cli-7.1.0}/PKG-INFO +3 -3
- {deltabot_cli-6.2.1 → deltabot_cli-7.1.0}/deltabot_cli/cli.py +68 -11
- {deltabot_cli-6.2.1 → deltabot_cli-7.1.0/deltabot_cli.egg-info}/PKG-INFO +3 -3
- {deltabot_cli-6.2.1 → deltabot_cli-7.1.0}/deltabot_cli.egg-info/requires.txt +0 -1
- {deltabot_cli-6.2.1 → deltabot_cli-7.1.0}/pyproject.toml +0 -1
- {deltabot_cli-6.2.1 → deltabot_cli-7.1.0}/.github/workflows/python-ci.yml +0 -0
- {deltabot_cli-6.2.1 → deltabot_cli-7.1.0}/.gitignore +0 -0
- {deltabot_cli-6.2.1 → deltabot_cli-7.1.0}/LICENSE +0 -0
- {deltabot_cli-6.2.1 → deltabot_cli-7.1.0}/README.md +0 -0
- {deltabot_cli-6.2.1 → deltabot_cli-7.1.0}/deltabot_cli/__init__.py +0 -0
- {deltabot_cli-6.2.1 → deltabot_cli-7.1.0}/deltabot_cli/_utils.py +0 -0
- {deltabot_cli-6.2.1 → deltabot_cli-7.1.0}/deltabot_cli.egg-info/SOURCES.txt +0 -0
- {deltabot_cli-6.2.1 → deltabot_cli-7.1.0}/deltabot_cli.egg-info/dependency_links.txt +0 -0
- {deltabot_cli-6.2.1 → deltabot_cli-7.1.0}/deltabot_cli.egg-info/top_level.txt +0 -0
- {deltabot_cli-6.2.1 → deltabot_cli-7.1.0}/examples/echobot.py +0 -0
- {deltabot_cli-6.2.1 → deltabot_cli-7.1.0}/examples/echobot_advanced.py +0 -0
- {deltabot_cli-6.2.1 → deltabot_cli-7.1.0}/pylama.ini +0 -0
- {deltabot_cli-6.2.1 → deltabot_cli-7.1.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.1.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,36 @@ class BotCli:
|
|
|
172
172
|
return rpc.get_config(accid, "configured_addr")
|
|
173
173
|
return rpc.get_config(accid, "addr")
|
|
174
174
|
|
|
175
|
+
def is_admin(self, rpc: Rpc, accid: int, contactid: int) -> bool:
|
|
176
|
+
"""Return True if the contact is an administrator.
|
|
177
|
+
Administrators are the members of the Administration group.
|
|
178
|
+
"""
|
|
179
|
+
chatid = self.get_admin_chat(rpc, accid)
|
|
180
|
+
contacts = rpc.get_chat_contacts(accid, chatid)
|
|
181
|
+
for contact in contacts:
|
|
182
|
+
if contactid == contact:
|
|
183
|
+
return True
|
|
184
|
+
return False
|
|
185
|
+
|
|
186
|
+
def get_admin_chat(self, rpc: Rpc, accid: int) -> int:
|
|
187
|
+
"""Return the bot administration group.
|
|
188
|
+
If the account is not configured, zero is returned.
|
|
189
|
+
"""
|
|
190
|
+
if not rpc.is_configured(accid):
|
|
191
|
+
return 0
|
|
192
|
+
chatid = int(rpc.get_config(accid, "ui.admin_chat") or 0)
|
|
193
|
+
return chatid or self.reset_admin_chat(rpc, accid)
|
|
194
|
+
|
|
195
|
+
def reset_admin_chat(self, rpc: Rpc, accid: int) -> int:
|
|
196
|
+
"""Reset the bot administration group and return the new group id.
|
|
197
|
+
If the account is not configured, zero is returned.
|
|
198
|
+
"""
|
|
199
|
+
if not rpc.is_configured(accid):
|
|
200
|
+
return 0
|
|
201
|
+
chatid = rpc.create_group_chat(accid, "Bot Admins", True)
|
|
202
|
+
rpc.set_config(accid, "ui.admin_chat", str(chatid))
|
|
203
|
+
return chatid
|
|
204
|
+
|
|
175
205
|
def start(self) -> None:
|
|
176
206
|
"""Start running the bot and processing incoming messages."""
|
|
177
207
|
self.init_parser()
|
|
@@ -305,8 +335,38 @@ def _config_cmd_for_acc(bot: Bot, accid: int, args: Namespace) -> None:
|
|
|
305
335
|
print(f"{key}={value!r}")
|
|
306
336
|
|
|
307
337
|
|
|
308
|
-
def
|
|
309
|
-
"""
|
|
338
|
+
def _admin_cmd(cli: BotCli, bot: Bot, args: Namespace) -> None:
|
|
339
|
+
"""print the invitation link to the bot administration group.
|
|
340
|
+
WARNING: don't share this, anyone joining will become admin of the bot"""
|
|
341
|
+
if args.account:
|
|
342
|
+
accounts = [cli.get_account(bot.rpc, args.account)]
|
|
343
|
+
if not accounts[0]:
|
|
344
|
+
bot.logger.error(f"unknown account: {args.account!r}")
|
|
345
|
+
sys.exit(1)
|
|
346
|
+
else:
|
|
347
|
+
accounts = bot.rpc.get_all_account_ids()
|
|
348
|
+
for accid in accounts:
|
|
349
|
+
addr = cli.get_address(bot.rpc, accid)
|
|
350
|
+
print(f"Account #{accid} ({addr}):")
|
|
351
|
+
_admin_cmd_for_acc(cli, bot, accid)
|
|
352
|
+
print("")
|
|
353
|
+
if not accounts:
|
|
354
|
+
bot.logger.error("There are no accounts yet, add a new account using the init subcommand")
|
|
355
|
+
sys.exit(1)
|
|
356
|
+
|
|
357
|
+
|
|
358
|
+
def _admin_cmd_for_acc(cli: BotCli, bot: Bot, accid: int) -> None:
|
|
359
|
+
"""print bot's admin group invitation for the given account"""
|
|
360
|
+
if bot.rpc.is_configured(accid):
|
|
361
|
+
chatid = cli.get_admin_chat(bot.rpc, accid)
|
|
362
|
+
qrdata = bot.rpc.get_chat_securejoin_qr_code(accid, chatid)
|
|
363
|
+
print(qrdata)
|
|
364
|
+
else:
|
|
365
|
+
bot.logger.error("account not configured")
|
|
366
|
+
|
|
367
|
+
|
|
368
|
+
def _link_cmd(cli: BotCli, bot: Bot, args: Namespace) -> None:
|
|
369
|
+
"""print the bot's chat invitation link"""
|
|
310
370
|
if args.account:
|
|
311
371
|
accounts = [cli.get_account(bot.rpc, args.account)]
|
|
312
372
|
if not accounts[0]:
|
|
@@ -317,20 +377,17 @@ def _qr_cmd(cli: BotCli, bot: Bot, args: Namespace) -> None:
|
|
|
317
377
|
for accid in accounts:
|
|
318
378
|
addr = cli.get_address(bot.rpc, accid)
|
|
319
379
|
print(f"Account #{accid} ({addr}):")
|
|
320
|
-
|
|
380
|
+
_link_cmd_for_acc(bot, accid)
|
|
321
381
|
print("")
|
|
322
382
|
if not accounts:
|
|
323
383
|
bot.logger.error("There are no accounts yet, add a new account using the init subcommand")
|
|
324
384
|
sys.exit(1)
|
|
325
385
|
|
|
326
386
|
|
|
327
|
-
def
|
|
328
|
-
"""
|
|
387
|
+
def _link_cmd_for_acc(bot: Bot, accid: int) -> None:
|
|
388
|
+
"""print the bot's chat invitation link for the given account"""
|
|
329
389
|
if bot.rpc.is_configured(accid):
|
|
330
|
-
qrdata
|
|
331
|
-
code = qrcode.QRCode()
|
|
332
|
-
code.add_data(qrdata)
|
|
333
|
-
code.print_ascii(invert=True)
|
|
390
|
+
qrdata = bot.rpc.get_chat_securejoin_qr_code(accid, None)
|
|
334
391
|
print(qrdata)
|
|
335
392
|
else:
|
|
336
393
|
bot.logger.error("account not configured")
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: deltabot-cli
|
|
3
|
-
Version:
|
|
3
|
+
Version: 7.1.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
|