mirror of
https://github.com/AsgardEternal/DiscordWhitelist.git
synced 2024-12-30 15:19:12 -06:00
ability to use remote admins
This commit is contained in:
parent
26f71f8fc8
commit
e02153b7b6
@ -1,3 +1,5 @@
|
|||||||
|
import os.path
|
||||||
|
|
||||||
import discord
|
import discord
|
||||||
import random
|
import random
|
||||||
import logging
|
import logging
|
||||||
@ -64,6 +66,24 @@ class Group(commands.Cog, name="group"):
|
|||||||
):
|
):
|
||||||
await self.baseperm(interaction, role, perms)
|
await self.baseperm(interaction, role, perms)
|
||||||
|
|
||||||
|
@app_commands.command()
|
||||||
|
async def addremote(
|
||||||
|
self,
|
||||||
|
interaction: discord.Interaction,
|
||||||
|
shortname: str,
|
||||||
|
remoteURL: str,
|
||||||
|
perms: str = 'whitelist'
|
||||||
|
):
|
||||||
|
if os.path.exists(f"wlgrps/{shortname}.cfg"):
|
||||||
|
await interaction.response.send_message("Already exists!")
|
||||||
|
return
|
||||||
|
else:
|
||||||
|
outfile = open(f"./wlgrps/{shortname}.cfg", "w")
|
||||||
|
outfile.write(f"remotelist={remoteURL}\n")
|
||||||
|
outfile.write(f"permissions={perms}\n")
|
||||||
|
outfile.close()
|
||||||
|
await interaction.response.send_message("created!")
|
||||||
|
|
||||||
@app_commands.command()
|
@app_commands.command()
|
||||||
async def remove(
|
async def remove(
|
||||||
self,
|
self,
|
||||||
|
66
poetry.lock
generated
66
poetry.lock
generated
@ -1,10 +1,9 @@
|
|||||||
# This file is automatically @generated by Poetry 1.4.0 and should not be changed by hand.
|
# This file is automatically @generated by Poetry 1.5.0 and should not be changed by hand.
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "aiohttp"
|
name = "aiohttp"
|
||||||
version = "3.8.3"
|
version = "3.8.3"
|
||||||
description = "Async http client/server framework (asyncio)"
|
description = "Async http client/server framework (asyncio)"
|
||||||
category = "main"
|
|
||||||
optional = false
|
optional = false
|
||||||
python-versions = ">=3.6"
|
python-versions = ">=3.6"
|
||||||
files = [
|
files = [
|
||||||
@ -113,7 +112,6 @@ speedups = ["Brotli", "aiodns", "cchardet"]
|
|||||||
name = "aiosignal"
|
name = "aiosignal"
|
||||||
version = "1.3.1"
|
version = "1.3.1"
|
||||||
description = "aiosignal: a list of registered asynchronous callbacks"
|
description = "aiosignal: a list of registered asynchronous callbacks"
|
||||||
category = "main"
|
|
||||||
optional = false
|
optional = false
|
||||||
python-versions = ">=3.7"
|
python-versions = ">=3.7"
|
||||||
files = [
|
files = [
|
||||||
@ -128,7 +126,6 @@ frozenlist = ">=1.1.0"
|
|||||||
name = "async-timeout"
|
name = "async-timeout"
|
||||||
version = "4.0.2"
|
version = "4.0.2"
|
||||||
description = "Timeout context manager for asyncio programs"
|
description = "Timeout context manager for asyncio programs"
|
||||||
category = "main"
|
|
||||||
optional = false
|
optional = false
|
||||||
python-versions = ">=3.6"
|
python-versions = ">=3.6"
|
||||||
files = [
|
files = [
|
||||||
@ -140,7 +137,6 @@ files = [
|
|||||||
name = "attrs"
|
name = "attrs"
|
||||||
version = "22.2.0"
|
version = "22.2.0"
|
||||||
description = "Classes Without Boilerplate"
|
description = "Classes Without Boilerplate"
|
||||||
category = "main"
|
|
||||||
optional = false
|
optional = false
|
||||||
python-versions = ">=3.6"
|
python-versions = ">=3.6"
|
||||||
files = [
|
files = [
|
||||||
@ -155,11 +151,21 @@ docs = ["furo", "myst-parser", "sphinx", "sphinx-notfound-page", "sphinxcontrib-
|
|||||||
tests = ["attrs[tests-no-zope]", "zope.interface"]
|
tests = ["attrs[tests-no-zope]", "zope.interface"]
|
||||||
tests-no-zope = ["cloudpickle", "cloudpickle", "hypothesis", "hypothesis", "mypy (>=0.971,<0.990)", "mypy (>=0.971,<0.990)", "pympler", "pympler", "pytest (>=4.3.0)", "pytest (>=4.3.0)", "pytest-mypy-plugins", "pytest-mypy-plugins", "pytest-xdist[psutil]", "pytest-xdist[psutil]"]
|
tests-no-zope = ["cloudpickle", "cloudpickle", "hypothesis", "hypothesis", "mypy (>=0.971,<0.990)", "mypy (>=0.971,<0.990)", "pympler", "pympler", "pytest (>=4.3.0)", "pytest (>=4.3.0)", "pytest-mypy-plugins", "pytest-mypy-plugins", "pytest-xdist[psutil]", "pytest-xdist[psutil]"]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "certifi"
|
||||||
|
version = "2023.7.22"
|
||||||
|
description = "Python package for providing Mozilla's CA Bundle."
|
||||||
|
optional = false
|
||||||
|
python-versions = ">=3.6"
|
||||||
|
files = [
|
||||||
|
{file = "certifi-2023.7.22-py3-none-any.whl", hash = "sha256:92d6037539857d8206b8f6ae472e8b77db8058fec5937a1ef3f54304089edbb9"},
|
||||||
|
{file = "certifi-2023.7.22.tar.gz", hash = "sha256:539cc1d13202e33ca466e88b2807e29f4c13049d6d87031a3c110744495cb082"},
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "charset-normalizer"
|
name = "charset-normalizer"
|
||||||
version = "2.1.1"
|
version = "2.1.1"
|
||||||
description = "The Real First Universal Charset Detector. Open, modern and actively maintained alternative to Chardet."
|
description = "The Real First Universal Charset Detector. Open, modern and actively maintained alternative to Chardet."
|
||||||
category = "main"
|
|
||||||
optional = false
|
optional = false
|
||||||
python-versions = ">=3.6.0"
|
python-versions = ">=3.6.0"
|
||||||
files = [
|
files = [
|
||||||
@ -174,7 +180,6 @@ unicode-backport = ["unicodedata2"]
|
|||||||
name = "discord-py"
|
name = "discord-py"
|
||||||
version = "2.1.0"
|
version = "2.1.0"
|
||||||
description = "A Python wrapper for the Discord API"
|
description = "A Python wrapper for the Discord API"
|
||||||
category = "main"
|
|
||||||
optional = false
|
optional = false
|
||||||
python-versions = ">=3.8.0"
|
python-versions = ">=3.8.0"
|
||||||
files = [
|
files = [
|
||||||
@ -195,7 +200,6 @@ voice = ["PyNaCl (>=1.3.0,<1.6)"]
|
|||||||
name = "frozenlist"
|
name = "frozenlist"
|
||||||
version = "1.3.3"
|
version = "1.3.3"
|
||||||
description = "A list-like structure which implements collections.abc.MutableSequence"
|
description = "A list-like structure which implements collections.abc.MutableSequence"
|
||||||
category = "main"
|
|
||||||
optional = false
|
optional = false
|
||||||
python-versions = ">=3.7"
|
python-versions = ">=3.7"
|
||||||
files = [
|
files = [
|
||||||
@ -279,7 +283,6 @@ files = [
|
|||||||
name = "idna"
|
name = "idna"
|
||||||
version = "3.4"
|
version = "3.4"
|
||||||
description = "Internationalized Domain Names in Applications (IDNA)"
|
description = "Internationalized Domain Names in Applications (IDNA)"
|
||||||
category = "main"
|
|
||||||
optional = false
|
optional = false
|
||||||
python-versions = ">=3.5"
|
python-versions = ">=3.5"
|
||||||
files = [
|
files = [
|
||||||
@ -291,7 +294,6 @@ files = [
|
|||||||
name = "jsonpickle"
|
name = "jsonpickle"
|
||||||
version = "3.0.1"
|
version = "3.0.1"
|
||||||
description = "Python library for serializing any arbitrary object graph into JSON"
|
description = "Python library for serializing any arbitrary object graph into JSON"
|
||||||
category = "main"
|
|
||||||
optional = false
|
optional = false
|
||||||
python-versions = ">=3.7"
|
python-versions = ">=3.7"
|
||||||
files = [
|
files = [
|
||||||
@ -308,7 +310,6 @@ testing-libs = ["simplejson", "ujson"]
|
|||||||
name = "multidict"
|
name = "multidict"
|
||||||
version = "6.0.4"
|
version = "6.0.4"
|
||||||
description = "multidict implementation"
|
description = "multidict implementation"
|
||||||
category = "main"
|
|
||||||
optional = false
|
optional = false
|
||||||
python-versions = ">=3.7"
|
python-versions = ">=3.7"
|
||||||
files = [
|
files = [
|
||||||
@ -392,7 +393,6 @@ files = [
|
|||||||
name = "mysql-connector-python"
|
name = "mysql-connector-python"
|
||||||
version = "8.0.32"
|
version = "8.0.32"
|
||||||
description = "MySQL driver written in Python"
|
description = "MySQL driver written in Python"
|
||||||
category = "main"
|
|
||||||
optional = false
|
optional = false
|
||||||
python-versions = "*"
|
python-versions = "*"
|
||||||
files = [
|
files = [
|
||||||
@ -435,7 +435,6 @@ gssapi = ["gssapi (>=1.6.9,<=1.8.2)"]
|
|||||||
name = "protobuf"
|
name = "protobuf"
|
||||||
version = "3.20.3"
|
version = "3.20.3"
|
||||||
description = "Protocol Buffers"
|
description = "Protocol Buffers"
|
||||||
category = "main"
|
|
||||||
optional = false
|
optional = false
|
||||||
python-versions = ">=3.7"
|
python-versions = ">=3.7"
|
||||||
files = [
|
files = [
|
||||||
@ -463,11 +462,48 @@ files = [
|
|||||||
{file = "protobuf-3.20.3.tar.gz", hash = "sha256:2e3427429c9cffebf259491be0af70189607f365c2f41c7c3764af6f337105f2"},
|
{file = "protobuf-3.20.3.tar.gz", hash = "sha256:2e3427429c9cffebf259491be0af70189607f365c2f41c7c3764af6f337105f2"},
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "requests"
|
||||||
|
version = "2.31.0"
|
||||||
|
description = "Python HTTP for Humans."
|
||||||
|
optional = false
|
||||||
|
python-versions = ">=3.7"
|
||||||
|
files = [
|
||||||
|
{file = "requests-2.31.0-py3-none-any.whl", hash = "sha256:58cd2187c01e70e6e26505bca751777aa9f2ee0b7f4300988b709f44e013003f"},
|
||||||
|
{file = "requests-2.31.0.tar.gz", hash = "sha256:942c5a758f98d790eaed1a29cb6eefc7ffb0d1cf7af05c3d2791656dbd6ad1e1"},
|
||||||
|
]
|
||||||
|
|
||||||
|
[package.dependencies]
|
||||||
|
certifi = ">=2017.4.17"
|
||||||
|
charset-normalizer = ">=2,<4"
|
||||||
|
idna = ">=2.5,<4"
|
||||||
|
urllib3 = ">=1.21.1,<3"
|
||||||
|
|
||||||
|
[package.extras]
|
||||||
|
socks = ["PySocks (>=1.5.6,!=1.5.7)"]
|
||||||
|
use-chardet-on-py3 = ["chardet (>=3.0.2,<6)"]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "urllib3"
|
||||||
|
version = "2.0.4"
|
||||||
|
description = "HTTP library with thread-safe connection pooling, file post, and more."
|
||||||
|
optional = false
|
||||||
|
python-versions = ">=3.7"
|
||||||
|
files = [
|
||||||
|
{file = "urllib3-2.0.4-py3-none-any.whl", hash = "sha256:de7df1803967d2c2a98e4b11bb7d6bd9210474c46e8a0401514e3a42a75ebde4"},
|
||||||
|
{file = "urllib3-2.0.4.tar.gz", hash = "sha256:8d22f86aae8ef5e410d4f539fde9ce6b2113a001bb4d189e0aed70642d602b11"},
|
||||||
|
]
|
||||||
|
|
||||||
|
[package.extras]
|
||||||
|
brotli = ["brotli (>=1.0.9)", "brotlicffi (>=0.8.0)"]
|
||||||
|
secure = ["certifi", "cryptography (>=1.9)", "idna (>=2.0.0)", "pyopenssl (>=17.1.0)", "urllib3-secure-extra"]
|
||||||
|
socks = ["pysocks (>=1.5.6,!=1.5.7,<2.0)"]
|
||||||
|
zstd = ["zstandard (>=0.18.0)"]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "yarl"
|
name = "yarl"
|
||||||
version = "1.8.2"
|
version = "1.8.2"
|
||||||
description = "Yet another URL library"
|
description = "Yet another URL library"
|
||||||
category = "main"
|
|
||||||
optional = false
|
optional = false
|
||||||
python-versions = ">=3.7"
|
python-versions = ">=3.7"
|
||||||
files = [
|
files = [
|
||||||
@ -554,4 +590,4 @@ multidict = ">=4.0"
|
|||||||
[metadata]
|
[metadata]
|
||||||
lock-version = "2.0"
|
lock-version = "2.0"
|
||||||
python-versions = "^3.10"
|
python-versions = "^3.10"
|
||||||
content-hash = "657a426f0ae90149e993e58c29cf306637e5be673688d0234db90915e46e5d18"
|
content-hash = "b229771a7e4a57a69fcf1af09b6cabcb918748e74eb4ff4922bbd943e73b15ea"
|
||||||
|
@ -10,6 +10,7 @@ python = "^3.10"
|
|||||||
"discord.py" = "^2.1.0"
|
"discord.py" = "^2.1.0"
|
||||||
jsonpickle = "^3.0.1"
|
jsonpickle = "^3.0.1"
|
||||||
mysql-connector-python = "^8.0.32"
|
mysql-connector-python = "^8.0.32"
|
||||||
|
requests = "^2.31.0"
|
||||||
|
|
||||||
|
|
||||||
[build-system]
|
[build-system]
|
||||||
|
@ -1,10 +1,15 @@
|
|||||||
import http.server
|
import http.server
|
||||||
import os
|
import os
|
||||||
|
import re
|
||||||
import socketserver
|
import socketserver
|
||||||
|
import traceback
|
||||||
|
import urllib.request
|
||||||
from urllib.parse import urlparse
|
from urllib.parse import urlparse
|
||||||
from urllib.parse import parse_qs
|
from urllib.parse import parse_qs
|
||||||
from sys import stderr
|
from sys import stderr
|
||||||
|
|
||||||
|
import requests
|
||||||
|
|
||||||
PORT = 8000
|
PORT = 8000
|
||||||
|
|
||||||
|
|
||||||
@ -26,10 +31,24 @@ class serveRA(http.server.SimpleHTTPRequestHandler):
|
|||||||
return
|
return
|
||||||
try:
|
try:
|
||||||
file = open(grpfile, 'rb')
|
file = open(grpfile, 'rb')
|
||||||
self.copyfile(file, self.wfile)
|
firstline = file.readline().decode('utf-8')
|
||||||
|
if firstline.startswith('remotelist='):
|
||||||
|
remote = firstline.split('=')[1].strip()
|
||||||
|
response = requests.get(remote, headers={'Accept': 'text/html,*/*'})
|
||||||
|
responsetext = response.text
|
||||||
|
config = file.read().decode('utf-8')
|
||||||
|
confgrps = re.findall(r"^permissions/(.+)=(.+)", config, flags=re.M)
|
||||||
|
baseperm = re.match(r"^permissions=(.+)", config, flags=re.M)
|
||||||
|
responsetext = re.sub(r"^Group=(.+):(.+)", fr'Group=\1:{baseperm[0]}', responsetext, flags=re.M)
|
||||||
|
for congrp in confgrps:
|
||||||
|
responsetext = re.sub(rf"^Group=({congrp[0]}):(.+)", rf"Group=\1:{congrp[1]}", responsetext, flags=re.M)
|
||||||
|
self.wfile.write(responsetext.encode('utf-8'))
|
||||||
|
else:
|
||||||
|
self.copyfile(file, self.wfile)
|
||||||
file.close()
|
file.close()
|
||||||
except:
|
except:
|
||||||
print('failed to open file!', file=stderr)
|
print('failed to open file!', file=stderr)
|
||||||
|
print(traceback.format_exc())
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user