Browse Source

Мейлер возвращён в основной модуль. Исправлен конфигурационный файл по-умолчанию.

Andrew Lobanov 7 months ago
parent
commit
9bf27c0401
3 changed files with 212 additions and 384 deletions
  1. 2 4
      caesium.def.cfg
  2. 210 33
      caesium.py
  3. 0 347
      mailer.py

+ 2 - 4
caesium.def.cfg

@@ -1,12 +1,10 @@
1 1
 editor nano
2 2
 theme default
3
-
4
-fetch ./mailer.py -db %db -w -n %node -m %nodename -a %auth -e %echoareas -to %to
5
-clone ./mailer.py -db %db -w -n %node -m %nodename -a %auth -e %echoareas -c %clone -to %to
3
+depth 50
6 4
 
7 5
 nodename tavern
8 6
 node http://idec.spline-online.tk/
9 7
 
10 8
 echo pipe.2032 Болталка
11 9
 echo ii.14 Обсуждение вопросов, связанных с ii
12
-echo lenta.rss science, sport, culture, media с lenta.ru
10
+echo newsru.com Новостная лента

+ 210 - 33
caesium.py

@@ -12,6 +12,8 @@ counts = []
12 12
 counts_rescan = True
13 13
 echo_counts = {}
14 14
 next_echoarea = False
15
+depth = 50
16
+messages = []
15 17
 
16 18
 version = "Caesium/0.3 │"
17 19
 
@@ -74,7 +76,7 @@ def separate(l, step=20):
74 76
         yield l[x:x+step]
75 77
 
76 78
 def load_config():
77
-    global nodes, editor, color_theme, show_splash, oldquote, fetch_cmd, clone_cmd, send_cmd, db, browser
79
+    global nodes, editor, color_theme, show_splash, oldquote, db, browser, depth
78 80
     nodes = []
79 81
     first = True
80 82
     node = {}
@@ -136,6 +138,11 @@ def load_config():
136 138
             clone_cmd = " ".join(param[1:])
137 139
         elif param[0] == "send":
138 140
             send_cmd = " ".join(param[1:])
141
+        elif param[0] == "depth":
142
+            try:
143
+                depth = int(param[1])
144
+            except:
145
+                None
139 146
         elif param[0] == "db":
140 147
             if param[1] == "txt":
141 148
                 db = 0
@@ -281,6 +288,206 @@ def get_out_length(drafts = False):
281 288
     except:
282 289
         return 0
283 290
 
291
+def make_toss():
292
+    lst = [x for x in os.listdir("out/" + nodes[node]["nodename"]) if x.endswith(".out")]
293
+    for msg in lst:
294
+        text = codecs.open("out/" + nodes[node]["nodename"] + "/%s" % msg, "r", "utf-8").read()
295
+        coded_text = base64.b64encode(text.encode("utf-8"))
296
+        codecs.open("out/" + nodes[node]["nodename"] + "/%s.toss" % msg, "w", "utf-8").write(coded_text.decode("utf-8"))
297
+        os.rename("out/" + nodes[node]["nodename"] + "/%s" % msg, "out/" + nodes[node]["nodename"] + "/%s%s" % (msg, "msg"))
298
+
299
+def send_mail():
300
+    lst = [x for x in sorted(os.listdir("out/" + nodes[node]["nodename"])) if x.endswith(".toss")]
301
+    max = len(lst)
302
+    n = 1
303
+    try:
304
+        for msg in lst:
305
+            print("\rОтправка сообщения: " + str(n) + "/" + str(max), end="")
306
+            text = codecs.open("out/" + nodes[node]["nodename"] + "/%s" % msg, "r", "utf-8").read()
307
+            data = urllib.parse.urlencode({"tmsg": text,"pauth": nodes[node]["auth"]}).encode("utf-8")
308
+            request = urllib.request.Request(nodes[node]["node"] + "u/point")
309
+            result = urllib.request.urlopen(request, data).read().decode("utf-8")
310
+            if result.startswith("msg ok"):
311
+                os.remove("out/" + nodes[node]["nodename"] + "/%s" % msg)
312
+                n = n + 1
313
+            elif result == "msg big!":
314
+                print("\nERROR: very big message (limit 64K)!")
315
+            elif result == "auth error!":
316
+                print("\nERROR: unknown auth!")
317
+            else:
318
+                print("\nERROR: unknown error!")
319
+        if len(lst) > 0:
320
+            print()
321
+    except:
322
+        print("\nОшибка: не удаётся связаться с нодой.")
323
+
324
+def separate(l, step=40):
325
+    for x in range(0, len(l), step):
326
+        yield l[x:x+step]
327
+
328
+def get_features():
329
+    try:
330
+        r = urllib.request.Request(nodes[node]["node"] + "x/features")
331
+        with urllib.request.urlopen(r) as f:
332
+            features = f.read().decode("utf-8").split("\n")
333
+    except:
334
+        features = []
335
+    return features
336
+
337
+def check_features(features):
338
+    ue = "u/e" in features
339
+    xc = "x/c" in features
340
+    return ue, xc
341
+
342
+def load_counts():
343
+    counts = {}
344
+    if os.path.exists("counts.lst"):
345
+        f = open("counts.lst", "rb")
346
+        counts = pickle.load(f)
347
+        f.close()
348
+    else:
349
+        counts[node] = {}
350
+    if not node in counts:
351
+        counts[node] = {}
352
+    return counts[node]
353
+
354
+def save_counts(counts, remote_counts):
355
+    counts[node] = remote_counts
356
+    f = open("counts.lst", "wb")
357
+    pickle.dump(counts, f)
358
+    f.close()
359
+
360
+def get_remote_counts():
361
+    counts = {}
362
+    echoareas = []
363
+    for echoarea in nodes[node]["echoareas"]:
364
+        if echoarea[0] not in ["favorites", "carbonarea"]:
365
+            echoareas.append(echoarea[0])
366
+    r = urllib.request.Request(nodes[node]["node"] + "x/c/" + "/".join(echoareas))
367
+    with urllib.request.urlopen(r) as f:
368
+        c = f.read().decode("utf-8").split("\n")
369
+    for count in c:
370
+        echoarea = count.split(":")
371
+        if len(echoarea) > 1:
372
+            counts[echoarea[0]] = int(echoarea[1])
373
+    return counts
374
+
375
+def calculate_offset(depth):
376
+    n = False
377
+    offset = 0
378
+    echoareas = []
379
+    for echoarea in nodes[node]["echoareas"]:
380
+        if not echoarea in ["favorites", "carbonarea"]:
381
+            echoareas.append(echoarea[0])
382
+    for echoarea in echoareas:
383
+        if not echoarea in counts[node]:
384
+            n = True
385
+        else:
386
+            if not echoarea in clone and int(remote_counts[echoarea]) - int(counts[node][echoarea]) > offset:
387
+                offset = int(remote_counts[echoarea]) - int(counts[node][echoarea])
388
+    if not n:
389
+        depth = offset
390
+
391
+def get_msg_list(clone, ue, depth):
392
+    msg_list = []
393
+    fetch_echoareas = []
394
+    echoareas = []
395
+    for echoarea in nodes[node]["echoareas"]:
396
+        if not echoarea[0] in ["favorites", "carbonarea"]:
397
+            echoareas.append(echoarea[0])
398
+    if ue:
399
+        for echoarea in echoareas:
400
+            if not echoarea in clone and (not echoarea in counts[node] or int(counts[node][echoarea]) < int(remote_counts[echoarea])):
401
+                fetch_echoareas.append(echoarea)
402
+    else:
403
+        clone = echoareas
404
+    if len(clone) > 0:
405
+        r = urllib.request.Request(nodes[node]["node"] + "u/e/" + "/".join(clone))
406
+        with urllib.request.urlopen(r) as f:
407
+            lines = f.read().decode("utf-8").split("\n")
408
+            for line in lines:
409
+                if len(line) > 0:
410
+                    msg_list.append(line)
411
+    if len(fetch_echoareas) > 0 and int(depth) > 0:
412
+        r = urllib.request.Request(nodes[node]["node"] + "u/e/" + "/".join(fetch_echoareas) + "/-%s:%s" %(depth, depth))
413
+        with urllib.request.urlopen(r) as f:
414
+            lines = f.read().decode("utf-8").split("\n")
415
+            for line in lines:
416
+                if len(line) > 0:
417
+                    msg_list.append(line)
418
+    return msg_list
419
+
420
+def get_bundle(node, msgids):
421
+    bundle = []
422
+    try:
423
+        r = urllib.request.Request(node + "u/m/" + msgids)
424
+        with urllib.request.urlopen(r) as f:
425
+            bundle = f.read().decode("utf-8").split("\n")
426
+    except:
427
+        None
428
+    return bundle
429
+
430
+def debundle(bundle):
431
+    global messages
432
+    for msg in bundle:
433
+        if msg:
434
+            m = msg.split(":")
435
+            msgid = m[0]
436
+            if len(msgid) == 20 and m[1]:
437
+                msgbody = base64.b64decode(m[1].encode("ascii")).decode("utf8").split("\n")
438
+                messages.append([msgid, msgbody])
439
+                
440
+    if len(messages) >= 1000:
441
+        save_message(messages, nodes[node]["node"], nodes[node]["to"])
442
+        messages = []
443
+
444
+def echo_filter(ea):
445
+    rr = re.compile(r'^[a-z0-9_!.-]{1,60}\.[a-z0-9_!.-]{1,60}$')
446
+    if rr.match(ea): return True
447
+
448
+def get_mail(clone, ue, depth):
449
+    fetch_msg_list = []
450
+    print("Получение индекса от ноды...")
451
+    remote_msg_list = get_msg_list(clone, ue, depth)
452
+    print("Построение разностного индекса...")
453
+    for line in remote_msg_list:
454
+        if echo_filter(line):
455
+            if line in clone and ue:
456
+                remove_echoarea(line)
457
+            local_index = get_echo_msgids(line)
458
+        else:
459
+            if not line in local_index:
460
+                fetch_msg_list.append(line)
461
+    msg_list_len = str(len(fetch_msg_list))
462
+    if len(fetch_msg_list) > 0:
463
+        count = 0
464
+        for get_list in separate(fetch_msg_list):
465
+            count = count + len(get_list)
466
+            print("\rПолучение сообщений: " + str(count) + "/"  + msg_list_len, end="")
467
+            debundle(get_bundle(nodes[node]["node"], "/".join(get_list)))
468
+        save_message(messages, node, nodes[node]["to"])
469
+    else:
470
+        print("Новых сообщений не обнаружено.", end="")
471
+    print()
472
+
473
+def mailer(clone):
474
+    print("Работа с " + nodes[node]["node"])
475
+    if nodes[node]["auth"]:
476
+        make_toss()
477
+        send_mail()
478
+        print("Получение списка возможностей ноды...")
479
+        features = get_features()
480
+        ue, xc = check_features(features)
481
+        if xc:
482
+            counts = load_counts()
483
+            print("Получение количества сообщений в конференциях...")
484
+            remote_counts = get_remote_counts()
485
+            calculate_offset(depth)
486
+    get_mail(clone, ue, depth)
487
+    if xc:
488
+        save_counts(counts, remote_counts)
489
+    input("Нажмите Enter для продолжения.")
490
+
284 491
 #
285 492
 # Пользовательский интерфейс
286 493
 #
@@ -500,23 +707,8 @@ def fetch_mail():
500 707
     for echoarea in nodes[node]["echoareas"][2:]:
501 708
         if not echoarea[2]:
502 709
             echoareas.append(echoarea[0])
503
-    if len(nodes[node]["clone"]) > 0:
504
-        cmd = clone_cmd.replace("%nodename", nodes[node]["nodename"]).replace("%node", nodes[node]["node"]).replace("%echoareas", ",".join(echoareas)).replace("%clone", ",".join(nodes[node]["clone"])).replace("%db", d)
505
-        if to:
506
-            cmd = cmd.replace("%to", to)
507
-        nodes[node]["clone"] = []
508
-    else:
509
-        cmd = fetch_cmd.replace("%nodename", nodes[node]["nodename"]).replace("%node", nodes[node]["node"]).replace("%echoareas", ",".join(echoareas)).replace("%db", d)
510
-        if "auth" in nodes[node]:
511
-            cmd = cmd.replace("%auth", nodes[node]["auth"])
512
-        else:
513
-            cmd = cmd.replace("-a %auth", "")
514
-        if to:
515
-            cmd = cmd.replace("%to", to)
516
-    if not "auth" in nodes[node]:
517
-        cmd = cmd.replace(" -a %auth", "")
518
-    p = subprocess.Popen(cmd, shell=True)
519
-    p.wait()
710
+    mailer(nodes[node]["clone"])
711
+    nodes[node]["clone"] = []
520 712
     stdscr = curses.initscr()
521 713
     curses.start_color()
522 714
     curses.noecho()
@@ -531,21 +723,6 @@ def load_lasts():
531 723
         lasts = pickle.load(f)
532 724
         f.close()
533 725
 
534
-def send_mail():
535
-    curses.echo()
536
-    curses.curs_set(True)
537
-    curses.endwin()
538
-    os.system('cls' if os.name == 'nt' else 'clear')
539
-    cmd = send_cmd.replace("%nodename", nodes[node]["nodename"]).replace("%node", nodes[node]["node"]).replace("%auth", nodes[node]["auth"])
540
-    p = subprocess.Popen(cmd, shell=True)
541
-    p.wait()
542
-    stdscr = curses.initscr()
543
-    curses.start_color()
544
-    curses.noecho()
545
-    curses.curs_set(False)
546
-    stdscr.keypad(True)
547
-    get_term_size()
548
-
549 726
 def edit_config(out = False):
550 727
     curses.echo()
551 728
     curses.curs_set(True)

+ 0 - 347
mailer.py

@@ -1,347 +0,0 @@
1
-#!/usr/bin/env python3
2
-
3
-import urllib.request, base64, codecs, re, os, sys, pickle
4
-
5
-clone = []
6
-counts = {}
7
-remote_counts = {}
8
-full = False
9
-h = False
10
-features = []
11
-ue = False
12
-xc = False
13
-to = False
14
-depth = "200"
15
-auth = False
16
-db = 0
17
-fetchonly = False
18
-sendonly = False
19
-
20
-messages = []
21
-
22
-def load_config():
23
-    node = ""
24
-    depth = "200"
25
-    echoareas = []
26
-    nodename = "unknown"
27
-    f = open(config, "r").read().split("\n")
28
-    for line in f:
29
-        param = line.split(" ")
30
-        if param[0] == "node":
31
-            node = param[1]
32
-        elif param[0] == "nodename":
33
-            nodename = param[1:]
34
-        elif param[0] == "auth":
35
-            auth = param[1]
36
-        elif param[0] == "depth":
37
-            depth = param[1]
38
-        elif param[0] == "echo":
39
-            echoareas.append(param[1])
40
-        elif param[0] == "db":
41
-            db = param[1]
42
-        elif param[0] == "oldmode":
43
-            full = True
44
-        elif param[0] == "to":
45
-            to = param[1].split(",")
46
-        elif param[0] == "fetchonly":
47
-            fetchonly = True
48
-        elif param[0] == "sendonly":
49
-            sendonly = True
50
-    return node, nodename, auth, depth, echoareas, db, oldmode, to, fetchonly, sendonly
51
-
52
-def check_directories():
53
-    if not os.path.exists("out"):
54
-        os.mkdir("out")
55
-    if not fetchonly and not os.path.exists("out/" + nodename):
56
-        os.mkdir("out/" + nodename)
57
-    if db == 0:
58
-        if not os.path.exists("echo"):
59
-            os.mkdir("echo")
60
-        if not os.path.exists("msg"):
61
-            os.mkdir("msg")
62
-        if not os.path.exists("echo/favorites"):
63
-            open("echo/favorites", "w")
64
-        if not os.path.exists("echo/carbonarea"):
65
-            open("echo/carbonarea", "w")
66
-    elif db == 1:
67
-        if not os.path.exists("aio"):
68
-            os.mkdir("aio")
69
-    elif db == 2:
70
-        if not os.path.exists("ait"):
71
-            os.mkdir("ait")
72
-
73
-def make_toss():
74
-    lst = [x for x in os.listdir("out/" + nodename) if x.endswith(".out")]
75
-    for msg in lst:
76
-        text = codecs.open("out/" + nodename + "/%s" % msg, "r", "utf-8").read()
77
-        coded_text = base64.b64encode(text.encode("utf-8"))
78
-        codecs.open("out/" + nodename + "/%s.toss" % msg, "w", "utf-8").write(coded_text.decode("utf-8"))
79
-        os.rename("out/" + nodename + "/%s" % msg, "out/" + nodename + "/%s%s" % (msg, "msg"))
80
-
81
-def send_mail():
82
-    lst = [x for x in sorted(os.listdir("out/" + nodename)) if x.endswith(".toss")]
83
-    max = len(lst)
84
-    n = 1
85
-    try:
86
-        for msg in lst:
87
-            print("\rОтправка сообщения: " + str(n) + "/" + str(max), end="")
88
-            text = codecs.open("out/" + nodename + "/%s" % msg, "r", "utf-8").read()
89
-            data = urllib.parse.urlencode({"tmsg": text,"pauth": auth}).encode("utf-8")
90
-            request = urllib.request.Request(node + "u/point")
91
-            result = urllib.request.urlopen(request, data).read().decode("utf-8")
92
-            if result.startswith("msg ok"):
93
-                os.remove("out/" + nodename + "/%s" % msg)
94
-                n = n + 1
95
-            elif result == "msg big!":
96
-                print("\nERROR: very big message (limit 64K)!")
97
-            elif result == "auth error!":
98
-                print("\nERROR: unknown auth!")
99
-            else:
100
-                print("\nERROR: unknown error!")
101
-        if len(lst) > 0:
102
-            print()
103
-    except:
104
-        print("\nОшибка: не удаётся связаться с нодой.")
105
-
106
-def separate(l, step=40):
107
-    for x in range(0, len(l), step):
108
-        yield l[x:x+step]
109
-
110
-def get_features():
111
-    global features
112
-    try:
113
-        r = urllib.request.Request(node + "x/features")
114
-        with urllib.request.urlopen(r) as f:
115
-            features = f.read().decode("utf-8").split("\n")
116
-    except:
117
-        features = []
118
-
119
-def check_features():
120
-    global ue, xc
121
-    ue = "u/e" in features
122
-    xc = "x/c" in features
123
-
124
-def load_counts():
125
-    global counts
126
-    if os.path.exists("counts.lst"):
127
-        f = open("counts.lst", "rb")
128
-        counts = pickle.load(f)
129
-        f.close()
130
-    else:
131
-        counts[node] = {}
132
-    if not node in counts:
133
-        counts[node] = {}
134
-
135
-def save_counts():
136
-    counts[node] = remote_counts
137
-    f = open("counts.lst", "wb")
138
-    pickle.dump(counts, f)
139
-    f.close()
140
-
141
-def get_remote_counts():
142
-    counts = {}
143
-    r = urllib.request.Request(node + "x/c/" + "/".join(echoareas))
144
-    with urllib.request.urlopen(r) as f:
145
-        c = f.read().decode("utf-8").split("\n")
146
-    for count in c:
147
-        echoarea = count.split(":")
148
-        if len(echoarea) > 1:
149
-            counts[echoarea[0]] = int(echoarea[1])
150
-    return counts
151
-
152
-def calculate_offset():
153
-    global depth
154
-    n = False
155
-    offset = 0
156
-    for echoarea in echoareas:
157
-        if not echoarea in counts[node]:
158
-            n = True
159
-        else:
160
-            if not echoarea in clone and int(remote_counts[echoarea]) - int(counts[node][echoarea]) > offset:
161
-                offset = int(remote_counts[echoarea]) - int(counts[node][echoarea])
162
-    if not n:
163
-        depth = offset
164
-
165
-def get_msg_list():
166
-    global clone
167
-    msg_list = []
168
-    fetch_echoareas = []
169
-    if not full and ue:
170
-        for echoarea in echoareas:
171
-            if not echoarea in clone and (not echoarea in counts[node] or int(counts[node][echoarea]) < int(remote_counts[echoarea])):
172
-                fetch_echoareas.append(echoarea)
173
-    else:
174
-        clone = echoareas
175
-    if len(clone) > 0:
176
-        r = urllib.request.Request(node + "u/e/" + "/".join(clone))
177
-        with urllib.request.urlopen(r) as f:
178
-            lines = f.read().decode("utf-8").split("\n")
179
-            for line in lines:
180
-                if len(line) > 0:
181
-                    msg_list.append(line)
182
-    if len(fetch_echoareas) > 0 and int(depth) > 0:
183
-        r = urllib.request.Request(node + "u/e/" + "/".join(fetch_echoareas) + "/-%s:%s" %(depth, depth))
184
-        with urllib.request.urlopen(r) as f:
185
-            lines = f.read().decode("utf-8").split("\n")
186
-            for line in lines:
187
-                if len(line) > 0:
188
-                    msg_list.append(line)
189
-    return msg_list
190
-
191
-def get_bundle(node, msgids):
192
-    bundle = []
193
-    try:
194
-        r = urllib.request.Request(node + "u/m/" + msgids)
195
-        with urllib.request.urlopen(r) as f:
196
-            bundle = f.read().decode("utf-8").split("\n")
197
-    except:
198
-        None
199
-    return bundle
200
-
201
-def debundle(bundle):
202
-    global messages, counts
203
-    for msg in bundle:
204
-        if msg:
205
-            m = msg.split(":")
206
-            msgid = m[0]
207
-            if len(msgid) == 20 and m[1]:
208
-                msgbody = base64.b64decode(m[1].encode("ascii")).decode("utf8").split("\n")
209
-                messages.append([msgid, msgbody])
210
-                
211
-    if len(messages) >= 1000:
212
-        save_message(messages, node, to)
213
-        messages = []
214
-
215
-def echo_filter(ea):
216
-    rr = re.compile(r'^[a-z0-9_!.-]{1,60}\.[a-z0-9_!.-]{1,60}$')
217
-    if rr.match(ea): return True
218
-
219
-def get_mail():
220
-    fetch_msg_list = []
221
-    print("Получение индекса от ноды...")
222
-    remote_msg_list = get_msg_list()
223
-    print("Построение разностного индекса...")
224
-    for line in remote_msg_list:
225
-        if echo_filter(line):
226
-            if line in clone and ue:
227
-                remove_echoarea(line)
228
-            local_index = get_echo_msgids(line)
229
-        else:
230
-            if not line in local_index:
231
-                fetch_msg_list.append(line)
232
-    msg_list_len = str(len(fetch_msg_list))
233
-    if len(fetch_msg_list) > 0:
234
-        count = 0
235
-        for get_list in separate(fetch_msg_list):
236
-            count = count + len(get_list)
237
-            print("\rПолучение сообщений: " + str(count) + "/"  + msg_list_len, end="")
238
-            debundle(get_bundle(node, "/".join(get_list)))
239
-        save_message(messages, node, to)
240
-    else:
241
-        print("Новых сообщений не обнаружено.", end="")
242
-    print()
243
-
244
-def check_new_echoareas():
245
-    local_base = os.listdir("echo/")
246
-    n = False
247
-    for echoarea in echoareas:
248
-        if not echoarea in local_base:
249
-            n = True
250
-    return n
251
-
252
-def show_help():
253
-    print("Usage: mailer.py [-f filename] [-n node] [-e echoarea1,echoarea2,...] [-d depth] [-c echoarea1,echoarea2,...] [-o] [-to name1,name2...] [-h].")
254
-    print()
255
-    print("  -f filename  load config file. Default idec-fetcher.cfg.")
256
-    print("  -db db type  set database type (txt, aio or ait).")
257
-    print("  -n node      node address.")
258
-    print("  -m nodename  nodename for search .out messages.")
259
-    print("  -a authkey   authkey.")
260
-    print("  -e echoareas echoareas for fetch.")
261
-    print("  -d depth     fetch messages with an offset to a predetermined depth. Default 200.")
262
-    print("  -c echoareas clone echoareas from node.")
263
-    print("  -o           old mode. Get full index from nore.")
264
-    print("  -to names    names for put messages to carbonarea.")
265
-    print("  -fetchonly   fetch messages only.")
266
-    print("  -sendonly    send messages only.")
267
-    print("  -h           this message.")
268
-    print()
269
-    print("If -f not exist, script will load config from current directory with name\nmailer.cfg.")
270
-
271
-args = sys.argv[1:]
272
-
273
-conf = "-f" in args
274
-if conf:
275
-    config = args[args.index("-f") + 1]
276
-else:
277
-    config = "mailer.cfg"
278
-if "-c" in args:
279
-    clone = args[args.index("-c") + 1].split(",")
280
-full = "-o" in args
281
-if "-d" in args:
282
-    depth = args[args.index("-d") + 1]
283
-h = "-h" in args
284
-if "-n" in args:
285
-    node = args[args.index("-n") + 1]
286
-if "-m" in args:
287
-    nodename = args[args.index("-m") + 1]
288
-if "-a" in args:
289
-    auth = args[args.index("-a") + 1]
290
-if "-e" in args:
291
-    echoareas = args[args.index("-e") + 1].split(",")
292
-if "-to" in args:
293
-    to = args[args.index("-to") + 1].split(",")
294
-if "-db" in args:
295
-    db = args[args.index("-db") + 1]
296
-if db == "txt":
297
-    db = 0
298
-elif db == "aio":
299
-    db = 1
300
-elif db == "ait":
301
-    db = 2
302
-elif db == "sqlite":
303
-    db = 3
304
-wait = "-w" in args
305
-if "-fetchonly" in args:
306
-    fetchonly = True
307
-if "-sendonly" in args:
308
-    sendonly = True
309
-
310
-if h:
311
-    show_help()
312
-    quit()
313
-
314
-if not "-n" in args and not "-e" in args and not os.path.exists(config):
315
-    print("Config file not found.")
316
-    quit()
317
-
318
-check_directories()
319
-if (not sendonly and (not "-n" in args or not "-e" in args)) or (not fetchonly and not "-n" in args and not "-a" in args):
320
-    node, nodename, auth, depth, echoareas, db, oldmode, to, fetchonly, sendonly = load_config()
321
-if db == 0:
322
-    from api.txt import *
323
-elif db == 1:
324
-    from api.aio import *
325
-elif db == 2:
326
-    from api.ait import *
327
-elif db == 3:
328
-    from api.sqlite import *
329
-print("Работа с " + node)
330
-if auth and not fetchonly:
331
-    make_toss()
332
-    send_mail()
333
-if not sendonly:
334
-    print("Получение списка возможностей ноды...")
335
-    get_features()
336
-    check_features()
337
-    if xc:
338
-        load_counts()
339
-        print("Получение количества сообщений в конференциях...")
340
-        remote_counts = get_remote_counts()
341
-        calculate_offset()
342
-    get_mail()
343
-    if xc:
344
-        save_counts()
345
-if wait:
346
-    input("Нажмите Enter для продолжения.")
347
-    print()