ソースを参照

give all groupserv founders +q in atheme2json

tags/v2.5.0-rc1
Shivaram Lingamneni 3年前
コミット
579924c832
1個のファイルの変更19行の追加23行の削除
  1. 19
    23
      distrib/atheme/atheme2json.py

+ 19
- 23
distrib/atheme/atheme2json.py ファイルの表示

@@ -27,11 +27,7 @@ def convert(infile):
27 27
         'channels': defaultdict(dict),
28 28
     }
29 29
 
30
-    # Translate channels owned by groups to being owned by the first founder of that group
31
-    # Otherwise the code crashes on networks using atheme's GroupServ
32
-    # Note: all group definitions precede channel access entries (token CA) by design, so it
33
-    # should be safe to read this in using one pass.
34
-    groups_to_user = {}
30
+    group_to_founders = defaultdict(list)
35 31
 
36 32
     channel_to_founder = defaultdict(lambda: (None, None))
37 33
 
@@ -39,15 +35,16 @@ def convert(infile):
39 35
         line = line.rstrip('\r\n')
40 36
         parts = line.split(' ')
41 37
         category = parts[0]
38
+
42 39
         if category == 'GACL':
40
+            # Note: all group definitions precede channel access entries (token CA) by design, so it
41
+            # should be safe to read this in using one pass.
43 42
             groupname = parts[1]
44 43
             user = parts[2]
45 44
             flags = parts[3]
46
-            # Pick the first founder
47
-            if groupname not in groups_to_user and 'F' in flags:
48
-                groups_to_user[groupname] = user
49
-
50
-        if category == 'MU':
45
+            if 'F' in flags:
46
+                group_to_founders[groupname].append(user)
47
+        elif category == 'MU':
51 48
             # user account
52 49
             # MU AAAAAAAAB shivaram $1$hcspif$nCm4r3S14Me9ifsOPGuJT. user@example.com 1600134392 1600467343 +sC default
53 50
             name = parts[2]
@@ -60,9 +57,7 @@ def convert(infile):
60 57
             username, groupednick = parts[1], parts[2]
61 58
             if username != groupednick:
62 59
                 user = out['users'][username]
63
-                if 'additionalNicks' not in user:
64
-                    user['additionalNicks'] = []
65
-                user['additionalNicks'].append(groupednick)
60
+                user.setdefault('additionalnicks', []).append(groupednick)
66 61
         elif category == 'MDU':
67 62
             if parts[2] == 'private:usercloak':
68 63
                 username = parts[1]
@@ -111,18 +106,19 @@ def convert(infile):
111 106
                 chdata['amode'] = {}
112 107
             # see libathemecore/flags.c: +o is op, +O is autoop, etc.
113 108
             if 'F' in flags:
114
-                # there can only be one founder
115
-                preexisting_founder, preexisting_set_at = channel_to_founder[chname]
116 109
                 # If the username starts with "!", it's actually a GroupServ group.
117 110
                 if username.startswith('!'):
118
-                    try:
119
-                        group_founder = groups_to_user[username]
120
-                        print(f"WARNING: flattening GroupServ group founder {username} on {chname} to first group founder {group_founder}")
121
-                    except KeyError:
122
-                        raise ValueError(f"Got channel {chname} owned by group {username} that has no founder?")
123
-                    else:
124
-                        username = group_founder
125
-
111
+                    group_founders = group_to_founders.get(username)
112
+                    if not group_founders:
113
+                        # skip this and warn about it later
114
+                        continue
115
+                    # attempt to promote the first group founder to channel founder
116
+                    username = group_founders[0]
117
+                    # but everyone gets the +q flag
118
+                    for founder in group_founders:
119
+                        chdata['amode'][founder] = 'q'
120
+                # there can only be one founder
121
+                preexisting_founder, preexisting_set_at = channel_to_founder[chname]
126 122
                 if preexisting_founder is None or set_at < preexisting_set_at:
127 123
                     chdata['founder'] = username
128 124
                     channel_to_founder[chname] = (username, set_at)

読み込み中…
キャンセル
保存