Browse Source

Web ui example integrating zkill killstream

ideas
sirgje 3 years ago
parent
commit
dd732c76da
No known key found for this signature in database GPG Key ID: 9F326B1EC4A97073
  1. 1
      cogs/web/templates/base.html
  2. 29
      cogs/web/templates/zkill.html
  3. 7
      cogs/webserver.py

1
cogs/web/templates/base.html

@ -12,6 +12,7 @@
<h5 class="my-0 mr-md-auto font-weight-normal">Rooster Web UI</h5>
<nav class="my-2 my-md-0 mr-md-3">
{% if current_user.is_authenticated %}
<a class="p-2 text-dark" href="/zkill/">zKillboard</a>
<a class="p-2 text-dark" href="/logout">Logout</a>
{% endif %}
</nav>

29
cogs/web/templates/zkill.html

@ -0,0 +1,29 @@
{% extends "base.html" %}
{% block content %}
<p>We have <span class="badge">{{ killwatches|length }}</span> killwatches.
<table class="table table-bordered table-striped">
<thead>
<tr>
<th scope="col">Channel</th>
<th scope="col">Entity Name</th>
<th scope="col">Entity Id</th>
<th scope="col">Value</th>
<th scope="col">Scope</th>
</tr>
</thead>
<tbody>
{% for killwatch in killwatches %}
<tr>
<td>{{ killwatches[killwatch].channel }}</td>
<td>{{ killwatches[killwatch].name }}</td>
<td>{{ killwatches[killwatch].id }}</td>
<td>{{ killwatches[killwatch].value }}</td>
<td>{{ killwatches[killwatch].scope }}</td>
</tr>
{% endfor %}
</tbody>
</table>
{% endblock %}

7
cogs/webserver.py

@ -1,3 +1,4 @@
import json
import logging
import config
from discord.ext import commands, tasks
@ -21,6 +22,12 @@ class Webserver(commands.Cog):
async def index():
return await render_template('index.html', guilds=self.bot.guilds, users=self.bot.users)
@app.route('/zkill/')
@login_required
async def zkill():
killwatches = await self.bot.redis.execute("get", "killwatch_criteria")
return await render_template('zkill.html', killwatches=json.loads(killwatches.decode("utf-8")))
@app.route('/send-message/<channel_id>')
@login_required
async def test_message(channel_id):

Loading…
Cancel
Save