cmsend 0.3.1__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.1 → cmsend-0.4.0}/PKG-INFO +11 -7
- {cmsend-0.3.1 → cmsend-0.4.0}/README.md +10 -6
- {cmsend-0.3.1 → cmsend-0.4.0}/cmsend.egg-info/PKG-INFO +11 -7
- {cmsend-0.3.1 → cmsend-0.4.0}/cmsend.py +83 -28
- {cmsend-0.3.1 → cmsend-0.4.0}/LICENSE +0 -0
- {cmsend-0.3.1 → cmsend-0.4.0}/cmsend.egg-info/SOURCES.txt +0 -0
- {cmsend-0.3.1 → cmsend-0.4.0}/cmsend.egg-info/dependency_links.txt +0 -0
- {cmsend-0.3.1 → cmsend-0.4.0}/cmsend.egg-info/entry_points.txt +0 -0
- {cmsend-0.3.1 → cmsend-0.4.0}/cmsend.egg-info/requires.txt +0 -0
- {cmsend-0.3.1 → cmsend-0.4.0}/cmsend.egg-info/top_level.txt +0 -0
- {cmsend-0.3.1 → cmsend-0.4.0}/pyproject.toml +0 -0
- {cmsend-0.3.1 → 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
|
|
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
|
|
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
|
|
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
|
|
|
@@ -17,13 +17,28 @@ def main():
|
|
|
17
17
|
parser.add_argument(
|
|
18
18
|
"--init",
|
|
19
19
|
type=str,
|
|
20
|
+
dest="relay",
|
|
20
21
|
help="initialize a profile with the specified chatmail relay",
|
|
21
22
|
)
|
|
22
23
|
parser.add_argument(
|
|
23
24
|
"--join",
|
|
25
|
+
dest="invitelink",
|
|
24
26
|
type=str,
|
|
25
27
|
help="setup a chat using the specified invite link",
|
|
26
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
|
+
)
|
|
27
42
|
parser.add_argument(
|
|
28
43
|
"-m",
|
|
29
44
|
type=str,
|
|
@@ -47,22 +62,31 @@ def main():
|
|
|
47
62
|
|
|
48
63
|
def perform_main(args):
|
|
49
64
|
accounts_dir = xdg_config_home().joinpath("cmsend")
|
|
50
|
-
|
|
65
|
+
if args.verbose >= 1:
|
|
66
|
+
print(f"# using accounts_dir at: {accounts_dir}")
|
|
51
67
|
with Rpc(accounts_dir=accounts_dir) as rpc:
|
|
52
68
|
dc = DeltaChat(rpc)
|
|
53
69
|
profile = Profile(dc, verbosity=args.verbose)
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
70
|
+
|
|
71
|
+
if args.relay:
|
|
72
|
+
profile.perform_init(domain=args.relay)
|
|
73
|
+
elif args.invitelink:
|
|
74
|
+
profile.perform_join(tag=args.tag, invitelink=args.invitelink)
|
|
75
|
+
elif args.listtags:
|
|
76
|
+
profile.perform_listtags()
|
|
58
77
|
else:
|
|
78
|
+
if not profile._account:
|
|
79
|
+
print("profile is not configured, run --init")
|
|
80
|
+
raise SystemExit(2)
|
|
81
|
+
|
|
59
82
|
if args.msg is None:
|
|
60
83
|
args.msg = sys.stdin.read()
|
|
61
|
-
profile.perform_send(args.msg, filename=args.filename)
|
|
84
|
+
profile.perform_send(text=args.msg, filename=args.filename, tag=args.tag)
|
|
62
85
|
|
|
63
86
|
|
|
64
87
|
class Profile:
|
|
65
88
|
_account = None
|
|
89
|
+
UI_CONFIG_TAGGED_CHATS = "ui.cmsend.tagged_chats"
|
|
66
90
|
|
|
67
91
|
def __init__(self, dc, verbosity=0):
|
|
68
92
|
self.dc = dc
|
|
@@ -71,13 +95,21 @@ class Profile:
|
|
|
71
95
|
addr = account.get_config("configured_addr")
|
|
72
96
|
if addr is not None:
|
|
73
97
|
self._account = account
|
|
74
|
-
|
|
98
|
+
self.verbose1(f"profile {self!r} is active")
|
|
75
99
|
|
|
76
100
|
def __repr__(self):
|
|
77
101
|
if self._account:
|
|
78
102
|
return f"Profile<{self._account.get_config('configured_addr')}>"
|
|
79
103
|
return "Profile<unconfigured>"
|
|
80
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
|
+
|
|
81
113
|
def perform_init(self, domain):
|
|
82
114
|
if self._account:
|
|
83
115
|
print(f"profile {self!r} already exists", file=sys.stderr)
|
|
@@ -87,12 +119,13 @@ class Profile:
|
|
|
87
119
|
account.set_config_from_qr(f"dcaccount:{domain}")
|
|
88
120
|
account.start_io()
|
|
89
121
|
account.wait_for_event(EventType.IMAP_INBOX_IDLE)
|
|
90
|
-
|
|
122
|
+
self.verbose1(f"profile {self!r} is configured and active now")
|
|
91
123
|
|
|
92
|
-
def perform_join(self, invitelink):
|
|
124
|
+
def perform_join(self, tag, invitelink):
|
|
93
125
|
if self._account is None:
|
|
94
126
|
print("you must first call --init to setup a profile", file=sys.stderr)
|
|
95
127
|
raise SystemExit(4)
|
|
128
|
+
|
|
96
129
|
self._account.start_io()
|
|
97
130
|
self._account.secure_join(invitelink)
|
|
98
131
|
|
|
@@ -106,33 +139,55 @@ class Profile:
|
|
|
106
139
|
ev = self.wait_for_event(check_joined)
|
|
107
140
|
print(f"established contact with contact_id == {ev.contact_id}")
|
|
108
141
|
|
|
109
|
-
def
|
|
110
|
-
if event.kind == EventType.
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
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}")
|
|
116
164
|
|
|
117
|
-
def perform_send(self, text, filename=None):
|
|
165
|
+
def perform_send(self, tag, text, filename=None):
|
|
118
166
|
self._account.start_io()
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
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
|
|
127
175
|
raise SystemExit(5)
|
|
128
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
|
+
|
|
129
186
|
def wait_for_event(self, check_event=lambda ev: None):
|
|
130
187
|
account = self._account
|
|
131
188
|
start_clock = time.time()
|
|
132
189
|
|
|
133
|
-
|
|
134
|
-
if self.verbosity > 0:
|
|
135
|
-
print(msg)
|
|
190
|
+
log = self.verbose2
|
|
136
191
|
|
|
137
192
|
while event := account.wait_for_event():
|
|
138
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
|