mirror of
https://github.com/AsgardEternal/DiscordWhitelist.git
synced 2024-12-28 22:29:13 -06:00
dump and init whitelist with a json file.
ADDED DEP: jsonpickle
This commit is contained in:
parent
1d0efc3c85
commit
6f05fcb5ee
1
.gitignore
vendored
1
.gitignore
vendored
@ -132,3 +132,4 @@ dmypy.json
|
||||
.idea/
|
||||
|
||||
.envrc
|
||||
/test.json
|
||||
|
@ -1,3 +1,4 @@
|
||||
import jsonpickle
|
||||
import discord
|
||||
import logging
|
||||
from autowl import config
|
||||
@ -37,6 +38,9 @@ class Whitelist(commands.Cog):
|
||||
] = config.WhitelistMember(interaction.user.name, steam64)
|
||||
|
||||
if steam64_updated:
|
||||
outFile = open("test.json", "w")
|
||||
outFile.write(jsonpickle.encode(self.client.whitelist, unpicklable=False))
|
||||
outFile.close()
|
||||
log.info(
|
||||
f"Updated {interaction.user.name}'s ({interaction.user.id}) whitelist steam64 to {steam64}"
|
||||
)
|
||||
|
@ -1,3 +1,4 @@
|
||||
import jsonpickle
|
||||
import logging
|
||||
import discord
|
||||
from discord.ext import commands
|
||||
@ -9,6 +10,11 @@ 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()
|
||||
|
||||
def __init__(self, config: config.DiscordClientConfig):
|
||||
self.config = config
|
||||
intents = discord.Intents.default()
|
||||
|
21
poetry.lock
generated
21
poetry.lock
generated
@ -1,4 +1,4 @@
|
||||
# This file is automatically @generated by Poetry and should not be changed by hand.
|
||||
# This file is automatically @generated by Poetry 1.4.0 and should not be changed by hand.
|
||||
|
||||
[[package]]
|
||||
name = "aiohttp"
|
||||
@ -287,6 +287,23 @@ files = [
|
||||
{file = "idna-3.4.tar.gz", hash = "sha256:814f528e8dead7d329833b91c5faa87d60bf71824cd12a7530b5526063d02cb4"},
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "jsonpickle"
|
||||
version = "3.0.1"
|
||||
description = "Python library for serializing any arbitrary object graph into JSON"
|
||||
category = "main"
|
||||
optional = false
|
||||
python-versions = ">=3.7"
|
||||
files = [
|
||||
{file = "jsonpickle-3.0.1-py2.py3-none-any.whl", hash = "sha256:130d8b293ea0add3845de311aaba55e6d706d0bb17bc123bd2c8baf8a39ac77c"},
|
||||
{file = "jsonpickle-3.0.1.tar.gz", hash = "sha256:032538804795e73b94ead410800ac387fdb6de98f8882ac957fcd247e3a85200"},
|
||||
]
|
||||
|
||||
[package.extras]
|
||||
docs = ["jaraco.packaging (>=3.2)", "rst.linker (>=1.9)", "sphinx"]
|
||||
testing = ["ecdsa", "feedparser", "gmpy2", "numpy", "pandas", "pymongo", "pytest (>=3.5,!=3.7.3)", "pytest-black-multipy", "pytest-checkdocs (>=1.2.3)", "pytest-cov", "pytest-flake8 (>=1.1.1)", "scikit-learn", "sqlalchemy"]
|
||||
testing-libs = ["simplejson", "ujson"]
|
||||
|
||||
[[package]]
|
||||
name = "multidict"
|
||||
version = "6.0.4"
|
||||
@ -462,4 +479,4 @@ multidict = ">=4.0"
|
||||
[metadata]
|
||||
lock-version = "2.0"
|
||||
python-versions = "^3.10"
|
||||
content-hash = "4150717da98b5eb32609d7670dc1457938d4fff5799126847030c693503f0247"
|
||||
content-hash = "22e27ffb14d002d43920b5647c8fd824ca4487469c5687561af70c02aa8e3cca"
|
||||
|
@ -8,6 +8,7 @@ readme = "README.md"
|
||||
[tool.poetry.dependencies]
|
||||
python = "^3.10"
|
||||
"discord.py" = "^2.1.0"
|
||||
jsonpickle = "^3.0.1"
|
||||
|
||||
|
||||
[build-system]
|
||||
|
Loading…
Reference in New Issue
Block a user