diff --git a/config.toml b/config.toml new file mode 100644 index 0000000..ff1d45d --- /dev/null +++ b/config.toml @@ -0,0 +1,21 @@ +#The config is auto generated in the web interface do not change unless you know what you are doing. + + +[webserver] +#set to false if you dont have a certificate +usessl = true +port = "5000" +#DO NOT USE IN PRODUCTION. Do not even use flask it is recomended to use a production ready wsgi server such as gunicorn +debug = true +#Leave it like this if you dont know what your doing. +ip = "0.0.0.0" +crt = "certs/certificate.crt" +key = "certs/private.key" + +[bot] + + +[commands] +hello=false +stop=false + diff --git a/creds.toml b/creds.toml new file mode 100644 index 0000000..1ea6743 --- /dev/null +++ b/creds.toml @@ -0,0 +1 @@ +token="MTAwNDgwODA4OTgzNDM3MzIzMA.GeCLNB.JmmGESI2peVqyaaPFlFJUEVG-6SI7LGh3x-Ysc" diff --git a/main.py b/main.py index 45d2de7..fcad6e3 100644 --- a/main.py +++ b/main.py @@ -1,6 +1,7 @@ import discord, flask, os, quart, sys, toml, time, datetime from quart import render_template from quart.helpers import make_response +from discord.ext import commands with open("config.toml", "r") as f: config = toml.load(f) @@ -10,7 +11,11 @@ with open("creds.toml", "r") as f: start_time = time.time() -bot = discord.Bot() +print(creds) +intents = discord.Intents.default() +intents.members = True + +bot = commands.Bot(command_prefix='!', intents=intents) @bot.event async def on_ready(): @@ -33,19 +38,27 @@ app = quart.Quart(__name__) #The index. @app.route('/', methods=['GET']) async def index(): - return "Hello!" + return await render_template('index.html') + +@app.route('/configuration', methods=['GET']) +async def configuration(): + return await render_template('configuration.html') + +@app.route('/dashboard', methods=['GET']) +async def dashboard(): + return await render_template('dashboard.html') + +@app.route('/plugins', methods=['GET']) +async def plugins(): + return await render_template('plugins.html') + @app.route('/stop', methods=['GET']) async def stop(): sys.exit("Web terminated.") -@app.route('/dashboard', methods=["GET"]) -async def dashboard(): - commands_called = 10 - uptime_seconds = time.time() - start_time - uptime = str(datetime.timedelta(seconds=uptime_seconds)) - return await render_template('dashboard.html',commands_called=commands_called, uptime=uptime) -bot.loop.create_task(app.run_task('0.0.0.0', 5000, certfile="certs/certificate.crt", keyfile="certs/private.key")) + +bot.loop.create_task(app.run_task('0.0.0.0', 5000)) -bot.run('MTAwNDgwODA4OTgzNDM3MzIzMA.Gy9Nou.CVhTk-fEKyTvRLG-KeZm6wuilK9-eDZsEh4p0U') +bot.run(creds["token"]) diff --git a/meetoo.async b/meetoo.async new file mode 100644 index 0000000..ac275d9 --- /dev/null +++ b/meetoo.async @@ -0,0 +1,16 @@ +import ssl +from aiohttp import web + +async def handle(request): + name = request.match_info.get('name', "Anonymous") + text = "Hello, " + name + return web.Response(text=text) + +app = web.Application() +app.add_routes([web.get('/', handle), + web.get('/{name}', handle)]) + +if __name__ == '__main__': + sslc = ssl.create_default_context(ssl.Purpose.CLIENT_AUTH) + sslc.load_cert_chain("certs/certificate.crt", "certs/private.key") + web.run_app(app, port=5000, ssl_context=sslc) diff --git a/pipstuff.txt b/pipstuff.txt index af75408..94cf0fd 100644 --- a/pipstuff.txt +++ b/pipstuff.txt @@ -1,4 +1,4 @@ -discord +py-cord pytoml flask quart diff --git a/share/python-wheels/CacheControl-0.12.6-py2.py3-none-any.whl b/share/python-wheels/CacheControl-0.12.6-py2.py3-none-any.whl new file mode 100644 index 0000000..2f9cfb9 Binary files /dev/null and b/share/python-wheels/CacheControl-0.12.6-py2.py3-none-any.whl differ diff --git a/share/python-wheels/appdirs-1.4.4-py2.py3-none-any.whl b/share/python-wheels/appdirs-1.4.4-py2.py3-none-any.whl new file mode 100644 index 0000000..549b7b5 Binary files /dev/null and b/share/python-wheels/appdirs-1.4.4-py2.py3-none-any.whl differ diff --git a/share/python-wheels/certifi-2020.6.20-py2.py3-none-any.whl b/share/python-wheels/certifi-2020.6.20-py2.py3-none-any.whl new file mode 100644 index 0000000..61e1869 Binary files /dev/null and b/share/python-wheels/certifi-2020.6.20-py2.py3-none-any.whl differ diff --git a/share/python-wheels/chardet-4.0.0-py2.py3-none-any.whl b/share/python-wheels/chardet-4.0.0-py2.py3-none-any.whl new file mode 100644 index 0000000..59aae1c Binary files /dev/null and b/share/python-wheels/chardet-4.0.0-py2.py3-none-any.whl differ diff --git a/share/python-wheels/colorama-0.4.4-py2.py3-none-any.whl b/share/python-wheels/colorama-0.4.4-py2.py3-none-any.whl new file mode 100644 index 0000000..cc13089 Binary files /dev/null and b/share/python-wheels/colorama-0.4.4-py2.py3-none-any.whl differ diff --git a/share/python-wheels/contextlib2-0.6.0.post1-py2.py3-none-any.whl b/share/python-wheels/contextlib2-0.6.0.post1-py2.py3-none-any.whl new file mode 100644 index 0000000..98fba7c Binary files /dev/null and b/share/python-wheels/contextlib2-0.6.0.post1-py2.py3-none-any.whl differ diff --git a/share/python-wheels/distlib-0.3.1-py2.py3-none-any.whl b/share/python-wheels/distlib-0.3.1-py2.py3-none-any.whl new file mode 100644 index 0000000..5e231dd Binary files /dev/null and b/share/python-wheels/distlib-0.3.1-py2.py3-none-any.whl differ diff --git a/share/python-wheels/distro-1.5.0-py2.py3-none-any.whl b/share/python-wheels/distro-1.5.0-py2.py3-none-any.whl new file mode 100644 index 0000000..7c94f1f Binary files /dev/null and b/share/python-wheels/distro-1.5.0-py2.py3-none-any.whl differ diff --git a/share/python-wheels/html5lib-1.1-py2.py3-none-any.whl b/share/python-wheels/html5lib-1.1-py2.py3-none-any.whl new file mode 100644 index 0000000..2792f38 Binary files /dev/null and b/share/python-wheels/html5lib-1.1-py2.py3-none-any.whl differ diff --git a/share/python-wheels/idna-2.10-py2.py3-none-any.whl b/share/python-wheels/idna-2.10-py2.py3-none-any.whl new file mode 100644 index 0000000..dbed0da Binary files /dev/null and b/share/python-wheels/idna-2.10-py2.py3-none-any.whl differ diff --git a/share/python-wheels/ipaddr-2.2.0-py2.py3-none-any.whl b/share/python-wheels/ipaddr-2.2.0-py2.py3-none-any.whl new file mode 100644 index 0000000..29449bd Binary files /dev/null and b/share/python-wheels/ipaddr-2.2.0-py2.py3-none-any.whl differ diff --git a/share/python-wheels/msgpack-1.0.0-py2.py3-none-any.whl b/share/python-wheels/msgpack-1.0.0-py2.py3-none-any.whl new file mode 100644 index 0000000..7e73733 Binary files /dev/null and b/share/python-wheels/msgpack-1.0.0-py2.py3-none-any.whl differ diff --git a/share/python-wheels/packaging-20.9-py2.py3-none-any.whl b/share/python-wheels/packaging-20.9-py2.py3-none-any.whl new file mode 100644 index 0000000..211ed92 Binary files /dev/null and b/share/python-wheels/packaging-20.9-py2.py3-none-any.whl differ diff --git a/share/python-wheels/pep517-0.9.1-py2.py3-none-any.whl b/share/python-wheels/pep517-0.9.1-py2.py3-none-any.whl new file mode 100644 index 0000000..e87e874 Binary files /dev/null and b/share/python-wheels/pep517-0.9.1-py2.py3-none-any.whl differ diff --git a/share/python-wheels/pip-20.3.4-py2.py3-none-any.whl b/share/python-wheels/pip-20.3.4-py2.py3-none-any.whl new file mode 100644 index 0000000..4ed01e4 Binary files /dev/null and b/share/python-wheels/pip-20.3.4-py2.py3-none-any.whl differ diff --git a/share/python-wheels/pkg_resources-0.0.0-py2.py3-none-any.whl b/share/python-wheels/pkg_resources-0.0.0-py2.py3-none-any.whl new file mode 100644 index 0000000..9892059 Binary files /dev/null and b/share/python-wheels/pkg_resources-0.0.0-py2.py3-none-any.whl differ diff --git a/share/python-wheels/progress-1.5-py2.py3-none-any.whl b/share/python-wheels/progress-1.5-py2.py3-none-any.whl new file mode 100644 index 0000000..e97ea6f Binary files /dev/null and b/share/python-wheels/progress-1.5-py2.py3-none-any.whl differ diff --git a/share/python-wheels/pyparsing-2.4.7-py2.py3-none-any.whl b/share/python-wheels/pyparsing-2.4.7-py2.py3-none-any.whl new file mode 100644 index 0000000..99552bd Binary files /dev/null and b/share/python-wheels/pyparsing-2.4.7-py2.py3-none-any.whl differ diff --git a/share/python-wheels/requests-2.25.1-py2.py3-none-any.whl b/share/python-wheels/requests-2.25.1-py2.py3-none-any.whl new file mode 100644 index 0000000..17ba061 Binary files /dev/null and b/share/python-wheels/requests-2.25.1-py2.py3-none-any.whl differ diff --git a/share/python-wheels/resolvelib-0.5.4-py2.py3-none-any.whl b/share/python-wheels/resolvelib-0.5.4-py2.py3-none-any.whl new file mode 100644 index 0000000..5b1846d Binary files /dev/null and b/share/python-wheels/resolvelib-0.5.4-py2.py3-none-any.whl differ diff --git a/share/python-wheels/retrying-1.3.3-py2.py3-none-any.whl b/share/python-wheels/retrying-1.3.3-py2.py3-none-any.whl new file mode 100644 index 0000000..140048b Binary files /dev/null and b/share/python-wheels/retrying-1.3.3-py2.py3-none-any.whl differ diff --git a/share/python-wheels/setuptools-44.1.1-py2.py3-none-any.whl b/share/python-wheels/setuptools-44.1.1-py2.py3-none-any.whl new file mode 100644 index 0000000..e75461a Binary files /dev/null and b/share/python-wheels/setuptools-44.1.1-py2.py3-none-any.whl differ diff --git a/share/python-wheels/six-1.16.0-py2.py3-none-any.whl b/share/python-wheels/six-1.16.0-py2.py3-none-any.whl new file mode 100644 index 0000000..bec49a1 Binary files /dev/null and b/share/python-wheels/six-1.16.0-py2.py3-none-any.whl differ diff --git a/share/python-wheels/toml-0.10.1-py2.py3-none-any.whl b/share/python-wheels/toml-0.10.1-py2.py3-none-any.whl new file mode 100644 index 0000000..58d089c Binary files /dev/null and b/share/python-wheels/toml-0.10.1-py2.py3-none-any.whl differ diff --git a/share/python-wheels/urllib3-1.26.5-py2.py3-none-any.whl b/share/python-wheels/urllib3-1.26.5-py2.py3-none-any.whl new file mode 100644 index 0000000..505e22d Binary files /dev/null and b/share/python-wheels/urllib3-1.26.5-py2.py3-none-any.whl differ diff --git a/share/python-wheels/webencodings-0.5.1-py2.py3-none-any.whl b/share/python-wheels/webencodings-0.5.1-py2.py3-none-any.whl new file mode 100644 index 0000000..917e2f4 Binary files /dev/null and b/share/python-wheels/webencodings-0.5.1-py2.py3-none-any.whl differ diff --git a/share/python-wheels/wheel-0.34.2-py2.py3-none-any.whl b/share/python-wheels/wheel-0.34.2-py2.py3-none-any.whl new file mode 100644 index 0000000..2fb6bcb Binary files /dev/null and b/share/python-wheels/wheel-0.34.2-py2.py3-none-any.whl differ diff --git a/static/configuration.css b/static/configuration.css new file mode 100644 index 0000000..fca533e --- /dev/null +++ b/static/configuration.css @@ -0,0 +1,88 @@ +body { + font-family: Arial, sans-serif; + margin: 0; + padding: 0; + background-color: #2c3e50; + color: #fff; +} + +.logo { + width: 25; + height: 25; +} + +header { + background-color: #3e4982; + color: #fff; + padding: 20px; + text-align: center; +} + +header h1 { + margin: 0; +} + +.container { + display: flex; +} + +table { + font-family: Arial, Helvetica, sans-serif; + border-collapse: collapse; + width: 100%; +} + +table td, +#status th { + border: 1px solid #ddd; + padding: 8px; +} + +table tr:nth-child(even) { + background-color: #1c567d; +} + +table tr:hover { + background-color: #2980b9; +} + +table th { + padding-top: 12px; + padding-bottom: 12px; + text-align: left; + background-color: #04AA6D; + color: white; +} + +nav { + background-color: #34495e; + width: 200px; + padding: 20px; + text-align: center; +} + +nav ul { + list-style: none; + margin: 0; + padding: 0; +} + +nav li a { + color: #fff; + text-decoration: none; + padding: 10px 0; + display: block; +} + +nav li a:hover { + background-color: #2980b9; +} + +.selected { + background-color: #2980b9; +} + +main { + padding: 20px; + flex-grow: 1; +} \ No newline at end of file diff --git a/static/dashboard.css b/static/dashboard.css new file mode 100644 index 0000000..b92a2c9 --- /dev/null +++ b/static/dashboard.css @@ -0,0 +1,88 @@ +body { + font-family: Arial, sans-serif; + margin: 0; + padding: 0; + background-color: #2c3e50; + color: #fff; +} + +.logo { + width: 25; + height: 25; +} + +header { + background-color: #3e4982; + color: #fff; + padding: 20px; + text-align: center; +} + +header h1 { + margin: 0; +} + +.container { + display: flex; +} + +table { + font-family: Arial, Helvetica, sans-serif; + border-collapse: collapse; + width: 100%; +} + +table td, +#status th { + border: 1px solid #ddd; + padding: 8px; +} + +table tr:nth-child(even) { + background-color: #1c567d; +} + +table tr:hover { + background-color: #2980b9; +} + +table th { + padding-top: 12px; + padding-bottom: 12px; + text-align: left; + background-color: #04AA6D; + color: white; +} + +nav { + background-color: #34495e; + width: 200px; + padding: 20px; + text-align: center; +} + +nav ul { + list-style: none; + margin: 0; + padding: 0; +} + +nav li a { + color: #fff; + text-decoration: none; + padding: 10px 0; + display: block; +} + +nav li a:hover { + background-color: #2980b9; +} + +.selected { + background-color: #2980b9; +} + +main { + padding: 20px; + flex-grow: 1; +} diff --git a/static/index.css b/static/index.css new file mode 100644 index 0000000..9ac95ae --- /dev/null +++ b/static/index.css @@ -0,0 +1,61 @@ +body { + font-family: Arial, sans-serif; + margin: 0; + padding: 0; + background-color: #2c3e50; + color: #fff; +} +.selected { + background-color: #2980b9; +} +.logo { + width: 25; + height: 25; +} + +header { + background-color: #3e4982; + color: #fff; + padding: 20px; + text-align: center; +} + +header h1 { + margin: 0; +} + +.container { + display: flex; +} + +nav { + background-color: #34495e; + width: 200px; + padding: 20px; + text-align: center; +} + +nav ul { + list-style: none; + margin: 0; + padding: 0; +} + +nav li a { + color: #fff; + text-decoration: none; + padding: 10px 0; + display: block; +} + +nav li a:hover { + background-color: #2980b9; +} + +main { + padding: 20px; + flex-grow: 1; +} + + + diff --git a/static/js/configuration.js b/static/js/configuration.js new file mode 100644 index 0000000..4aa072e --- /dev/null +++ b/static/js/configuration.js @@ -0,0 +1,66 @@ +const form = document.querySelector("form"); +const tokenInput = form.querySelector("#token"); +const nameInput = form.querySelector("#name"); +const statusSelect = form.querySelector("#status"); + +// set the token input as password field +tokenInput.setAttribute("type", "password"); + +// function to get the config values from the server +const getConfigValues = async () => { + try { + const tokenResponse = await fetch('/api/token'); + const tokenValue = await tokenResponse.text(); + tokenInput.value = tokenValue; + + const nameResponse = await fetch('/api/name'); + const nameValue = await nameResponse.text(); + nameInput.value = nameValue; + + const statusResponse = await fetch('/api/status'); + const statusValue = await statusResponse.text(); + statusSelect.value = statusValue; + } catch (error) { + console.error(error); + } +} + +getConfigValues(); + +form.addEventListener("submit", async (event) => { + event.preventDefault(); + const token = tokenInput.value; + const name = nameInput.value; + const status = statusSelect.value; + + try { + // send POST request to /api/token endpoint with token as the body + if (token !== '') { + await fetch('/api/token', { + method: 'POST', + body: token + }); + } + + + // send POST request to /api/name endpoint with name as the body + if (name !== '') { + await fetch('/api/name', { + method: 'POST', + body: name + }); + } + + + // send POST request to /api/status endpoint with status as the body + if (status !== '') { + await fetch('/api/status', { + method: 'POST', + body: status + }); + } + + } catch (error) { + console.error(error); + } +}); \ No newline at end of file diff --git a/static/plugins.css b/static/plugins.css new file mode 100644 index 0000000..fca533e --- /dev/null +++ b/static/plugins.css @@ -0,0 +1,88 @@ +body { + font-family: Arial, sans-serif; + margin: 0; + padding: 0; + background-color: #2c3e50; + color: #fff; +} + +.logo { + width: 25; + height: 25; +} + +header { + background-color: #3e4982; + color: #fff; + padding: 20px; + text-align: center; +} + +header h1 { + margin: 0; +} + +.container { + display: flex; +} + +table { + font-family: Arial, Helvetica, sans-serif; + border-collapse: collapse; + width: 100%; +} + +table td, +#status th { + border: 1px solid #ddd; + padding: 8px; +} + +table tr:nth-child(even) { + background-color: #1c567d; +} + +table tr:hover { + background-color: #2980b9; +} + +table th { + padding-top: 12px; + padding-bottom: 12px; + text-align: left; + background-color: #04AA6D; + color: white; +} + +nav { + background-color: #34495e; + width: 200px; + padding: 20px; + text-align: center; +} + +nav ul { + list-style: none; + margin: 0; + padding: 0; +} + +nav li a { + color: #fff; + text-decoration: none; + padding: 10px 0; + display: block; +} + +nav li a:hover { + background-color: #2980b9; +} + +.selected { + background-color: #2980b9; +} + +main { + padding: 20px; + flex-grow: 1; +} \ No newline at end of file diff --git a/templates/configuration.html b/templates/configuration.html new file mode 100644 index 0000000..c416904 --- /dev/null +++ b/templates/configuration.html @@ -0,0 +1,47 @@ + + + +
+This is the admin dashboard. Here you can see important thing like the uptime, hits per minute, cogs status etc..
+Module | +Status | +Module link | +
---|---|---|
Uptime | +1 Year | +/api/uptime | +
Hits Per Minute | +10 | +/api/hpm | +
Plugin - Fivem | +Online | +/plugins/fivem | +
This bot is designed to help you with various tasks and make your life easier
+Here you can find information about the bot's features, plugins, configuration, and support. All this info is public. If you want you can turn it off in the settings page.
+This is the plugin page here you can disable/enable the individual cogs.
+Plugin | +Status | +Plugin link | +
---|---|---|
Uptime | +1 Year | +/api/uptime | +
Hits Per Minute | +10 | +/api/hpm | +
Plugin - Fivem | +Online | +/plugins/fivem | +