Testing gitea webhooks

main
supopur 2 years ago
parent 8c235443a7
commit c4ebac3bce

@ -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

@ -0,0 +1 @@
token="MTAwNDgwODA4OTgzNDM3MzIzMA.GeCLNB.JmmGESI2peVqyaaPFlFJUEVG-6SI7LGh3x-Ysc"

@ -1,6 +1,7 @@
import discord, flask, os, quart, sys, toml, time, datetime import discord, flask, os, quart, sys, toml, time, datetime
from quart import render_template from quart import render_template
from quart.helpers import make_response from quart.helpers import make_response
from discord.ext import commands
with open("config.toml", "r") as f: with open("config.toml", "r") as f:
config = toml.load(f) config = toml.load(f)
@ -10,7 +11,11 @@ with open("creds.toml", "r") as f:
start_time = time.time() 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 @bot.event
async def on_ready(): async def on_ready():
@ -33,19 +38,27 @@ app = quart.Quart(__name__)
#The index. #The index.
@app.route('/', methods=['GET']) @app.route('/', methods=['GET'])
async def index(): 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']) @app.route('/stop', methods=['GET'])
async def stop(): async def stop():
sys.exit("Web terminated.") 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"])

@ -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)

@ -1,4 +1,4 @@
discord py-cord
pytoml pytoml
flask flask
quart quart

@ -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;
}

@ -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;
}

@ -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;
}

@ -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);
}
});

@ -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;
}

@ -0,0 +1,47 @@
<!DOCTYPE html>
<html>
<head>
<title>MEE2 Configuration</title>
<link href="{{ url_for('static', filename='configuration.css') }}" rel="stylesheet" type="text/css" />
<script src="{{ url_for('static', filename='js/configuration.js') }}"></script>
<link rel="icon" type="image/x-icon" href="https://cdn.discordapp.com/app-icons/1004808089834373230/e30029e50ec03472f1fe236a43d38684.png?size=512">
</head>
<body>
<header>
<h1>MEE2 Configuration</h1>
</header>
<div class="container">
<nav>
<ul>
<li><a href="/">Home</a></li>
<li><a href="/dashboard">Dashboard</a></li>
<li><a href="#" class="selected">Configuration</a></li>
<li><a href="/logs">Logs</a></li>
<li><a href="/support">Support</a></li>
</ul>
</nav>
<main>
<form>
<label for="token">Token:</label>
<input type="password" id="token" name="token">
<br>
<label for="name">Bot Name:</label>
<input type="text" id="name" name="name">
<br>
<label for="status">Status:</label>
<select id="status" name="status">
<option value="online">Online</option>
<option value="idle">Idle</option>
<option value="dnd">Do Not Disturb</option>
<option value="invisible">Invisible</option>
</select>
<br>
<input type="submit" value="Save Changes">
</form>
</main>
</div>
</body>
</html>

@ -0,0 +1,54 @@
<!DOCTYPE html>
<html>
<head>
<title>MEE2 Dashboard</title>
<link href="{{ url_for('static', filename='dashboard.css') }}" rel="stylesheet" type="text/css" />
<link rel="icon" type="image/x-icon" href="https://cdn.discordapp.com/app-icons/1004808089834373230/e30029e50ec03472f1fe236a43d38684.png?size=512">
</head>
<body>
<header>
<h1>MEE2 - Admin Dashboard</h1>
</header>
<div class="container">
<nav>
<ul>
<li><a href="/">Home</a></li>
<li><a href="#" class="selected">Dashboard</a></li>
<li><a href="/plugins">Plugins</a></li>
<li><a href="/configuration">Configuration</a></li>
<li><a href="/logs">Logs</a></li>
<li><a href="/support">Support</a></li>
</ul>
</nav>
<main>
<p>This is the admin dashboard. Here you can see important thing like the uptime, hits per minute, cogs status etc..</p>
<table id="status">
<tr>
<th>Module</th>
<th>Status</th>
<th>Module link</th>
</tr>
<tr>
<td>Uptime</td>
<td>1 Year</td>
<td><a href="/api/uptime">/api/uptime</a></td>
</tr>
<tr>
<td>Hits Per Minute</td>
<td>10</td>
<td><a href="/api/hpm">/api/hpm</a></td>
</tr>
<tr>
<td>Plugin - Fivem</td>
<td>Online</td>
<td><a href="/plugins/fivem">/plugins/fivem</a></td>
</tr>
</table>
</main>
</div>
</body>
</html>

@ -0,0 +1,34 @@
<!DOCTYPE html>
<html>
<head>
<title>MEE2 Index</title>
<link rel="icon" type="image/x-icon" href="https://cdn.discordapp.com/app-icons/1004808089834373230/e30029e50ec03472f1fe236a43d38684.png?size=512">
<link href="{{ url_for('static', filename='index.css') }}" rel="stylesheet" type="text/css" />
</head>
<body>
<header>
<h1>MEE2</h1>
</header>
<div class="container">
<nav>
<ul>
<li class="selected"><a href="#">Home</a></li>
<li><a href="/dashboard">Dashboard</a></li>
<li><a href="/plugins">Plugins</a></li>
<li><a href="/configuration">Configuration</a></li>
<li><a href="/logs">Logs</a></li>
<li><a href="/support">Support</a></li>
</ul>
</nav>
<main>
<h2>Welcome to the MEE2 index page.</h2>
<p>This bot is designed to help you with various tasks and make your life easier</p>
<p>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.</p>
</main>
</div>
</body>
</html>

@ -0,0 +1,54 @@
<!DOCTYPE html>
<html>
<head>
<title>MEE2 Plugins</title>
<link href="{{ url_for('static', filename='plugins.css') }}" rel="stylesheet" type="text/css" />
<link rel="icon" type="image/x-icon" href="https://cdn.discordapp.com/app-icons/1004808089834373230/e30029e50ec03472f1fe236a43d38684.png?size=512">
</head>
<body>
<header>
<h1>MEE2 - Plugins</h1>
</header>
<div class="container">
<nav>
<ul>
<li><a href="/">Home</a></li>
<li><a href="/dashboard">Dashboard</a></li>
<li><a href="#" class="selected">Plugins</a></li>
<li><a href="/configuration">Configuration</a></li>
<li><a href="/logs">Logs</a></li>
<li><a href="/support">Support</a></li>
</ul>
</nav>
<main>
<p>This is the plugin page here you can disable/enable the individual cogs.</p>
<table id="status">
<tr>
<th>Plugin</th>
<th>Status</th>
<th>Plugin link</th>
</tr>
<tr>
<td>Uptime</td>
<td>1 Year</td>
<td><a href="/api/uptime">/api/uptime</a></td>
</tr>
<tr>
<td>Hits Per Minute</td>
<td>10</td>
<td><a href="/api/hpm">/api/hpm</a></td>
</tr>
<tr>
<td>Plugin - Fivem</td>
<td>Online</td>
<td><a href="/plugins/fivem">/plugins/fivem</a></td>
</tr>
</table>
</main>
</div>
</body>
</html>

@ -0,0 +1,16 @@
import requests
def get_player_description(user_id):
url = f"https://users.roblox.com/v1/users/{user_id}"
response = requests.get(url)
if response.status_code == 200:
player_data = response.json()
return player_data["description"]
else:
return None
user_id = 156719681 # Replace with the desired user ID
description = get_player_description(user_id)
print(f"Player description: \n{description}")
Loading…
Cancel
Save