deltabot-cli 6.1.0__tar.gz → 6.2.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.1.0/deltabot_cli.egg-info → deltabot_cli-6.2.0}/PKG-INFO +1 -1
- {deltabot_cli-6.1.0 → deltabot_cli-6.2.0}/deltabot_cli/cli.py +24 -3
- {deltabot_cli-6.1.0 → deltabot_cli-6.2.0/deltabot_cli.egg-info}/PKG-INFO +1 -1
- {deltabot_cli-6.1.0 → deltabot_cli-6.2.0}/pyproject.toml +3 -0
- {deltabot_cli-6.1.0 → deltabot_cli-6.2.0}/.github/workflows/python-ci.yml +0 -0
- {deltabot_cli-6.1.0 → deltabot_cli-6.2.0}/.gitignore +0 -0
- {deltabot_cli-6.1.0 → deltabot_cli-6.2.0}/LICENSE +0 -0
- {deltabot_cli-6.1.0 → deltabot_cli-6.2.0}/README.md +0 -0
- {deltabot_cli-6.1.0 → deltabot_cli-6.2.0}/deltabot_cli/__init__.py +0 -0
- {deltabot_cli-6.1.0 → deltabot_cli-6.2.0}/deltabot_cli/_utils.py +0 -0
- {deltabot_cli-6.1.0 → deltabot_cli-6.2.0}/deltabot_cli.egg-info/SOURCES.txt +0 -0
- {deltabot_cli-6.1.0 → deltabot_cli-6.2.0}/deltabot_cli.egg-info/dependency_links.txt +0 -0
- {deltabot_cli-6.1.0 → deltabot_cli-6.2.0}/deltabot_cli.egg-info/requires.txt +0 -0
- {deltabot_cli-6.1.0 → deltabot_cli-6.2.0}/deltabot_cli.egg-info/top_level.txt +0 -0
- {deltabot_cli-6.1.0 → deltabot_cli-6.2.0}/examples/echobot.py +0 -0
- {deltabot_cli-6.1.0 → deltabot_cli-6.2.0}/examples/echobot_advanced.py +0 -0
- {deltabot_cli-6.1.0 → deltabot_cli-6.2.0}/pylama.ini +0 -0
- {deltabot_cli-6.1.0 → deltabot_cli-6.2.0}/setup.cfg +0 -0
|
@@ -6,12 +6,13 @@ import subprocess
|
|
|
6
6
|
import sys
|
|
7
7
|
import time
|
|
8
8
|
from argparse import ArgumentParser, Namespace
|
|
9
|
+
from pathlib import Path
|
|
9
10
|
from threading import Thread
|
|
10
11
|
from typing import Callable, Set, Union
|
|
11
12
|
|
|
12
13
|
import qrcode
|
|
13
14
|
from appdirs import user_config_dir
|
|
14
|
-
from deltachat2 import Bot, Event, EventType, IOTransport, JsonRpcError, Rpc
|
|
15
|
+
from deltachat2 import Bot, CoreEvent, Event, EventType, IOTransport, JsonRpcError, Rpc
|
|
15
16
|
from deltachat2.events import EventFilter, HookCollection, HookDecorator, RawEvent
|
|
16
17
|
from rich.logging import RichHandler
|
|
17
18
|
|
|
@@ -131,6 +132,9 @@ class BotCli:
|
|
|
131
132
|
config_parser.add_argument("option", help="option name", nargs="?")
|
|
132
133
|
config_parser.add_argument("value", help="option value to set", nargs="?")
|
|
133
134
|
|
|
135
|
+
import_parser = self.add_subcommand(_import_cmd, name="import")
|
|
136
|
+
import_parser.add_argument("path", help="path to the account backup", type=Path)
|
|
137
|
+
|
|
134
138
|
self.add_subcommand(_serve_cmd, name="serve")
|
|
135
139
|
self.add_subcommand(_qr_cmd, name="qr")
|
|
136
140
|
self.add_subcommand(_list_cmd, name="list")
|
|
@@ -215,7 +219,7 @@ def _init_cmd(cli: BotCli, bot: Bot, args: Namespace) -> None: # noqa: C901
|
|
|
215
219
|
while True:
|
|
216
220
|
raw_event = bot.rpc.get_next_event()
|
|
217
221
|
accid = raw_event.context_id
|
|
218
|
-
event = raw_event.event
|
|
222
|
+
event = CoreEvent(raw_event.event)
|
|
219
223
|
if event.kind == EventType.CONFIGURE_PROGRESS:
|
|
220
224
|
if event.comment:
|
|
221
225
|
bot.logger.info(event.comment)
|
|
@@ -340,7 +344,7 @@ def _list_cmd(cli: BotCli, bot: Bot, _args: Namespace) -> None:
|
|
|
340
344
|
for accid in accounts:
|
|
341
345
|
addr = cli.get_address(rpc, accid)
|
|
342
346
|
if not rpc.is_configured(accid):
|
|
343
|
-
addr = addr
|
|
347
|
+
addr = f"{addr or ''} (not configured)"
|
|
344
348
|
print(f"#{accid} - {addr}")
|
|
345
349
|
|
|
346
350
|
|
|
@@ -365,3 +369,20 @@ def _remove_cmd(cli: BotCli, bot: Bot, args: Namespace) -> None:
|
|
|
365
369
|
addr = cli.get_address(bot.rpc, accid)
|
|
366
370
|
bot.rpc.remove_account(accid)
|
|
367
371
|
print(f"Account #{accid} ({addr}) removed successfully.")
|
|
372
|
+
|
|
373
|
+
|
|
374
|
+
def _import_cmd(_cli: BotCli, bot: Bot, args: Namespace) -> None:
|
|
375
|
+
"""import account backup"""
|
|
376
|
+
if not args.path.exists():
|
|
377
|
+
bot.logger.error(f"path doesn't exist: {str(args.path)!r}")
|
|
378
|
+
sys.exit(1)
|
|
379
|
+
accid = bot.rpc.add_account()
|
|
380
|
+
try:
|
|
381
|
+
bot.rpc.import_backup(accid, str(args.path), None)
|
|
382
|
+
except JsonRpcError as ex:
|
|
383
|
+
bot.rpc.remove_account(accid)
|
|
384
|
+
bot.logger.exception(ex)
|
|
385
|
+
sys.exit(1)
|
|
386
|
+
else:
|
|
387
|
+
addr = bot.rpc.get_config(accid, "configured_addr")
|
|
388
|
+
print(f"Account #{accid} ({addr}) imported successfully.")
|
|
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
|
|
File without changes
|