Skip to content

Commit

Permalink
bot admin
Browse files Browse the repository at this point in the history
  • Loading branch information
Kivou-2000607 committed Dec 16, 2019
1 parent 505c5df commit 864aaf0
Show file tree
Hide file tree
Showing 8 changed files with 71 additions and 33 deletions.
4 changes: 3 additions & 1 deletion bot/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ def saveBotsConfigs():
var[guild.guildId] = dict({})
var[guild.guildId]["admin"] = {"name": guild.guildName,
"owner": guild.guildOwnerName,
"owner_id": guild.guildOwnerId}
"owner_id": guild.guildOwnerId,
"contact": guild.guildContactName,
"contact_id": guild.guildContactId}

# manage channels
if guild.manageChannels:
Expand Down
23 changes: 23 additions & 0 deletions bot/migrations/0014_auto_20191216_2220.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Generated by Django 2.2.7 on 2019-12-16 22:20

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('bot', '0013_auto_20191215_1959'),
]

operations = [
migrations.AddField(
model_name='guild',
name='guildContactId',
field=models.BigIntegerField(default=0),
),
migrations.AddField(
model_name='guild',
name='guildContactName',
field=models.CharField(default='guild_contact', max_length=32),
),
]
2 changes: 2 additions & 0 deletions bot/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ class Guild(models.Model):
guildName = models.CharField(default="guild_name", max_length=32)
guildOwnerId = models.BigIntegerField(default=0)
guildOwnerName = models.CharField(default="guild_owner", max_length=32)
guildContactId = models.BigIntegerField(default=0)
guildContactName = models.CharField(default="guild_contact", max_length=32)

# general options
manageChannels = models.BooleanField(default=False)
Expand Down
2 changes: 1 addition & 1 deletion player/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
class PlayerAdmin(admin.ModelAdmin):
class Media:
css = {'all': ('perso/css/admin.css',)}
list_display = ['tId', 'name', 'active', 'validKey', 'last_action', 'lastActionTS', 'last_update', 'lastUpdateTS']
list_display = ['tId', 'name', 'botPerm', 'active', 'validKey', 'last_action', 'lastActionTS', 'last_update', 'lastUpdateTS']
search_fields = ['name', 'tId']
list_filter = ['active', 'validKey']

Expand Down
17 changes: 12 additions & 5 deletions templates/bot/apps.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,17 @@
along with yata. If not, see <https://www.gnu.org/licenses/>.
{% endcomment %}

{% load app_filters %}

{% for app in apps %}
<h2 class="title">{{app.name}} [{{app.id}}]</h2>
<div class="module">
{% for guildId, guild in app.variables.items %}
<h1>Guild {{guild.admin.name}} [{{guildId}}] owned by {{guild.admin.owner}} [{{guild.admin.owner_id}}]</h1>
{% for guildId, guild in app.variables.items %}
<div class="catch-me">
<h2 class="title toggle-display rounded">{{app.name}} [{{app.id}}] on guild {{guild.admin.name}} [{{guildId}}]&nbsp;&nbsp;<i class="fas fa-caret-right"></i></h2>
<div class="module" style="display: none;">
<h2>Owner</h2>
<p>{{guild.admin.owner}} [{{guild.admin.owner_id}}]</p>
<h2>Contact</h2>
<p>{{guild.admin.contact|playerURL:guild.admin.contact_id|safe}}</p>
{% for module, options in guild.items %}
{% if module != "admin" %}
<h2>{{module}}</h2>
Expand All @@ -38,6 +44,7 @@ <h2>{{module}}</h2>
{% if not forloop.last %}
<hr class="sep">
{% endif %}
{% endfor %}
</div>
</div>
{% endfor %}
{% endfor %}
6 changes: 3 additions & 3 deletions templates/bot/discord-id.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@
{% endcomment %}

<form>{% csrf_token %}
<p>
<p>Here is you status:
{% if player.dId%}
You have been verified on the official Torn discord server with the discord ID: <tt class="valid">{{player.dId}}</tt>
<span class="valid">Your discord account <tt>{{player.dId}}</tt> is officially verified by Torn.</span>
{% else %}
<span class="error">You have not been verified on the official Torn discord server.</span>
<span class="error">Your discord account is not officialy verified by Torn.&nbsp;&nbsp;<i class="fas fa-question-circle" title="Gog get your discord account verified on the official Torn discord."></i></span>
{% endif %}
<a id="discord-update-id" href="{% url 'bot:updateId' %}">&nbsp;&nbsp;<i class="fas fa-sync-alt" title="Update discord ID"></i></a>
{% if error %}&nbsp;&nbsp;<span class="error">{{error.apiErrorSub}}</span>{% endif %}
Expand Down
4 changes: 2 additions & 2 deletions templates/bot/give-permission.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
<form>{% csrf_token %}
<p>
{% if player.botPerm%}
<a id="discord-toggle-perm" class="valid" href="{% url 'bot:togglePerm' %}"><i class="fas fa-toggle-on"></i>&nbsp; Currently, the official YATA bot has your permission to use your API key. Click to remove permission.</a>
<span class="valid"><i class="fas fa-lock-open"></i>&nbsp; The official YATA bot has your permission to use your API key.</span> <a id="discord-toggle-perm" href="{% url 'bot:togglePerm' %}">remove</a>
{% else %}
<a id="discord-toggle-perm" class="error" href="{% url 'bot:togglePerm' %}"><i class="fas fa-toggle-off"></i>&nbsp; Currently, the official YATA bot doesn't have your permission to use your API key. Click to give permission.</a>
<span class="error"><i class="fas fa-lock"></i>&nbsp; The official YATA bot does not have your permission to use your API key.</span> <a id="discord-toggle-perm" href="{% url 'bot:togglePerm' %}">give</a>
{% endif %}
</p>
</form>
46 changes: 25 additions & 21 deletions templates/bot/main.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,41 +22,45 @@
<!-- <h2 class="title">Configurations</h2> -->
<div class="module rounded">
<h1>The YATA bot(s)</h1>
<p>The source code of the YATA bot is currently developed and maintained by {{"Kivou"|playerURL:"2000607"|safe}} and is hosted on different servers owned by different users.</p>
<p>The source code of the YATA bot is currently developed and maintained by {{"Kivou"|playerURL:"2000607"|safe}}.</p>

<h2>Official YATA bot</h2>
<p>The official YATA bot is the one runned by {{"Kivou"|playerURL:"2000607"|safe}} and is on different servers at the same time.</p>
<h2><i class="fas fa-thumbs-up"></i>&nbsp; Official YATA bot</h2>
<p>The official YATA bot (later on simply called YATA bot) runs on a single server controled by {{"Kivou"|playerURL:"2000607"|safe}} and is hosted on multiple discord servers owned by different members.</p>
<ul>
<li>It is the only one that have access to the YATA database (see below)</li>
<li>It is the only one vouched for by {{"Kivou"|playerURL:"2000607"|safe}}</li>
</ul>
<p>You can check if you're dealing with the official bot by checking the list of servers at the bottom of this page <b>and</b> by checking that the bot ID is <tt>623862007434706986</tt> (<a href="https://support.discordapp.com/hc/en-us/articles/206346498-Where-can-I-find-my-User-Server-Message-ID-" target="_blank">how to look at discord ID</a>).</p>
<h2>Unofficial YATA bots</h2>
<h2><i class="fas fa-question"></i>&nbsp; Unofficial YATA bots</h2>
<p>There is no control whatsoever on the different versions of the bot. Some might be better, some might be worse, some might be malicious... The only think known is that they have not access to the information put on YATA and will never have.</p>

<h1>Discord ID</h1>
<p>Some features requires a verified account on the <a href="https://www.torn.com/discord" target="_blank">official Torn discord server</a>.</p>
<div id="discord-id">{% include "bot/discord-id.html" %}</div>

<h1>Give permission to the YATA bot</h1>
<p>Some features of the YATA bot <a href="#bot-features">[see next section]</a> require your personnal API key (stored in YATA) to pull information. It will not do it without your consent. The discord server owner will never have a direct access to your key and will only be able to use the bot functions. <span class="error">But</span>, server owners can play with the roles and the permissions as they wish. If they have malicious intents they can use the bot without your knowledge.<br>
So, before giving permission to the bot, make sure that <span class="warning">YOU TRUST THE OWNERS of every servers you're in and that are running the official YATA bot.</span>
<h1>YATA bot permission to use your key</h1>
<p>Some features of the YATA bot (<a href="#bot-features">see next section</a>) require your personnal API key (stored in YATA) to pull information. It will not do it without your consent. The discord server owner will never have a direct access to your key and will only be able to use the bot functions. <span class="error">But</span>, server owners can play with the roles and the permissions as they wish. If they have malicious intents they can use the bot without your knowledge.<br>
So, before giving permission to the bot, make sure that <span class="warning">you <span style="text-decoration: underline;">trust the owners</span> of every servers you're in and that are running the YATA bot.</span>
</p>
<div id="discord-perm">{% include "bot/give-permission.html" %}</div>

<h1 id="bot-features">Bot features asking for your key</h1>
<h2>Feature 1. Stock sharing</h2>
<h1 id="bot-features">Bot features asking permission for your key</h1>
<h2>Feature 1. Verify</h2>
<p class="valid"><i class="fas fa-user-check"></i>&nbsp;&nbsp;No private data</p>
<p>The bot requires at least one master key to make the calls for the verifications. Usually the person asking for the bot is putting his but adding others lower the load. No private data is ever pulled from this module but still the bot requires your permission.</p>
<h2>Feature 2. Stock sharing</h2>
<p class="error"><i class="fas fa-user-lock"></i>&nbsp;&nbsp;Private data</p>
<p>If you happen to have the <tt>@wssb</tt> or <tt>@tcb</tt> role you're concerned. With your permission, the bot will be able to pull education time left and bank investement time left, respectively, and will make it visible to members of the server (supposed to be shared with <tt>@wssb</tt> and <tt>@tcb</tt> members).</p>
<h2>More might come</h2>
<p>But for now stock sharing is the only one.</p>
<h2>Rule of thumb:</h2>
<ol>
<li>Look on your servers if the official YATA bot is running</li>
<li>Look if you got any of these roles: <tt>@wssb</tt>, <tt>@tcb</tt></li>
<ul>
<li>If yes, you have to give permission to the bot... So read carfully what's above</li>
<li>If no, you don't need to give the bot the permission, the other features don't require your key</li>
</ul>
<li>Enjoy the features!</li>
</ol>
<h2>Rule of thumb:</h2>
<ol>
<li>Look on your servers if the YATA bot is running</li>
<li>Look if you got any of these roles: <tt>@wssb</tt>, <tt>@tcb</tt></li>
<ul>
<li>If yes, you have to give permission to the bot... So read carfully what's above</li>
<li>If no, you don't need to give the bot the permission, the other features don't require your key</li>
</ul>
<li>Enjoy the features!</li>
</ol>
<h2>The other features</h2>
<p>The other features of the bot either don't require your key (like all <tt>!loot</tt>) or DM you the response (like <tt>!weaponexp</tt>), thus no permission is asked to use it.</p>
</div>

0 comments on commit 864aaf0

Please sign in to comment.