mirror of
https://github.com/AsgardEternal/DiscordWhitelist.git
synced 2024-12-28 22:29:13 -06:00
output Squad whitelist file
This commit is contained in:
parent
6f05fcb5ee
commit
ef315a70e1
1
.gitignore
vendored
1
.gitignore
vendored
@ -133,3 +133,4 @@ dmypy.json
|
||||
|
||||
.envrc
|
||||
/test.json
|
||||
/testwl
|
||||
|
@ -34,13 +34,22 @@ class Whitelist(commands.Cog):
|
||||
if role.id == self.client.whitelist[group].discord_role_id:
|
||||
steam64_updated = True
|
||||
self.client.whitelist[group].members[
|
||||
interaction.user.id
|
||||
str(interaction.user.id)
|
||||
] = config.WhitelistMember(interaction.user.name, steam64)
|
||||
|
||||
if steam64_updated:
|
||||
outFile = open("test.json", "w")
|
||||
outFile.write(jsonpickle.encode(self.client.whitelist, unpicklable=False))
|
||||
outFile.write(jsonpickle.encode(self.client.whitelist))
|
||||
outFile.close()
|
||||
wlFile = open("testwl", "w")
|
||||
for wlgrp in self.client.whitelist:
|
||||
wlFile.write(f"Group={wlgrp}:reserve\n")
|
||||
for wlgrp in self.client.whitelist:
|
||||
wlFile.write("\n")
|
||||
wlFile.write(f"//{wlgrp}\n")
|
||||
for wlmem in self.client.whitelist[wlgrp].members:
|
||||
wlFile.write(f"Admin={self.client.whitelist[wlgrp].members[wlmem].steam64}:{wlgrp} //{self.client.whitelist[wlgrp].members[wlmem].discord_username} ({wlmem})\n")
|
||||
wlFile.close()
|
||||
log.info(
|
||||
f"Updated {interaction.user.name}'s ({interaction.user.id}) whitelist steam64 to {steam64}"
|
||||
)
|
||||
|
@ -10,10 +10,13 @@ log = logging.getLogger(__name__)
|
||||
class Bot(commands.Bot):
|
||||
whitelist = config.Whitelist({}).whitelist
|
||||
|
||||
infile = open("test.json", "r")
|
||||
if infile:
|
||||
whitelist = jsonpickle.decode(infile.read())
|
||||
infile.close()
|
||||
try:
|
||||
infile = open("test.json", "r")
|
||||
if infile:
|
||||
whitelist = jsonpickle.decode(infile.read())
|
||||
infile.close()
|
||||
except:
|
||||
pass
|
||||
|
||||
def __init__(self, config: config.DiscordClientConfig):
|
||||
self.config = config
|
||||
|
@ -1,6 +1,5 @@
|
||||
from dataclasses import dataclass
|
||||
|
||||
|
||||
@dataclass
|
||||
class DiscordClientConfig:
|
||||
login_token: str
|
||||
|
Loading…
Reference in New Issue
Block a user