mirror of
https://github.com/TinyTapeout/tt-support-tools.git
synced 2026-11-03 04:36:09 +01:00
handle the new global names
This commit is contained in:
+28
-11
@@ -47,28 +47,45 @@ async def on_ready():
|
|||||||
stream = open(info_file, 'r')
|
stream = open(info_file, 'r')
|
||||||
data = yaml.load(stream, Loader=yaml.FullLoader)
|
data = yaml.load(stream, Loader=yaml.FullLoader)
|
||||||
stream.close()
|
stream.close()
|
||||||
dname = data['documentation']
|
if 'discord' in data['documentation']:
|
||||||
if 'discord' in dname:
|
dname = data['documentation']['discord']
|
||||||
dname = dname['discord']
|
if len(dname):
|
||||||
parts = dname.split('#')
|
if '#' in dname:
|
||||||
if len(parts) != 2 or len(parts[0]) == 0 or not re.match('^[0-9]{4}$', parts[1]):
|
dname = dname.split('#')[0]
|
||||||
print(f'Invalid format for discord username {dname} in project {project}. Skipping.')
|
# print(f'adding {dname}')
|
||||||
else:
|
participants.append(dname)
|
||||||
participants.append({'name': parts[0], 'discriminator': parts[1]})
|
|
||||||
else:
|
else:
|
||||||
print(f'Project {project} has no discord username listed. Skipping.')
|
print(f'Project {project} has no discord username listed. Skipping.')
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
print(f'Error parsing info.yaml for project {project}. Skipping.')
|
print(f'Error parsing info.yaml for project {project}. Skipping.')
|
||||||
print(f'Error was: {ex}')
|
print(f'Error was: {ex}')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
members = []
|
||||||
|
for p in participants:
|
||||||
for m in server.members:
|
for m in server.members:
|
||||||
a = [d for d in participants if d['name'] == m.name and d['discriminator'] == m.discriminator]
|
if m.name == p:
|
||||||
if len(a) != 0:
|
members.append(m)
|
||||||
|
break
|
||||||
|
if m.global_name == p:
|
||||||
|
members.append(m)
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
print(f'{p} not found in members')
|
||||||
|
|
||||||
|
new_role_members = []
|
||||||
|
for m in members:
|
||||||
if len([d for d in m.roles if d.id == role.id]) == 0:
|
if len([d for d in m.roles if d.id == role.id]) == 0:
|
||||||
print(f'Giving the role to {m.name}#{m.discriminator}')
|
print(f'Giving the role to {m.name}')
|
||||||
|
new_role_members.append(m.name)
|
||||||
await m.add_roles(role, reason='Automatic role assignment by GitHub actions pipeline.')
|
await m.add_roles(role, reason='Automatic role assignment by GitHub actions pipeline.')
|
||||||
|
else:
|
||||||
|
print(f'{m.name} already has role')
|
||||||
|
|
||||||
print('All done!')
|
print('All done!')
|
||||||
|
print("gave new role to:")
|
||||||
|
print('@' + ' @'.join(new_role_members))
|
||||||
await client.close()
|
await client.close()
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
print('Exception was thrown!')
|
print('Exception was thrown!')
|
||||||
|
|||||||
Reference in New Issue
Block a user