Data API Complicance (Red 3.4) (#136)

* Simple ones first

* Less simple but still simple.

* Slightly more complicated

* use correct name

* move to module

* Black -l 120

* review

* give users the proper feedback

Co-authored-by: aikaterna <20862007+aikaterna@users.noreply.github.com>
This commit is contained in:
Draper
2020-08-26 17:57:43 +01:00
committed by GitHub
parent 4376194429
commit ae9dbf569c
95 changed files with 593 additions and 703 deletions

View File

@@ -1,5 +1,7 @@
from .chatchart import Chatchart
__red_end_user_data_statement__ = "This cog does not persistently store data or metadata about users."
def setup(bot):
bot.add_cog(Chatchart(bot))

View File

@@ -5,7 +5,6 @@
# Thanks to violetnyte for suggesting this cog.
import discord
import heapq
import os
from io import BytesIO
from typing import Optional
import matplotlib
@@ -20,6 +19,10 @@ from redbot.core import commands
class Chatchart(commands.Cog):
"""Show activity."""
async def red_delete_data_for_user(self, **kwargs):
""" Nothing to delete """
return
def __init__(self, bot):
self.bot = bot
@@ -85,7 +88,7 @@ class Chatchart(commands.Cog):
"""
Generates a pie chart, representing the last 5000 messages in the specified channel.
"""
e = discord.Embed(description="Loading...", colour=0x00ccff)
e = discord.Embed(description="Loading...", colour=0x00CCFF)
e.set_thumbnail(url="https://i.imgur.com/vSp4xRk.gif")
em = await ctx.send(embed=e)
@@ -119,9 +122,9 @@ class Chatchart(commands.Cog):
msg_data["users"][whole_name]["msgcount"] = 1
msg_data["total count"] += 1
if msg_data['users'] == {}:
if msg_data["users"] == {}:
await em.delete()
return await ctx.message.channel.send(f'Only bots have sent messages in {channel.mention}')
return await ctx.message.channel.send(f"Only bots have sent messages in {channel.mention}")
for usr in msg_data["users"]:
pd = float(msg_data["users"][usr]["msgcount"]) / float(msg_data["total count"])
@@ -129,12 +132,7 @@ class Chatchart(commands.Cog):
top_ten = heapq.nlargest(
20,
[
(x, msg_data["users"][x][y])
for x in msg_data["users"]
for y in msg_data["users"][x]
if y == "percent"
],
[(x, msg_data["users"][x][y]) for x in msg_data["users"] for y in msg_data["users"][x] if y == "percent"],
key=lambda x: x[1],
)
others = 100 - sum(x[1] for x in top_ten)

View File

@@ -14,5 +14,6 @@
"requirements": [
"matplotlib"
],
"type": "COG"
"type": "COG",
"end_user_data_statement": "This cog does not persistently store data or metadata about users."
}