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 .snacktime import Snacktime
__red_end_user_data_statement__ = "This cog does not persistently store data or metadata about users."
async def setup(bot):
bot.add_cog(Snacktime(bot))

View File

@@ -5,5 +5,6 @@
"description" : "snackburr will come around every-so-often if you've asked him to.\nI hear snackburr likes to come around more often when people are partyin.",
"install_msg" : "A snack delivery bear has arrived ʕ•ᴥ• ʔ",
"tags" : ["snack", "snacktime", "snackburr", "party", "party time"],
"disabled" : false
"disabled" : false,
"end_user_data_statement": "This cog does not persistently store data or metadata about users."
}

View File

@@ -124,8 +124,6 @@ SNACKBURR_PHRASES = {
"partakes of",
"ingests",
],
"ENABLE": [
"Oh you guys want snacks?! Aight, I'll come around every so often to hand some out!"
],
"ENABLE": ["Oh you guys want snacks?! Aight, I'll come around every so often to hand some out!"],
"DISABLE": ["You guys don't want snacks anymore? Alright, I'll stop comin around."],
}

View File

@@ -17,6 +17,10 @@ log = logging.getLogger("red.aikaterna.snacktime")
class Snacktime(commands.Cog):
"""Snackburr's passing out pb jars!"""
async def red_delete_data_for_user(self, **kwargs):
""" Nothing to delete """
return
def __init__(self, bot):
self.bot = bot
self.config = Config.get_conf(self, 2712291001, force_registration=True)
@@ -93,9 +97,7 @@ class Snacktime(commands.Cog):
first_phrase = randchoice(SNACKBURR_PHRASES["EAT_BEFORE"])
second_phrase = randchoice(SNACKBURR_PHRASES["EAT_AFTER"])
await ctx.send(
f"`{persona} {ctx.author.display_name} {first_phrase} {second_phrase} {amount} whole pb jars!`"
)
await ctx.send(f"`{persona} {ctx.author.display_name} {first_phrase} {second_phrase} {amount} whole pb jars!`")
@commands.guild_only()
@commands.group()
@@ -121,9 +123,7 @@ class Snacktime(commands.Cog):
msg = f"[Delivering in]: {humanize_list(channel_names)}\n"
msg += f"[Event start delay]: {guild_data['EVENT_START_DELAY']} seconds\n"
msg += (
f"[Event start variance]: {guild_data['EVENT_START_DELAY_VARIANCE']} seconds\n"
)
msg += f"[Event start variance]: {guild_data['EVENT_START_DELAY_VARIANCE']} seconds\n"
msg += f"[Friends status]: {invite_friends}\n"
msg += f"[Messages before event]: {guild_data['MSGS_BEFORE_EVENT']}\n"
msg += f"[Snack amount limit]: {guild_data['SNACK_AMOUNT']} pb\n"
@@ -136,18 +136,14 @@ class Snacktime(commands.Cog):
@snackset.command()
async def errandtime(self, ctx, seconds: int):
"""How long snackburr needs to be out doin errands.. more or less."""
event_start_delay_variance = await self.config.guild(
ctx.guild
).EVENT_START_DELAY_VARIANCE()
event_start_delay_variance = await self.config.guild(ctx.guild).EVENT_START_DELAY_VARIANCE()
if seconds <= event_start_delay_variance:
await ctx.send("errandtime must be greater than errandvariance!")
elif seconds <= 0:
await ctx.send("errandtime must be greater than 0")
else:
await self.config.guild(ctx.guild).EVENT_START_DELAY.set(seconds)
await ctx.send(
f"snackburr's errands will now take around {round(seconds/60, 2)} minutes!"
)
await ctx.send(f"snackburr's errands will now take around {round(seconds/60, 2)} minutes!")
@snackset.command()
async def errandvariance(self, ctx, seconds: int):
@@ -159,9 +155,7 @@ class Snacktime(commands.Cog):
await ctx.send("errandvariance must be 0 or greater!")
else:
await self.config.guild(ctx.guild).EVENT_START_DELAY_VARIANCE.set(seconds)
await ctx.send(
f"snackburr now might be {round(seconds/60, 2)} minutes early or late to snacktime"
)
await ctx.send(f"snackburr now might be {round(seconds/60, 2)} minutes early or late to snacktime")
@snackset.command(name="snacktime")
async def snacktimetime(self, ctx, seconds: int):
@@ -185,9 +179,7 @@ class Snacktime(commands.Cog):
await ctx.send("snackvariance must be 0 or greater!")
else:
await self.config.guild(ctx.guild).SNACK_DURATION_VARIANCE.set(seconds)
await ctx.send(
f"snackburr now may have to leave snacktime {round(seconds/60, 2)} minutes early or late"
)
await ctx.send(f"snackburr now may have to leave snacktime {round(seconds/60, 2)} minutes early or late")
@snackset.command()
async def msgsneeded(self, ctx, amt: int):
@@ -196,9 +188,7 @@ class Snacktime(commands.Cog):
await ctx.send("msgsneeded must be greater than 0")
else:
await self.config.guild(ctx.guild).MSGS_BEFORE_EVENT.set(amt)
await ctx.send(
f"snackburr will now wait until {amt} messages pass until he comes with snacks"
)
await ctx.send(f"snackburr will now wait until {amt} messages pass until he comes with snacks")
@snackset.command()
async def amount(self, ctx, amt: int):
@@ -272,13 +262,9 @@ class Snacktime(commands.Cog):
return
self.snacktimeCheckLock[scid] = True
if seconds < 0:
await ctx.send(
f"I'm not sure where snackburr is.. He's already {round(abs(seconds/60), 2)} minutes late!"
)
await ctx.send(f"I'm not sure where snackburr is.. He's already {round(abs(seconds/60), 2)} minutes late!")
else:
await ctx.send(
f"snackburr's out on errands! I think he'll be back in {round(seconds/60, 2)} minutes"
)
await ctx.send(f"snackburr's out on errands! I think he'll be back in {round(seconds/60, 2)} minutes")
await asyncio.sleep(40)
self.snacktimeCheckLock[scid] = False
@@ -306,20 +292,14 @@ class Snacktime(commands.Cog):
await self.config.channel(message.channel).repeatMissedSnacktimes.set(0)
else:
await message.channel.send(await self.get_response(message, "NO_TAKERS"))
repeat_missed_snacktimes = await self.config.channel(
message.channel
).repeatMissedSnacktimes()
await self.config.channel(message.channel).repeatMissedSnacktimes.set(
repeat_missed_snacktimes + 1
)
repeat_missed_snacktimes = await self.config.channel(message.channel).repeatMissedSnacktimes()
await self.config.channel(message.channel).repeatMissedSnacktimes.set(repeat_missed_snacktimes + 1)
await asyncio.sleep(2)
if (repeat_missed_snacktimes + 1) > 9: # move to a setting
await message.channel.send(await self.get_response(message, "LONELY"))
deliver_channels = await self.config.guild(message.guild).DELIVER_CHANNELS()
new_deliver_channels = deliver_channels.remove(message.channel.id)
await self.config.guild(message.guild).DELIVER_CHANNELS.set(
new_deliver_channels
)
await self.config.guild(message.guild).DELIVER_CHANNELS.set(new_deliver_channels)
await self.config.channel(message.channel).repeatMissedSnacktimes.set(0)
except:
log.error("Snacktime: Failed to send message in startSnack")
@@ -365,9 +345,7 @@ class Snacktime(commands.Cog):
# start snacktime
await self.startSnack(message)
# if no snack coming, schedule one
elif self.snackInProgress.get(scid, False) == False and not self.startLock.get(
scid, False
):
elif self.snackInProgress.get(scid, False) == False and not self.startLock.get(scid, False):
self.msgsPassed[scid] = self.msgsPassed.get(scid, 0) + 1
# check for collisions
msgs_before_event = await self.config.guild(message.guild).MSGS_BEFORE_EVENT()
@@ -385,9 +363,7 @@ class Snacktime(commands.Cog):
log.debug(f"Snacktime: {message.author.name} - I got the Lock")
self.lockRequests[scid] = []
# someone got through already
if self.msgsPassed[
scid
] < msgs_before_event or self.snackInProgress.get(scid, False):
if self.msgsPassed[scid] < msgs_before_event or self.snackInProgress.get(scid, False):
log.debug("Snacktime: Lock: someone got through already.")
return
else:
@@ -404,8 +380,7 @@ class Snacktime(commands.Cog):
log.debug(f"Snacktime: activity: {message.content}")
guild_data = await self.config.guild(message.guild).all()
timeTillSnack = guild_data["EVENT_START_DELAY"] + randint(
-guild_data["EVENT_START_DELAY_VARIANCE"],
guild_data["EVENT_START_DELAY_VARIANCE"],
-guild_data["EVENT_START_DELAY_VARIANCE"], guild_data["EVENT_START_DELAY_VARIANCE"],
)
log.debug(f"Snacktime: {str(timeTillSnack)} seconds till snacktime")
self.snacktimePrediction[scid] = msgTime + guild_data["EVENT_START_DELAY"]
@@ -450,10 +425,7 @@ class Snacktime(commands.Cog):
userWants = False
for agreePhrase in agree_phrases:
# no one word answers
if (
agreePhrase in message.content.lower()
and len(message.content.split()) > 1
):
if agreePhrase in message.content.lower() and len(message.content.split()) > 1:
userWants = True
break
if userWants:
@@ -478,8 +450,7 @@ class Snacktime(commands.Cog):
await bank.set_balance(message.author, b.max_balance)
except Exception as e:
log.info(
f"Failed to send pb message. {message.author.name} didn't get pb\n",
exc_info=True,
f"Failed to send pb message. {message.author.name} didn't get pb\n", exc_info=True,
)
else: