mirror of
https://github.com/AsgardEternal/DiscordWhitelist.git
synced 2024-12-30 15:19:12 -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
|
.envrc
|
||||||
/test.json
|
/test.json
|
||||||
|
/testwl
|
||||||
|
@ -34,13 +34,22 @@ class Whitelist(commands.Cog):
|
|||||||
if role.id == self.client.whitelist[group].discord_role_id:
|
if role.id == self.client.whitelist[group].discord_role_id:
|
||||||
steam64_updated = True
|
steam64_updated = True
|
||||||
self.client.whitelist[group].members[
|
self.client.whitelist[group].members[
|
||||||
interaction.user.id
|
str(interaction.user.id)
|
||||||
] = config.WhitelistMember(interaction.user.name, steam64)
|
] = config.WhitelistMember(interaction.user.name, steam64)
|
||||||
|
|
||||||
if steam64_updated:
|
if steam64_updated:
|
||||||
outFile = open("test.json", "w")
|
outFile = open("test.json", "w")
|
||||||
outFile.write(jsonpickle.encode(self.client.whitelist, unpicklable=False))
|
outFile.write(jsonpickle.encode(self.client.whitelist))
|
||||||
outFile.close()
|
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(
|
log.info(
|
||||||
f"Updated {interaction.user.name}'s ({interaction.user.id}) whitelist steam64 to {steam64}"
|
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):
|
class Bot(commands.Bot):
|
||||||
whitelist = config.Whitelist({}).whitelist
|
whitelist = config.Whitelist({}).whitelist
|
||||||
|
|
||||||
infile = open("test.json", "r")
|
try:
|
||||||
if infile:
|
infile = open("test.json", "r")
|
||||||
whitelist = jsonpickle.decode(infile.read())
|
if infile:
|
||||||
infile.close()
|
whitelist = jsonpickle.decode(infile.read())
|
||||||
|
infile.close()
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
def __init__(self, config: config.DiscordClientConfig):
|
def __init__(self, config: config.DiscordClientConfig):
|
||||||
self.config = config
|
self.config = config
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class DiscordClientConfig:
|
class DiscordClientConfig:
|
||||||
login_token: str
|
login_token: str
|
||||||
|
Loading…
Reference in New Issue
Block a user