tuxbot-bot/cogs/afk.py

69 lines
2.2 KiB
Python
Raw Normal View History

2018-12-03 01:26:23 +01:00
from discord.ext import commands
2019-05-30 00:59:20 +02:00
import discord
2018-12-03 01:26:23 +01:00
import random
2019-05-30 00:59:20 +02:00
class AFK(commands.Cog):
2018-12-03 01:26:23 +01:00
"""Commandes utilitaires."""
def __init__(self, bot):
self.bot = bot
2019-05-30 00:59:20 +02:00
self.afk_users = []
2018-12-03 01:26:23 +01:00
"""---------------------------------------------------------------------"""
@commands.command(pass_context=True)
2019-05-30 00:59:20 +02:00
async def afk(self, ctx, action: str = ""):
if action.lower() == "list":
try:
await ctx.send(*self.afk_users)
except discord.HTTPException:
await ctx.send("Il n'y a personne d'afk...")
else:
user = ctx.author
self.afk_users.append(user)
msgs = ["s'absente de discord quelques instants",
"se casse de son pc",
"va sortir son chien",
"reviens bientôt",
"va nourrir son cochon",
"va manger des cookies",
"va manger de la poutine",
"va faire caca",
"va faire pipi"]
await ctx.send(f"**{user.mention}** {random.choice(msgs)}...")
2018-12-03 01:26:23 +01:00
"""---------------------------------------------------------------------"""
2019-05-30 00:59:20 +02:00
@commands.Cog.listener()
async def on_message(self, message):
if message.author.bot \
or message.guild.id != int(self.bot.config.main_server_id):
return
2018-12-03 01:26:23 +01:00
2019-05-30 00:59:20 +02:00
user = message.author
2018-12-03 01:26:23 +01:00
2019-05-30 00:59:20 +02:00
if user in self.afk_users \
and message.content != self.bot.config.prefix[0] + "afk":
self.afk_users.remove(user)
2018-12-03 01:26:23 +01:00
msgs = ["a réssuscité",
"est de nouveau parmi nous",
"a fini de faire caca",
"a fini d'uriner",
"n'est plus mort",
"est de nouveau sur son PC",
"a fini de manger sa poutine",
"a fini de danser",
"s'est réveillé",
"est de retour dans ce monde cruel"]
2019-05-30 00:59:20 +02:00
await message.channel.send(f"**{user.mention}**"
f" {random.choice(msgs)}...")
2018-12-03 01:26:23 +01:00
def setup(bot):
bot.add_cog(AFK(bot))