From 864aaf07d2644f733d8b7cbc39be8a0eedfbebad Mon Sep 17 00:00:00 2001 From: Kivou-2000607 Date: Tue, 17 Dec 2019 00:13:33 +0100 Subject: [PATCH] bot admin --- bot/functions.py | 4 +- bot/migrations/0014_auto_20191216_2220.py | 23 ++++++++++++ bot/models.py | 2 + player/admin.py | 2 +- templates/bot/apps.html | 17 ++++++--- templates/bot/discord-id.html | 6 +-- templates/bot/give-permission.html | 4 +- templates/bot/main.html | 46 ++++++++++++----------- 8 files changed, 71 insertions(+), 33 deletions(-) create mode 100644 bot/migrations/0014_auto_20191216_2220.py diff --git a/bot/functions.py b/bot/functions.py index 8bb373555..fe9c60e94 100644 --- a/bot/functions.py +++ b/bot/functions.py @@ -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: diff --git a/bot/migrations/0014_auto_20191216_2220.py b/bot/migrations/0014_auto_20191216_2220.py new file mode 100644 index 000000000..771634eab --- /dev/null +++ b/bot/migrations/0014_auto_20191216_2220.py @@ -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), + ), + ] diff --git a/bot/models.py b/bot/models.py index 35fd630b5..27d1eab88 100644 --- a/bot/models.py +++ b/bot/models.py @@ -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) diff --git a/player/admin.py b/player/admin.py index 170126416..fcb700327 100644 --- a/player/admin.py +++ b/player/admin.py @@ -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'] diff --git a/templates/bot/apps.html b/templates/bot/apps.html index d0add2a3d..7f0a371de 100644 --- a/templates/bot/apps.html +++ b/templates/bot/apps.html @@ -17,11 +17,17 @@ along with yata. If not, see . {% endcomment %} +{% load app_filters %} + {% for app in apps %} -

{{app.name}} [{{app.id}}]

-
- {% for guildId, guild in app.variables.items %} -

Guild {{guild.admin.name}} [{{guildId}}] owned by {{guild.admin.owner}} [{{guild.admin.owner_id}}]

+{% for guildId, guild in app.variables.items %} +
+

{{app.name}} [{{app.id}}] on guild {{guild.admin.name}} [{{guildId}}]  

+ +
+{% endfor %} {% endfor %} diff --git a/templates/bot/discord-id.html b/templates/bot/discord-id.html index 4d49767b2..81b7de75e 100644 --- a/templates/bot/discord-id.html +++ b/templates/bot/discord-id.html @@ -18,11 +18,11 @@ {% endcomment %}
{% csrf_token %} -

+

Here is you status: {% if player.dId%} - You have been verified on the official Torn discord server with the discord ID: {{player.dId}} + Your discord account {{player.dId}} is officially verified by Torn. {% else %} - You have not been verified on the official Torn discord server. + Your discord account is not officialy verified by Torn.   {% endif %}    {% if error %}  {{error.apiErrorSub}}{% endif %} diff --git a/templates/bot/give-permission.html b/templates/bot/give-permission.html index ca9f0109d..1274b0e6b 100644 --- a/templates/bot/give-permission.html +++ b/templates/bot/give-permission.html @@ -20,9 +20,9 @@ {% csrf_token %}

{% if player.botPerm%} -   Currently, the official YATA bot has your permission to use your API key. Click to remove permission. +   The official YATA bot has your permission to use your API key. remove {% else %} -   Currently, the official YATA bot doesn't have your permission to use your API key. Click to give permission. +   The official YATA bot does not have your permission to use your API key. give {% endif %}

diff --git a/templates/bot/main.html b/templates/bot/main.html index c65313992..cf85da363 100644 --- a/templates/bot/main.html +++ b/templates/bot/main.html @@ -22,41 +22,45 @@

The YATA bot(s)

-

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.

+

The source code of the YATA bot is currently developed and maintained by {{"Kivou"|playerURL:"2000607"|safe}}.

-

Official YATA bot

-

The official YATA bot is the one runned by {{"Kivou"|playerURL:"2000607"|safe}} and is on different servers at the same time.

+

  Official YATA bot

+

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.

  • It is the only one that have access to the YATA database (see below)
  • It is the only one vouched for by {{"Kivou"|playerURL:"2000607"|safe}}

You can check if you're dealing with the official bot by checking the list of servers at the bottom of this page and by checking that the bot ID is 623862007434706986 (how to look at discord ID).

-

Unofficial YATA bots

+

  Unofficial YATA bots

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.

Discord ID

Some features requires a verified account on the official Torn discord server.

{% include "bot/discord-id.html" %}
-

Give permission to the YATA bot

-

Some features of the YATA bot [see next section] 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. But, 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.
- So, before giving permission to the bot, make sure that YOU TRUST THE OWNERS of every servers you're in and that are running the official YATA bot. +

YATA bot permission to use your key

+

Some features of the YATA bot (see next section) 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. But, 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.
+ So, before giving permission to the bot, make sure that you trust the owners of every servers you're in and that are running the YATA bot.

{% include "bot/give-permission.html" %}
-

Bot features asking for your key

-

Feature 1. Stock sharing

+

Bot features asking permission for your key

+

Feature 1. Verify

+

  No private data

+

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.

+

Feature 2. Stock sharing

+

  Private data

If you happen to have the @wssb or @tcb 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 @wssb and @tcb members).

-

More might come

-

But for now stock sharing is the only one.

-

Rule of thumb:

-
    -
  1. Look on your servers if the official YATA bot is running
  2. -
  3. Look if you got any of these roles: @wssb, @tcb
  4. -
      -
    • If yes, you have to give permission to the bot... So read carfully what's above
    • -
    • If no, you don't need to give the bot the permission, the other features don't require your key
    • -
    -
  5. Enjoy the features!
  6. -
+

Rule of thumb:

+
    +
  1. Look on your servers if the YATA bot is running
  2. +
  3. Look if you got any of these roles: @wssb, @tcb
  4. +
      +
    • If yes, you have to give permission to the bot... So read carfully what's above
    • +
    • If no, you don't need to give the bot the permission, the other features don't require your key
    • +
    +
  5. Enjoy the features!
  6. +
+

The other features

+

The other features of the bot either don't require your key (like all !loot) or DM you the response (like !weaponexp), thus no permission is asked to use it.