cmsend 0.3.2__tar.gz → 0.4.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.
- {cmsend-0.3.2 → cmsend-0.4.0}/PKG-INFO +11 -7
- {cmsend-0.3.2 → cmsend-0.4.0}/README.md +10 -6
- {cmsend-0.3.2 → cmsend-0.4.0}/cmsend.egg-info/PKG-INFO +11 -7
- {cmsend-0.3.2 → cmsend-0.4.0}/cmsend.py +74 -25
- {cmsend-0.3.2 → cmsend-0.4.0}/LICENSE +0 -0
- {cmsend-0.3.2 → cmsend-0.4.0}/cmsend.egg-info/SOURCES.txt +0 -0
- {cmsend-0.3.2 → cmsend-0.4.0}/cmsend.egg-info/dependency_links.txt +0 -0
- {cmsend-0.3.2 → cmsend-0.4.0}/cmsend.egg-info/entry_points.txt +0 -0
- {cmsend-0.3.2 → cmsend-0.4.0}/cmsend.egg-info/requires.txt +0 -0
- {cmsend-0.3.2 → cmsend-0.4.0}/cmsend.egg-info/top_level.txt +0 -0
- {cmsend-0.3.2 → cmsend-0.4.0}/pyproject.toml +0 -0
- {cmsend-0.3.2 → cmsend-0.4.0}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: cmsend
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.4.0
|
|
4
4
|
Summary: ping messages between chatmail relays
|
|
5
5
|
Project-URL: Repository, https://github.com/chatmail/cmsend
|
|
6
6
|
Project-URL: Changelog, https://github.com/chatmail/cmsend/blob/master/CHANGELOG.md
|
|
@@ -21,17 +21,21 @@ To send and receive from a single chatmail relay:
|
|
|
21
21
|
|
|
22
22
|
cmsend --init nine.testrun.org # <-- substitute with the domain you want to set as origin
|
|
23
23
|
|
|
24
|
-
To setup a
|
|
24
|
+
To setup a tagged chat using an invite link:
|
|
25
25
|
|
|
26
|
-
cmsend --join "INVITELINK" # <-- quotes are neccessary because links contain "&"
|
|
26
|
+
cmsend -t LOG --join "INVITELINK" # <-- quotes are neccessary because links contain "&"
|
|
27
27
|
|
|
28
|
-
To send a message to
|
|
28
|
+
To send a message to a tagged chat:
|
|
29
29
|
|
|
30
|
-
echo "hello" | cmsend
|
|
30
|
+
echo "hello" | cmsend -t LOG
|
|
31
31
|
|
|
32
|
-
To
|
|
32
|
+
To list all chats with tags:
|
|
33
33
|
|
|
34
|
-
cmsend -
|
|
34
|
+
cmsend -l
|
|
35
|
+
|
|
36
|
+
To send a message to a tagged chat with an attachment:
|
|
37
|
+
|
|
38
|
+
cmsend -t LOG -m "here is the file" -a README.md
|
|
35
39
|
|
|
36
40
|
To show help:
|
|
37
41
|
|
|
@@ -8,17 +8,21 @@ To send and receive from a single chatmail relay:
|
|
|
8
8
|
|
|
9
9
|
cmsend --init nine.testrun.org # <-- substitute with the domain you want to set as origin
|
|
10
10
|
|
|
11
|
-
To setup a
|
|
11
|
+
To setup a tagged chat using an invite link:
|
|
12
12
|
|
|
13
|
-
cmsend --join "INVITELINK" # <-- quotes are neccessary because links contain "&"
|
|
13
|
+
cmsend -t LOG --join "INVITELINK" # <-- quotes are neccessary because links contain "&"
|
|
14
14
|
|
|
15
|
-
To send a message to
|
|
15
|
+
To send a message to a tagged chat:
|
|
16
16
|
|
|
17
|
-
echo "hello" | cmsend
|
|
17
|
+
echo "hello" | cmsend -t LOG
|
|
18
18
|
|
|
19
|
-
To
|
|
19
|
+
To list all chats with tags:
|
|
20
20
|
|
|
21
|
-
cmsend -
|
|
21
|
+
cmsend -l
|
|
22
|
+
|
|
23
|
+
To send a message to a tagged chat with an attachment:
|
|
24
|
+
|
|
25
|
+
cmsend -t LOG -m "here is the file" -a README.md
|
|
22
26
|
|
|
23
27
|
To show help:
|
|
24
28
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: cmsend
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.4.0
|
|
4
4
|
Summary: ping messages between chatmail relays
|
|
5
5
|
Project-URL: Repository, https://github.com/chatmail/cmsend
|
|
6
6
|
Project-URL: Changelog, https://github.com/chatmail/cmsend/blob/master/CHANGELOG.md
|
|
@@ -21,17 +21,21 @@ To send and receive from a single chatmail relay:
|
|
|
21
21
|
|
|
22
22
|
cmsend --init nine.testrun.org # <-- substitute with the domain you want to set as origin
|
|
23
23
|
|
|
24
|
-
To setup a
|
|
24
|
+
To setup a tagged chat using an invite link:
|
|
25
25
|
|
|
26
|
-
cmsend --join "INVITELINK" # <-- quotes are neccessary because links contain "&"
|
|
26
|
+
cmsend -t LOG --join "INVITELINK" # <-- quotes are neccessary because links contain "&"
|
|
27
27
|
|
|
28
|
-
To send a message to
|
|
28
|
+
To send a message to a tagged chat:
|
|
29
29
|
|
|
30
|
-
echo "hello" | cmsend
|
|
30
|
+
echo "hello" | cmsend -t LOG
|
|
31
31
|
|
|
32
|
-
To
|
|
32
|
+
To list all chats with tags:
|
|
33
33
|
|
|
34
|
-
cmsend -
|
|
34
|
+
cmsend -l
|
|
35
|
+
|
|
36
|
+
To send a message to a tagged chat with an attachment:
|
|
37
|
+
|
|
38
|
+
cmsend -t LOG -m "here is the file" -a README.md
|
|
35
39
|
|
|
36
40
|
To show help:
|
|
37
41
|
|
|
@@ -26,6 +26,19 @@ def main():
|
|
|
26
26
|
type=str,
|
|
27
27
|
help="setup a chat using the specified invite link",
|
|
28
28
|
)
|
|
29
|
+
parser.add_argument(
|
|
30
|
+
"-t",
|
|
31
|
+
type=str,
|
|
32
|
+
dest="tag",
|
|
33
|
+
default="GENESIS",
|
|
34
|
+
help="use the specified tag for joining a chat or sending a message (default: GENESIS)",
|
|
35
|
+
)
|
|
36
|
+
parser.add_argument(
|
|
37
|
+
"-l",
|
|
38
|
+
dest="listtags",
|
|
39
|
+
action="store_true",
|
|
40
|
+
help="list existing tagged chats"
|
|
41
|
+
)
|
|
29
42
|
parser.add_argument(
|
|
30
43
|
"-m",
|
|
31
44
|
type=str,
|
|
@@ -49,14 +62,18 @@ def main():
|
|
|
49
62
|
|
|
50
63
|
def perform_main(args):
|
|
51
64
|
accounts_dir = xdg_config_home().joinpath("cmsend")
|
|
52
|
-
|
|
65
|
+
if args.verbose >= 1:
|
|
66
|
+
print(f"# using accounts_dir at: {accounts_dir}")
|
|
53
67
|
with Rpc(accounts_dir=accounts_dir) as rpc:
|
|
54
68
|
dc = DeltaChat(rpc)
|
|
55
69
|
profile = Profile(dc, verbosity=args.verbose)
|
|
70
|
+
|
|
56
71
|
if args.relay:
|
|
57
72
|
profile.perform_init(domain=args.relay)
|
|
58
73
|
elif args.invitelink:
|
|
59
|
-
profile.perform_join(invitelink=args.invitelink)
|
|
74
|
+
profile.perform_join(tag=args.tag, invitelink=args.invitelink)
|
|
75
|
+
elif args.listtags:
|
|
76
|
+
profile.perform_listtags()
|
|
60
77
|
else:
|
|
61
78
|
if not profile._account:
|
|
62
79
|
print("profile is not configured, run --init")
|
|
@@ -64,11 +81,12 @@ def perform_main(args):
|
|
|
64
81
|
|
|
65
82
|
if args.msg is None:
|
|
66
83
|
args.msg = sys.stdin.read()
|
|
67
|
-
profile.perform_send(args.msg, filename=args.filename)
|
|
84
|
+
profile.perform_send(text=args.msg, filename=args.filename, tag=args.tag)
|
|
68
85
|
|
|
69
86
|
|
|
70
87
|
class Profile:
|
|
71
88
|
_account = None
|
|
89
|
+
UI_CONFIG_TAGGED_CHATS = "ui.cmsend.tagged_chats"
|
|
72
90
|
|
|
73
91
|
def __init__(self, dc, verbosity=0):
|
|
74
92
|
self.dc = dc
|
|
@@ -77,13 +95,21 @@ class Profile:
|
|
|
77
95
|
addr = account.get_config("configured_addr")
|
|
78
96
|
if addr is not None:
|
|
79
97
|
self._account = account
|
|
80
|
-
|
|
98
|
+
self.verbose1(f"profile {self!r} is active")
|
|
81
99
|
|
|
82
100
|
def __repr__(self):
|
|
83
101
|
if self._account:
|
|
84
102
|
return f"Profile<{self._account.get_config('configured_addr')}>"
|
|
85
103
|
return "Profile<unconfigured>"
|
|
86
104
|
|
|
105
|
+
def verbose1(self, msg):
|
|
106
|
+
if self.verbosity >= 1:
|
|
107
|
+
print(msg)
|
|
108
|
+
|
|
109
|
+
def verbose2(self, msg):
|
|
110
|
+
if self.verbosity >= 2:
|
|
111
|
+
print(msg)
|
|
112
|
+
|
|
87
113
|
def perform_init(self, domain):
|
|
88
114
|
if self._account:
|
|
89
115
|
print(f"profile {self!r} already exists", file=sys.stderr)
|
|
@@ -93,12 +119,13 @@ class Profile:
|
|
|
93
119
|
account.set_config_from_qr(f"dcaccount:{domain}")
|
|
94
120
|
account.start_io()
|
|
95
121
|
account.wait_for_event(EventType.IMAP_INBOX_IDLE)
|
|
96
|
-
|
|
122
|
+
self.verbose1(f"profile {self!r} is configured and active now")
|
|
97
123
|
|
|
98
|
-
def perform_join(self, invitelink):
|
|
124
|
+
def perform_join(self, tag, invitelink):
|
|
99
125
|
if self._account is None:
|
|
100
126
|
print("you must first call --init to setup a profile", file=sys.stderr)
|
|
101
127
|
raise SystemExit(4)
|
|
128
|
+
|
|
102
129
|
self._account.start_io()
|
|
103
130
|
self._account.secure_join(invitelink)
|
|
104
131
|
|
|
@@ -112,33 +139,55 @@ class Profile:
|
|
|
112
139
|
ev = self.wait_for_event(check_joined)
|
|
113
140
|
print(f"established contact with contact_id == {ev.contact_id}")
|
|
114
141
|
|
|
115
|
-
def
|
|
116
|
-
if event.kind == EventType.
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
142
|
+
def me_was_added(event):
|
|
143
|
+
if event.kind == EventType.INCOMING_MSG:
|
|
144
|
+
msg = self._account.get_message_by_id(event.msg_id)
|
|
145
|
+
text = msg.get_snapshot().text
|
|
146
|
+
if text.startswith("Member Me added"):
|
|
147
|
+
return True
|
|
148
|
+
|
|
149
|
+
ev_chat_id = self.wait_for_event(me_was_added)
|
|
150
|
+
chat_id = ev_chat_id.chat_id
|
|
151
|
+
print(f"joining completed with chat_id == {chat_id} tag={tag}")
|
|
152
|
+
self._account.set_config(f"{self.UI_CONFIG_TAGGED_CHATS}.{tag}", str(chat_id))
|
|
153
|
+
list_tags = self._account.get_config(self.UI_CONFIG_TAGGED_CHATS) or ""
|
|
154
|
+
tags = set(list_tags.split(","))
|
|
155
|
+
tags.add(tag)
|
|
156
|
+
self._account.set_config(self.UI_CONFIG_TAGGED_CHATS, ",".join(tags))
|
|
157
|
+
|
|
158
|
+
def perform_listtags(self):
|
|
159
|
+
list_tags = self._account.get_config(self.UI_CONFIG_TAGGED_CHATS) or ""
|
|
160
|
+
for tag in filter(None, list_tags.split(",")):
|
|
161
|
+
chat = self.get_tagged_chat(tag)
|
|
162
|
+
snap = chat.get_full_snapshot()
|
|
163
|
+
print(f"{tag}: chat_id={chat.id} name={snap.name}")
|
|
122
164
|
|
|
123
|
-
def perform_send(self, text, filename=None):
|
|
165
|
+
def perform_send(self, tag, text, filename=None):
|
|
124
166
|
self._account.start_io()
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
167
|
+
|
|
168
|
+
chat = self.get_tagged_chat(tag)
|
|
169
|
+
snap = chat.get_full_snapshot()
|
|
170
|
+
if snap.is_encrypted and snap.can_send:
|
|
171
|
+
msg = chat.send_message(text=text, file=filename)
|
|
172
|
+
print(f"message {msg.id} was queued, waiting for delivery")
|
|
173
|
+
msg.wait_until_delivered()
|
|
174
|
+
return 0
|
|
133
175
|
raise SystemExit(5)
|
|
134
176
|
|
|
177
|
+
def get_tagged_chat(self, tag):
|
|
178
|
+
chat_id = self._account.get_config(f"{self.UI_CONFIG_TAGGED_CHATS}.{tag}")
|
|
179
|
+
if not chat_id:
|
|
180
|
+
print(f"No chat tagged with tag={tag} found for sending on {self!r}, "
|
|
181
|
+
f"use -t {tag} --join 'https://i.delta.chat/...'")
|
|
182
|
+
raise SystemExit(5)
|
|
183
|
+
|
|
184
|
+
return self._account.get_chat_by_id(int(chat_id))
|
|
185
|
+
|
|
135
186
|
def wait_for_event(self, check_event=lambda ev: None):
|
|
136
187
|
account = self._account
|
|
137
188
|
start_clock = time.time()
|
|
138
189
|
|
|
139
|
-
|
|
140
|
-
if self.verbosity > 0:
|
|
141
|
-
print(msg)
|
|
190
|
+
log = self.verbose2
|
|
142
191
|
|
|
143
192
|
while event := account.wait_for_event():
|
|
144
193
|
if event.kind == EventType.INCOMING_MSG:
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|