diff options
author | 2020-05-22 20:42:50 +0100 | |
---|---|---|
committer | 2020-05-22 20:42:50 +0100 | |
commit | 376fddaaaa63212fa758f80504571df74156c0f3 (patch) | |
tree | 9cd1648da041f034339b136cb53880551c9aa608 | |
parent | Merge pull request #942 from ks129/python-news-stats (diff) | |
parent | Merge branch 'master' into stats (diff) |
Merge pull request #945 from ks129/stats
-rw-r--r-- | bot/cogs/bot.py | 2 | ||||
-rw-r--r-- | bot/cogs/snekbox.py | 18 | ||||
-rw-r--r-- | bot/cogs/stats.py | 17 |
3 files changed, 36 insertions, 1 deletions
diff --git a/bot/cogs/bot.py b/bot/cogs/bot.py index f6aea51c5..a79b37d25 100644 --- a/bot/cogs/bot.py +++ b/bot/cogs/bot.py @@ -326,6 +326,8 @@ class BotCog(Cog, name="Bot"): log.trace("The code consists only of expressions, not sending instructions") if howto != "": + # Increase amount of codeblock correction in stats + self.bot.stats.incr("codeblock_corrections") howto_embed = Embed(description=howto) bot_message = await msg.channel.send(f"Hey {msg.author.mention}!", embed=howto_embed) self.codeblock_message_ids[msg.id] = bot_message.id diff --git a/bot/cogs/snekbox.py b/bot/cogs/snekbox.py index 6ef659f28..a2a7574d4 100644 --- a/bot/cogs/snekbox.py +++ b/bot/cogs/snekbox.py @@ -206,6 +206,12 @@ class Snekbox(Cog): if paste_link: msg = f"{msg}\nFull output: {paste_link}" + # Collect stats of eval fails + successes + if icon == ":x:": + self.bot.stats.incr("snekbox.python.fail") + else: + self.bot.stats.incr("snekbox.python.success") + response = await ctx.send(msg) self.bot.loop.create_task( wait_for_deletion(response, user_ids=(ctx.author.id,), client=ctx.bot) @@ -293,6 +299,18 @@ class Snekbox(Cog): await ctx.send_help(ctx.command) return + if Roles.helpers in (role.id for role in ctx.author.roles): + self.bot.stats.incr("snekbox_usages.roles.helpers") + else: + self.bot.stats.incr("snekbox_usages.roles.developers") + + if ctx.channel.category_id == Categories.help_in_use: + self.bot.stats.incr("snekbox_usages.channels.help") + elif ctx.channel.id == Channels.bot_commands: + self.bot.stats.incr("snekbox_usages.channels.bot_commands") + else: + self.bot.stats.incr("snekbox_usages.channels.topical") + log.info(f"Received code from {ctx.author} for evaluation:\n{code}") while True: diff --git a/bot/cogs/stats.py b/bot/cogs/stats.py index d253db913..9baf222e2 100644 --- a/bot/cogs/stats.py +++ b/bot/cogs/stats.py @@ -2,8 +2,10 @@ import string from datetime import datetime from discord import Member, Message, Status -from discord.ext.commands import Bot, Cog, Context +from discord.ext.commands import Cog, Context +from discord.ext.tasks import loop +from bot.bot import Bot from bot.constants import Channels, Guild, Stats as StatConf @@ -23,6 +25,7 @@ class Stats(Cog): def __init__(self, bot: Bot): self.bot = bot self.last_presence_update = None + self.update_guild_boost.start() @Cog.listener() async def on_message(self, message: Message) -> None: @@ -101,6 +104,18 @@ class Stats(Cog): self.bot.stats.gauge("guild.status.do_not_disturb", dnd) self.bot.stats.gauge("guild.status.offline", offline) + @loop(hours=1) + async def update_guild_boost(self) -> None: + """Post the server boost level and tier every hour.""" + await self.bot.wait_until_guild_available() + g = self.bot.get_guild(Guild.id) + self.bot.stats.gauge("boost.amount", g.premium_subscription_count) + self.bot.stats.gauge("boost.tier", g.premium_tier) + + def cog_unload(self) -> None: + """Stop the boost statistic task on unload of the Cog.""" + self.update_guild_boost.stop() + def setup(bot: Bot) -> None: """Load the stats cog.""" |