Przeglądaj źródła

fix bugs in atheme2json.py

tags/v2.5.0-rc1
Shivaram Lingamneni 3 lat temu
rodzic
commit
31003bd02d
1 zmienionych plików z 11 dodań i 8 usunięć
  1. 11
    8
      distrib/atheme/atheme2json.py

+ 11
- 8
distrib/atheme/atheme2json.py Wyświetl plik

@@ -6,7 +6,7 @@ import re
6 6
 import sys
7 7
 from collections import defaultdict
8 8
 
9
-MASK_MAGIC_REGEX = re.compile(r'[*?!@]')
9
+MASK_MAGIC_REGEX = re.compile(r'[*?!@$]')
10 10
 
11 11
 def to_unixnano(timestamp):
12 12
     return int(timestamp) * (10**9)
@@ -103,8 +103,6 @@ def convert(infile):
103 103
             # channel access lists
104 104
             # CA #mychannel shivaram +AFORafhioqrstv 1600134478 shivaram
105 105
             chname, username, flags, set_at = parts[1], parts[2], parts[3], int(parts[4])
106
-            if MASK_MAGIC_REGEX.search(username):
107
-                continue
108 106
             chname = parts[1]
109 107
             chdata = out['channels'][chname]
110 108
             flags = parts[3]
@@ -130,7 +128,16 @@ def convert(infile):
130 128
                     channel_to_founder[chname] = (username, set_at)
131 129
                 # but multiple people can receive the 'q' amode
132 130
                 chdata['amode'][username] = 'q'
133
-            elif 'q' in flags:
131
+                continue
132
+            if MASK_MAGIC_REGEX.search(username):
133
+                # ignore groups, masks, etc. for any field other than founder
134
+                continue
135
+            # record the first appearing successor, if necessary
136
+            if 'S' in flags:
137
+                if not chdata.get('successor'):
138
+                    chdata['successor'] = username
139
+            # finally, handle amodes
140
+            if 'q' in flags:
134 141
                 chdata['amode'][username] = 'q'
135 142
             elif 'a' in flags:
136 143
                 chdata['amode'][username] = 'a'
@@ -140,10 +147,6 @@ def convert(infile):
140 147
                 chdata['amode'][username] = 'h'
141 148
             elif 'v' in flags or 'V' in flags:
142 149
                 chdata['amode'][username] = 'v'
143
-            elif 'S' in flags:
144
-                # take the first entry as the successor
145
-                if not chdata.get('successor'):
146
-                    chdata['successor'] = username
147 150
         else:
148 151
             pass
149 152
 

Ładowanie…
Anuluj
Zapisz