Clone from git.gnous.eu/Gnous/tuxbot
This commit is contained in:
parent
d85a5b8005
commit
ed4b1bf866
37 changed files with 2234 additions and 1797 deletions
0
README
Normal file → Executable file
0
README
Normal file → Executable file
85
bot.py
85
bot.py
|
@ -1,28 +1,27 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
__author__ = ["Romain", "Maël / Outout"]
|
__author__ = "Maël / Outout | Romain"
|
||||||
__licence__ = "WTFPL Licence 2.0"
|
__licence__ = "WTFPL Licence 2.0"
|
||||||
|
|
||||||
from discord.ext import commands
|
import copy
|
||||||
|
import datetime
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
import traceback
|
||||||
|
|
||||||
|
import aiohttp
|
||||||
import discord
|
import discord
|
||||||
|
from discord.ext import commands
|
||||||
|
|
||||||
|
import cogs.utils.cli_colors as colors
|
||||||
|
import config
|
||||||
from cogs.utils import checks
|
from cogs.utils import checks
|
||||||
|
|
||||||
import datetime
|
l_extensions = (
|
||||||
import json
|
|
||||||
import copy
|
|
||||||
import traceback
|
|
||||||
import sys
|
|
||||||
import os
|
|
||||||
import aiohttp
|
|
||||||
|
|
||||||
import config
|
|
||||||
import cogs.utils.cli_colors as colors
|
|
||||||
|
|
||||||
l_extensions = [
|
|
||||||
|
|
||||||
'cogs.admin',
|
'cogs.admin',
|
||||||
# 'cogs.afk',
|
'cogs.afk',
|
||||||
|
'cogs.atc',
|
||||||
'cogs.basics',
|
'cogs.basics',
|
||||||
'cogs.ci',
|
'cogs.ci',
|
||||||
'cogs.cog_manager',
|
'cogs.cog_manager',
|
||||||
|
@ -33,60 +32,71 @@ l_extensions = [
|
||||||
'cogs.search',
|
'cogs.search',
|
||||||
'cogs.send_logs',
|
'cogs.send_logs',
|
||||||
'cogs.sondage',
|
'cogs.sondage',
|
||||||
'cogs.utility'
|
'cogs.utility',
|
||||||
]
|
'cogs.vocal',
|
||||||
|
)
|
||||||
|
|
||||||
help_attrs = dict(hidden=True, in_help=True, name="DONOTUSE")
|
help_attrs = dict(hidden=True, in_help=True, name="DONOTUSE")
|
||||||
|
|
||||||
|
|
||||||
class TuxBot(commands.Bot):
|
class TuxBot(commands.Bot):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
self.uptime = datetime.datetime.utcnow()
|
||||||
self.config = config
|
self.config = config
|
||||||
super().__init__(command_prefix=self.config.prefix[0],
|
super().__init__(command_prefix=self.config.prefix[0],
|
||||||
description=self.config.description,
|
description=self.config.description,
|
||||||
pm_help=None,
|
pm_help=None,
|
||||||
help_attrs=help_attrs)
|
help_command = None
|
||||||
|
)
|
||||||
|
|
||||||
self.client_id = self.config.client_id
|
self.client_id = self.config.client_id
|
||||||
self.session = aiohttp.ClientSession(loop=self.loop)
|
self.session = aiohttp.ClientSession(loop=self.loop)
|
||||||
self._events = []
|
self._events = []
|
||||||
|
|
||||||
|
|
||||||
self.add_command(self.do)
|
self.add_command(self.do)
|
||||||
|
|
||||||
for extension in l_extensions:
|
for extension in l_extensions:
|
||||||
try:
|
try:
|
||||||
self.load_extension(extension)
|
self.load_extension(extension)
|
||||||
print(f"{colors.text_colors.GREEN}\"{extension}\" chargé !{colors.ENDC}")
|
print(f"{colors.text_colors.GREEN}\"{extension}\""
|
||||||
|
f" chargé !{colors.ENDC}")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"{colors.text_colors.RED}Impossible de charger l'extension {extension}\n{type(e).__name__}: {e}{colors.ENDC}", file=sys.stderr)
|
print(f"{colors.text_colors.RED}"
|
||||||
|
f"Impossible de charger l'extension {extension}\n"
|
||||||
|
f"{type(e).__name__}: {e}{colors.ENDC}", file=sys.stderr)
|
||||||
|
|
||||||
async def on_command_error(self, ctx, error):
|
async def on_command_error(self, ctx, error):
|
||||||
if isinstance(error, commands.NoPrivateMessage):
|
if isinstance(error, commands.NoPrivateMessage):
|
||||||
await ctx.author.send('Cette commande ne peut pas être utilisee en message privee.')
|
await ctx.author.send('Cette commande ne peut pas être utilisée '
|
||||||
|
'en message privé.')
|
||||||
elif isinstance(error, commands.DisabledCommand):
|
elif isinstance(error, commands.DisabledCommand):
|
||||||
await ctx.author.send('Desoler mais cette commande est desactive, elle ne peut donc pas être utilisée.')
|
await ctx.author.send('Desolé mais cette commande est desactivée, '
|
||||||
|
'elle ne peut donc pas être utilisée.')
|
||||||
elif isinstance(error, commands.CommandInvokeError):
|
elif isinstance(error, commands.CommandInvokeError):
|
||||||
print(f'In {ctx.command.qualified_name}:', file=sys.stderr)
|
print(f'In {ctx.command.qualified_name}:', file=sys.stderr)
|
||||||
traceback.print_tb(error.original.__traceback__)
|
traceback.print_tb(error.original.__traceback__)
|
||||||
print(f'{error.original.__class__.__name__}: {error.original}', file=sys.stderr)
|
print(f'{error.original.__class__.__name__}: {error.original}',
|
||||||
|
file=sys.stderr)
|
||||||
|
|
||||||
async def on_ready(self):
|
async def on_ready(self):
|
||||||
if not hasattr(self, 'uptime'):
|
|
||||||
self.uptime = datetime.datetime.utcnow()
|
|
||||||
|
|
||||||
log_channel_id = self.get_channel(int(self.config.log_channel_id))
|
log_channel_id = self.get_channel(int(self.config.log_channel_id))
|
||||||
|
|
||||||
print('\n\n---------------------')
|
print('\n\n---------------------')
|
||||||
print('CONNECTÉ :')
|
print('CONNECTÉ :')
|
||||||
print(f'Nom d\'utilisateur: {self.user} {colors.text_style.DIM}(ID: {self.user.id}){colors.ENDC}')
|
print(f'Nom d\'utilisateur: {self.user} {colors.text_style.DIM}'
|
||||||
print(f'Channel de log: {log_channel_id} {colors.text_style.DIM}(ID: {log_channel_id.id}){colors.ENDC}')
|
f'(ID: {self.user.id}){colors.ENDC}')
|
||||||
|
print(f'Salon de journalisation: {log_channel_id} {colors.text_style.DIM}'
|
||||||
|
f'(ID: {log_channel_id.id}){colors.ENDC}')
|
||||||
print(f'Prefix: {self.config.prefix[0]}')
|
print(f'Prefix: {self.config.prefix[0]}')
|
||||||
print('Merci d\'utiliser TuxBot')
|
print('Merci d\'utiliser TuxBot')
|
||||||
print('---------------------\n\n')
|
print('---------------------\n\n')
|
||||||
|
|
||||||
await self.change_presence(status=discord.Status.dnd, activity=discord.Game(name=self.config.game))
|
await self.change_presence(status=discord.Status.dnd,
|
||||||
|
activity=discord.Game(
|
||||||
|
name=self.config.game),
|
||||||
|
)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
async def on_resumed():
|
async def on_resumed():
|
||||||
print('resumed...')
|
print('resumed...')
|
||||||
|
|
||||||
|
@ -97,24 +107,27 @@ class TuxBot(commands.Bot):
|
||||||
try:
|
try:
|
||||||
await self.process_commands(message)
|
await self.process_commands(message)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f'{colors.text_colors.RED}Erreur rencontré : \n {type(e).__name__}: {e}{colors.ENDC} \n \n')
|
print(f'{colors.text_colors.RED}Erreur rencontré : \n'
|
||||||
|
f' {type(e).__name__}: {e}{colors.ENDC} \n \n')
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
super().run(self.config.token, reconnect=True)
|
super().run(self.config.token, reconnect=True)
|
||||||
|
|
||||||
@checks.has_permissions(administrator=True)
|
@checks.has_permissions(administrator=True)
|
||||||
@commands.command(pass_context=True, hidden=True)
|
@commands.command(pass_context=True, hidden=True)
|
||||||
async def do(ctx, times: int, *, command):
|
async def do(self, ctx, times: int, *, command):
|
||||||
"""Repeats a command a specified number of times."""
|
"""Repeats a command a specified number of times."""
|
||||||
msg = copy.copy(ctx.message)
|
msg = copy.copy(ctx.message)
|
||||||
msg.content = command
|
msg.content = command
|
||||||
for i in range(times):
|
for i in range(times):
|
||||||
await bot.process_commands(msg)
|
await self.process_commands(msg)
|
||||||
|
|
||||||
|
|
||||||
## LOAD ##
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
if os.path.exists('config.py') is not True:
|
if os.path.exists('config.py') is not True:
|
||||||
print(f"{colors.text_colors.RED}Veuillez créer le fichier config.py{colors.ENDC}"); exit()
|
print(f"{colors.text_colors.RED}"
|
||||||
|
f"Veuillez créer le fichier config.py{colors.ENDC}")
|
||||||
|
exit()
|
||||||
|
|
||||||
tuxbot = TuxBot()
|
tuxbot = TuxBot()
|
||||||
tuxbot.run()
|
tuxbot.run()
|
||||||
|
|
0
cogs/.DS_Store
vendored
Normal file → Executable file
0
cogs/.DS_Store
vendored
Normal file → Executable file
383
cogs/admin.py
383
cogs/admin.py
|
@ -1,28 +1,32 @@
|
||||||
from discord.ext import commands
|
from discord.ext import commands
|
||||||
import discord
|
import discord
|
||||||
import aiohttp
|
|
||||||
import asyncio
|
import asyncio
|
||||||
import time
|
|
||||||
from .utils import checks
|
from .utils import checks
|
||||||
|
|
||||||
from .utils.checks import get_user
|
from .utils.checks import get_user
|
||||||
|
|
||||||
import json
|
import traceback
|
||||||
import random
|
import textwrap
|
||||||
|
from contextlib import redirect_stdout
|
||||||
import datetime
|
import inspect
|
||||||
|
import io
|
||||||
import requests
|
|
||||||
|
|
||||||
|
|
||||||
class Admin:
|
class Admin(commands.Cog):
|
||||||
"""Commandes secrètes d'administration."""
|
"""Commandes secrètes d'administration."""
|
||||||
|
|
||||||
|
|
||||||
def __init__(self, bot):
|
def __init__(self, bot):
|
||||||
self.bot = bot
|
self.bot = bot
|
||||||
|
self._last_result = None
|
||||||
|
self.sessions = set()
|
||||||
|
|
||||||
"""--------------------------------------------------------------------------------------------------------------------------"""
|
@staticmethod
|
||||||
|
def cleanup_code(content):
|
||||||
|
if content.startswith('```') and content.endswith('```'):
|
||||||
|
return '\n'.join(content.split('\n')[1:-1])
|
||||||
|
return content.strip('` \n')
|
||||||
|
|
||||||
|
"""---------------------------------------------------------------------"""
|
||||||
|
|
||||||
@checks.has_permissions(administrator=True)
|
@checks.has_permissions(administrator=True)
|
||||||
@commands.command(pass_context=True)
|
@commands.command(pass_context=True)
|
||||||
|
@ -32,17 +36,18 @@ class Admin:
|
||||||
if user:
|
if user:
|
||||||
try:
|
try:
|
||||||
await user.ban(reason=reason)
|
await user.ban(reason=reason)
|
||||||
return_msg = "`{}` a été banni\n".format(user.mention)
|
return_msg = f"`{user.mention}` a été banni\n"
|
||||||
if reason:
|
if reason:
|
||||||
return_msg += "raison : `{}`".format(reason)
|
return_msg += f"raison : `{reason}`"
|
||||||
return_msg += "."
|
return_msg += "."
|
||||||
await ctx.send(return_msg)
|
await ctx.send(return_msg)
|
||||||
except discord.Forbidden:
|
except discord.Forbidden:
|
||||||
await ctx.send('Impossible de bannir cet user, probleme de permission.')
|
await ctx.send('Impossible de bannir cet user,'
|
||||||
|
' probleme de permission.')
|
||||||
else:
|
else:
|
||||||
return await ctx.send('Impossible de trouver l\'user.')
|
return await ctx.send('Impossible de trouver l\'user.')
|
||||||
|
|
||||||
"""--------------------------------------------------------------------------------------------------------------------------"""
|
"""---------------------------------------------------------------------"""
|
||||||
|
|
||||||
@checks.has_permissions(administrator=True)
|
@checks.has_permissions(administrator=True)
|
||||||
@commands.command(pass_context=True)
|
@commands.command(pass_context=True)
|
||||||
|
@ -52,17 +57,18 @@ class Admin:
|
||||||
if user:
|
if user:
|
||||||
try:
|
try:
|
||||||
await user.kick(reason=reason)
|
await user.kick(reason=reason)
|
||||||
return_msg = "`{}` a été kické\n".format(user.mention)
|
return_msg = f"`{user.mention}` a été kické\n"
|
||||||
if reason:
|
if reason:
|
||||||
return_msg += "raison : `{}`".format(reason)
|
return_msg += f"raison : `{reason}`"
|
||||||
return_msg += "."
|
return_msg += "."
|
||||||
await ctx.send(return_msg)
|
await ctx.send(return_msg)
|
||||||
except discord.Forbidden:
|
except discord.Forbidden:
|
||||||
await ctx.send('Impossible de kicker cet user, probleme de permission.')
|
await ctx.send('Impossible de kicker cet user,'
|
||||||
|
' probleme de permission.')
|
||||||
else:
|
else:
|
||||||
return await ctx.send('Impossible de trouver l\'user.')
|
return await ctx.send('Impossible de trouver l\'user.')
|
||||||
|
|
||||||
"""--------------------------------------------------------------------------------------------------------------------------"""
|
"""---------------------------------------------------------------------"""
|
||||||
|
|
||||||
@checks.has_permissions(administrator=True)
|
@checks.has_permissions(administrator=True)
|
||||||
@commands.command(name='clear', pass_context=True)
|
@commands.command(name='clear', pass_context=True)
|
||||||
|
@ -70,22 +76,23 @@ class Admin:
|
||||||
"""Clear <number> of message(s)"""
|
"""Clear <number> of message(s)"""
|
||||||
try:
|
try:
|
||||||
await ctx.message.delete()
|
await ctx.message.delete()
|
||||||
except:
|
except Exception:
|
||||||
print("Impossible de supprimer le message \"" + str(ctx.message.content) + "\"")
|
print(f"Impossible de supprimer le message "
|
||||||
|
f"\"{str(ctx.message.content)}\"")
|
||||||
if number < 1000:
|
if number < 1000:
|
||||||
async for message in ctx.message.channel.history(limit=number):
|
|
||||||
try:
|
try:
|
||||||
await message.delete()
|
await ctx.message.channel.purge(limit=number)
|
||||||
except Exception as e: # TODO : A virer dans l'event on_error
|
except Exception as e: # TODO : A virer dans l'event on_error
|
||||||
if silent is not True:
|
if silent is not True:
|
||||||
await ctx.send(':sob: Une erreur est survenue : \n {}: {}'.format(type(e).__name__, e))
|
await ctx.send(f':sob: Une erreur est survenue : \n'
|
||||||
|
f' {type(e).__name__}: {e}')
|
||||||
if silent is not True:
|
if silent is not True:
|
||||||
await ctx.send("Hop voila j'ai viré des messages! Hello World")
|
await ctx.send("Hop voila j'ai viré des messages! Hello World")
|
||||||
print(str(number)+" messages ont été supprimés")
|
print(f"{str(number)} messages ont été supprimés")
|
||||||
else:
|
else:
|
||||||
await ctx.send('Trop de messages, entre un nombre < 1000')
|
await ctx.send('Trop de messages, entre un nombre < 1000')
|
||||||
|
|
||||||
"""--------------------------------------------------------------------------------------------------------------------------"""
|
"""---------------------------------------------------------------------"""
|
||||||
|
|
||||||
@checks.has_permissions(administrator=True)
|
@checks.has_permissions(administrator=True)
|
||||||
@commands.command(name='say', pass_context=True)
|
@commands.command(name='say', pass_context=True)
|
||||||
|
@ -94,51 +101,57 @@ class Admin:
|
||||||
try:
|
try:
|
||||||
try:
|
try:
|
||||||
await ctx.message.delete()
|
await ctx.message.delete()
|
||||||
except:
|
except Exception:
|
||||||
print("Impossible de supprimer le message \"" + str(ctx.message.content) + "\"")
|
print(f"Impossible de supprimer le message "
|
||||||
|
f"\"{str(ctx.message.content)}\"")
|
||||||
await ctx.send(tosay)
|
await ctx.send(tosay)
|
||||||
except Exception as e: # TODO : A virer dans l'event on_error
|
except Exception as e: # TODO : A virer dans l'event on_error
|
||||||
await ctx.send(':sob: Une erreur est survenue : \n {}: {}'.format(type(e).__name__, e))
|
await ctx.send(f':sob: Une erreur est survenue : \n'
|
||||||
|
f' {type(e).__name__}: {e}')
|
||||||
|
|
||||||
"""--------------------------------------------------------------------------------------------------------------------------"""
|
"""---------------------------------------------------------------------"""
|
||||||
|
|
||||||
@checks.has_permissions(administrator=True)
|
@checks.has_permissions(administrator=True)
|
||||||
@commands.command(name='sayto', pass_context=True)
|
@commands.command(name='sayto', pass_context=True)
|
||||||
async def _sayto(self, ctx, id:int, *, tosay:str):
|
async def _sayto(self, ctx, channel_id: int, *, tosay: str):
|
||||||
"""Say a message in the <id> channel"""
|
"""Say a message in the <channel_id> channel"""
|
||||||
try:
|
try:
|
||||||
chan = self.bot.get_channel(id)
|
chan = self.bot.get_channel(channel_id)
|
||||||
try:
|
try:
|
||||||
await ctx.message.delete()
|
await ctx.message.delete()
|
||||||
except:
|
except Exception:
|
||||||
print("Impossible de supprimer le message \"" + str(ctx.message.content) + "\"")
|
print(f"Impossible de supprimer le message "
|
||||||
|
f"\"{str(ctx.message.content)}\"")
|
||||||
try:
|
try:
|
||||||
await chan.send(tosay)
|
await chan.send(tosay)
|
||||||
except Exception as e:
|
except Exception:
|
||||||
print("Impossible d'envoyer le message dans " + str(id))
|
print(f"Impossible d'envoyer le message dans {str(channel_id)}")
|
||||||
except Exception as e: # TODO : A virer dans l'event on_error
|
except Exception as e: # TODO : A virer dans l'event on_error
|
||||||
await ctx.send(':sob: Une erreur est survenue : \n {}: {}'.format(type(e).__name__, e))
|
await ctx.send(f':sob: Une erreur est survenue : \n'
|
||||||
|
f' {type(e).__name__}: {e}')
|
||||||
|
|
||||||
"""--------------------------------------------------------------------------------------------------------------------------"""
|
"""---------------------------------------------------------------------"""
|
||||||
|
|
||||||
@checks.has_permissions(administrator=True)
|
@checks.has_permissions(administrator=True)
|
||||||
@commands.command(name='sayto_dm', pass_context=True)
|
@commands.command(name='sayto_dm', pass_context=True)
|
||||||
async def _sayto_dm(self, ctx, id:int, *, tosay:str):
|
async def _sayto_dm(self, ctx, user_id: int, *, tosay: str):
|
||||||
"""Say a message to the <id> user"""
|
"""Say a message to the <user_id> user"""
|
||||||
try:
|
try:
|
||||||
user = self.bot.get_user(id)
|
user = self.bot.get_user(user_id)
|
||||||
try:
|
try:
|
||||||
await ctx.message.delete()
|
await ctx.message.delete()
|
||||||
except:
|
except Exception:
|
||||||
print("Impossible de supprimer le message \"" + str(ctx.message.content) + "\"")
|
print(f"Impossible de supprimer le message "
|
||||||
|
f"\"{str(ctx.message.content)}\"")
|
||||||
try:
|
try:
|
||||||
await user.send(tosay)
|
await user.send(tosay)
|
||||||
except Exception as e:
|
except Exception:
|
||||||
print("Impossible d'envoyer le message dans " + str(id))
|
print(f"Impossible d'envoyer le message dans {str(user_id)}")
|
||||||
except Exception as e: # TODO : A virer dans l'event on_error
|
except Exception as e: # TODO : A virer dans l'event on_error
|
||||||
await ctx.send(':sob: Une erreur est survenue : \n {}: {}'.format(type(e).__name__, e))
|
await ctx.send(f':sob: Une erreur est survenue : \n'
|
||||||
|
f' {type(e).__name__}: {e}')
|
||||||
|
|
||||||
"""--------------------------------------------------------------------------------------------------------------------------"""
|
"""---------------------------------------------------------------------"""
|
||||||
|
|
||||||
@checks.has_permissions(administrator=True)
|
@checks.has_permissions(administrator=True)
|
||||||
@commands.command(name='editsay', pass_context=True)
|
@commands.command(name='editsay', pass_context=True)
|
||||||
|
@ -147,18 +160,20 @@ class Admin:
|
||||||
try:
|
try:
|
||||||
try:
|
try:
|
||||||
await ctx.message.delete()
|
await ctx.message.delete()
|
||||||
except:
|
except Exception:
|
||||||
print("Impossible de supprimer le message \"" + str(ctx.message.content) + "\"")
|
print(f"Impossible de supprimer le message "
|
||||||
|
f"\"{str(ctx.message.content)}\"")
|
||||||
toedit = await ctx.channel.get_message(id)
|
toedit = await ctx.channel.get_message(id)
|
||||||
except discord.errors.NotFound:
|
except discord.errors.NotFound:
|
||||||
await ctx.send("Impossible de trouver le message avec l'id `{}` sur ce salon".format(id))
|
await ctx.send(f"Impossible de trouver le message avec l'id "
|
||||||
|
f"`{id}` sur ce salon")
|
||||||
return
|
return
|
||||||
try:
|
try:
|
||||||
await toedit.edit(content=str(new_content))
|
await toedit.edit(content=str(new_content))
|
||||||
except discord.errors.Forbidden:
|
except discord.errors.Forbidden:
|
||||||
await ctx.send("J'ai po les perms pour editer mes messages :(")
|
await ctx.send("J'ai po les perms pour editer mes messages :(")
|
||||||
|
|
||||||
"""--------------------------------------------------------------------------------------------------------------------------"""
|
"""---------------------------------------------------------------------"""
|
||||||
|
|
||||||
@checks.has_permissions(administrator=True)
|
@checks.has_permissions(administrator=True)
|
||||||
@commands.command(name='addreaction', pass_context=True)
|
@commands.command(name='addreaction', pass_context=True)
|
||||||
|
@ -167,18 +182,20 @@ class Admin:
|
||||||
try:
|
try:
|
||||||
try:
|
try:
|
||||||
await ctx.message.delete()
|
await ctx.message.delete()
|
||||||
except:
|
except Exception:
|
||||||
print("Impossible de supprimer le message \"" + str(ctx.message.content) + "\"")
|
print(f"Impossible de supprimer le message "
|
||||||
|
f"\"{str(ctx.message.content)}\"")
|
||||||
toadd = await ctx.channel.get_message(id)
|
toadd = await ctx.channel.get_message(id)
|
||||||
except discord.errors.NotFound:
|
except discord.errors.NotFound:
|
||||||
await ctx.send("Impossible de trouver le message avec l'id `{}` sur ce salon".format(id))
|
await ctx.send(f"Impossible de trouver le message avec l'id "
|
||||||
|
f"`{id}` sur ce salon")
|
||||||
return
|
return
|
||||||
try:
|
try:
|
||||||
await toadd.add_reaction(reaction)
|
await toadd.add_reaction(reaction)
|
||||||
except discord.errors.Forbidden:
|
except discord.errors.Forbidden:
|
||||||
await ctx.send("J'ai po les perms pour ajouter des réactions :(")
|
await ctx.send("J'ai po les perms pour ajouter des réactions :(")
|
||||||
|
|
||||||
"""--------------------------------------------------------------------------------------------------------------------------"""
|
"""---------------------------------------------------------------------"""
|
||||||
|
|
||||||
@checks.has_permissions(administrator=True)
|
@checks.has_permissions(administrator=True)
|
||||||
@commands.command(name='delete', pass_context=True)
|
@commands.command(name='delete', pass_context=True)
|
||||||
|
@ -187,18 +204,20 @@ class Admin:
|
||||||
try:
|
try:
|
||||||
try:
|
try:
|
||||||
await ctx.message.delete()
|
await ctx.message.delete()
|
||||||
except:
|
except Exception:
|
||||||
print("Impossible de supprimer le message \"" + str(ctx.message.content) + "\"")
|
print(f"Impossible de supprimer le message "
|
||||||
|
f"\"{str(ctx.message.content)}\"")
|
||||||
todelete = await ctx.channel.get_message(id)
|
todelete = await ctx.channel.get_message(id)
|
||||||
except discord.errors.NotFound:
|
except discord.errors.NotFound:
|
||||||
await ctx.send("Impossible de trouver le message avec l'id `{}` sur ce salon".format(id))
|
await ctx.send(f"Impossible de trouver le message avec l'id "
|
||||||
|
f"`{id}` sur ce salon")
|
||||||
return
|
return
|
||||||
try:
|
try:
|
||||||
await todelete.delete()
|
await todelete.delete()
|
||||||
except discord.errors.Forbidden:
|
except discord.errors.Forbidden:
|
||||||
await ctx.send("J'ai po les perms pour supprimer des messages :(")
|
await ctx.send("J'ai po les perms pour supprimer des messages :(")
|
||||||
|
|
||||||
"""--------------------------------------------------------------------------------------------------------------------------"""
|
"""---------------------------------------------------------------------"""
|
||||||
|
|
||||||
@checks.has_permissions(administrator=True)
|
@checks.has_permissions(administrator=True)
|
||||||
@commands.command(name='deletefrom', pass_context=True)
|
@commands.command(name='deletefrom', pass_context=True)
|
||||||
|
@ -208,25 +227,34 @@ class Admin:
|
||||||
chan = self.bot.get_channel(chan_id)
|
chan = self.bot.get_channel(chan_id)
|
||||||
try:
|
try:
|
||||||
await ctx.message.delete()
|
await ctx.message.delete()
|
||||||
except:
|
except Exception:
|
||||||
print("Impossible de supprimer le message \"" + str(ctx.message.content) + "\"")
|
print(f"Impossible de supprimer le message "
|
||||||
|
f"\"{str(ctx.message.content)}\"")
|
||||||
todelete = await chan.get_message(message_id)
|
todelete = await chan.get_message(message_id)
|
||||||
except discord.errors.NotFound:
|
except discord.errors.NotFound:
|
||||||
await ctx.send("Impossible de trouver le message avec l'id `{}` sur le salon".format(id))
|
await ctx.send(f"Impossible de trouver le message avec l'id "
|
||||||
|
f"`{id}` sur le salon")
|
||||||
return
|
return
|
||||||
try:
|
try:
|
||||||
await todelete.delete()
|
await todelete.delete()
|
||||||
except discord.errors.Forbidden:
|
except discord.errors.Forbidden:
|
||||||
await ctx.send("J'ai po les perms pour supprimer le message :(")
|
await ctx.send("J'ai po les perms pour supprimer le message :(")
|
||||||
|
|
||||||
"""--------------------------------------------------------------------------------------------------------------------------"""
|
"""---------------------------------------------------------------------"""
|
||||||
|
|
||||||
@checks.has_permissions(administrator=True)
|
@checks.has_permissions(administrator=True)
|
||||||
@commands.command(name='embed', pass_context=True)
|
@commands.command(name='embed', pass_context=True)
|
||||||
async def _embed(self, ctx, *, msg: str = "help"):
|
async def _embed(self, ctx, *, msg: str = "help"):
|
||||||
"""Send an embed"""
|
"""Send an embed"""
|
||||||
if msg != "help":
|
if msg != "help":
|
||||||
ptext = title = description = image = thumbnail = color = footer = author = None
|
ptext = title \
|
||||||
|
= description \
|
||||||
|
= image \
|
||||||
|
= thumbnail \
|
||||||
|
= color \
|
||||||
|
= footer \
|
||||||
|
= author \
|
||||||
|
= None
|
||||||
timestamp = discord.Embed.Empty
|
timestamp = discord.Embed.Empty
|
||||||
embed_values = msg.split('|')
|
embed_values = msg.split('|')
|
||||||
for i in embed_values:
|
for i in embed_values:
|
||||||
|
@ -253,7 +281,8 @@ class Admin:
|
||||||
elif i.strip().lower().startswith('timestamp'):
|
elif i.strip().lower().startswith('timestamp'):
|
||||||
timestamp = ctx.message.created_at
|
timestamp = ctx.message.created_at
|
||||||
else:
|
else:
|
||||||
if description is None and not i.strip().lower().startswith('field='):
|
if description is None and not i.strip()\
|
||||||
|
.lower().startswith('field='):
|
||||||
description = i.strip()
|
description = i.strip()
|
||||||
|
|
||||||
if color:
|
if color:
|
||||||
|
@ -262,39 +291,58 @@ class Admin:
|
||||||
if not color.startswith('0x'):
|
if not color.startswith('0x'):
|
||||||
color = '0x' + color
|
color = '0x' + color
|
||||||
|
|
||||||
if ptext is title is description is image is thumbnail is color is footer is author is None and 'field=' not in msg:
|
if ptext \
|
||||||
|
is title \
|
||||||
|
is description \
|
||||||
|
is image \
|
||||||
|
is thumbnail \
|
||||||
|
is color \
|
||||||
|
is footer \
|
||||||
|
is author \
|
||||||
|
is None \
|
||||||
|
and 'field=' not in msg:
|
||||||
try:
|
try:
|
||||||
await ctx.message.delete()
|
await ctx.message.delete()
|
||||||
except:
|
except Exception:
|
||||||
print("Impossible de supprimer le message \"" + str(ctx.message.content) + "\"")
|
print("Impossible de supprimer le message \"" + str(
|
||||||
|
ctx.message.content) + "\"")
|
||||||
return await ctx.send(content=None,
|
return await ctx.send(content=None,
|
||||||
embed=discord.Embed(description=msg))
|
embed=discord.Embed(description=msg))
|
||||||
|
|
||||||
if color:
|
if color:
|
||||||
em = discord.Embed(timestamp=timestamp, title=title, description=description, color=int(color, 16))
|
em = discord.Embed(timestamp=timestamp, title=title,
|
||||||
|
description=description,
|
||||||
|
color=int(color, 16))
|
||||||
else:
|
else:
|
||||||
em = discord.Embed(timestamp=timestamp, title=title, description=description)
|
em = discord.Embed(timestamp=timestamp, title=title,
|
||||||
|
description=description)
|
||||||
for i in embed_values:
|
for i in embed_values:
|
||||||
if i.strip().lower().startswith('field='):
|
if i.strip().lower().startswith('field='):
|
||||||
field_inline = True
|
field_inline = True
|
||||||
field = i.strip().lstrip('field=')
|
field = i.strip().lstrip('field=')
|
||||||
field_name, field_value = field.split('value=')
|
field_name, field_value = field.split('value=')
|
||||||
if 'inline=' in field_value:
|
if 'inline=' in field_value:
|
||||||
field_value, field_inline = field_value.split('inline=')
|
field_value, field_inline = field_value.split(
|
||||||
if 'false' in field_inline.lower() or 'no' in field_inline.lower():
|
'inline=')
|
||||||
|
if 'false' in field_inline.lower() \
|
||||||
|
or 'no' in field_inline.lower():
|
||||||
field_inline = False
|
field_inline = False
|
||||||
field_name = field_name.strip().lstrip('name=')
|
field_name = field_name.strip().lstrip('name=')
|
||||||
em.add_field(name=field_name, value=field_value.strip(), inline=field_inline)
|
em.add_field(name=field_name, value=field_value.strip(),
|
||||||
|
inline=field_inline)
|
||||||
if author:
|
if author:
|
||||||
if 'icon=' in author:
|
if 'icon=' in author:
|
||||||
text, icon = author.split('icon=')
|
text, icon = author.split('icon=')
|
||||||
if 'url=' in icon:
|
if 'url=' in icon:
|
||||||
em.set_author(name=text.strip()[5:], icon_url=icon.split('url=')[0].strip(), url=icon.split('url=')[1].strip())
|
em.set_author(name=text.strip()[5:],
|
||||||
|
icon_url=icon.split('url=')[0].strip(),
|
||||||
|
url=icon.split('url=')[1].strip())
|
||||||
else:
|
else:
|
||||||
em.set_author(name=text.strip()[5:], icon_url=icon)
|
em.set_author(name=text.strip()[5:], icon_url=icon)
|
||||||
else:
|
else:
|
||||||
if 'url=' in author:
|
if 'url=' in author:
|
||||||
em.set_author(name=author.split('url=')[0].strip()[5:], url=author.split('url=')[1].strip())
|
em.set_author(name=author.split('url=')[0].strip()[5:],
|
||||||
|
url=author.split('url=')[1].strip())
|
||||||
else:
|
else:
|
||||||
em.set_author(name=author)
|
em.set_author(name=author)
|
||||||
|
|
||||||
|
@ -311,25 +359,182 @@ class Admin:
|
||||||
|
|
||||||
try:
|
try:
|
||||||
await ctx.message.delete()
|
await ctx.message.delete()
|
||||||
except:
|
except Exception:
|
||||||
print("Impossible de supprimer le message \"" + str(ctx.message.content) + "\"")
|
print("Impossible de supprimer le message \"" + str(
|
||||||
|
ctx.message.content) + "\"")
|
||||||
await ctx.send(content=ptext, embed=em)
|
await ctx.send(content=ptext, embed=em)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
embed=discord.Embed(title="Aide sur l'utilisation de la commande .embed:")
|
embed = discord.Embed(
|
||||||
embed.add_field(name="Titre:", value="title=<le titre>", inline=True)
|
title="Aide sur l'utilisation de la commande .embed:")
|
||||||
embed.add_field(name="Description:", value="description=<la description>", inline=True)
|
embed.add_field(name="Titre:", value="title=<le titre>",
|
||||||
embed.add_field(name="Couleur:", value="color=<couleur en hexa>", inline=True)
|
inline=True)
|
||||||
embed.add_field(name="Image:", value="image=<url de l'image (en https)>", inline=True)
|
embed.add_field(name="Description:",
|
||||||
embed.add_field(name="Thumbnail:", value="thumbnail=<url de l'image>", inline=True)
|
value="description=<la description>", inline=True)
|
||||||
embed.add_field(name="Auteur:", value="author=<nom de l'auteur>", inline=True)
|
embed.add_field(name="Couleur:", value="color=<couleur en hexa>",
|
||||||
embed.add_field(name="Icon", value="icon=<url de l'image>", inline=True)
|
inline=True)
|
||||||
embed.add_field(name="Footer", value="footer=<le footer>", inline=True)
|
embed.add_field(name="Image:",
|
||||||
embed.set_footer(text="Exemple: .embed title=Un titre | description=Une description | color=3AB35E | field=name=test value=test")
|
value="image=<url de l'image (en https)>",
|
||||||
|
inline=True)
|
||||||
|
embed.add_field(name="Thumbnail:",
|
||||||
|
value="thumbnail=<url de l'image>", inline=True)
|
||||||
|
embed.add_field(name="Auteur:", value="author=<nom de l'auteur>",
|
||||||
|
inline=True)
|
||||||
|
embed.add_field(name="Icon", value="icon=<url de l'image>",
|
||||||
|
inline=True)
|
||||||
|
embed.add_field(name="Footer", value="footer=<le footer>",
|
||||||
|
inline=True)
|
||||||
|
embed.set_footer(text="Exemple: .embed title=Un titre |"
|
||||||
|
" description=Une description |"
|
||||||
|
" color=3AB35E |"
|
||||||
|
" field=name=test value=test")
|
||||||
|
|
||||||
await ctx.send(embed=embed)
|
await ctx.send(embed=embed)
|
||||||
|
|
||||||
"""--------------------------------------------------------------------------------------------------------------------------"""
|
"""---------------------------------------------------------------------"""
|
||||||
|
|
||||||
|
@checks.has_permissions(administrator=True)
|
||||||
|
@commands.command(pass_context=True, hidden=True)
|
||||||
|
async def repl(self, ctx):
|
||||||
|
"""Launches an interactive REPL session."""
|
||||||
|
variables = {
|
||||||
|
'ctx': ctx,
|
||||||
|
'bot': self.bot,
|
||||||
|
'message': ctx.message,
|
||||||
|
'guild': ctx.guild,
|
||||||
|
'channel': ctx.channel,
|
||||||
|
'author': ctx.author,
|
||||||
|
'_': None,
|
||||||
|
}
|
||||||
|
|
||||||
|
if ctx.channel.id in self.sessions:
|
||||||
|
await ctx.send('Already running a REPL session in this channel.'
|
||||||
|
' Exit it with `quit`.')
|
||||||
|
return
|
||||||
|
|
||||||
|
self.sessions.add(ctx.channel.id)
|
||||||
|
await ctx.send(
|
||||||
|
'Enter code to execute or evaluate. `exit()` or `quit` to exit.')
|
||||||
|
|
||||||
|
def check(m):
|
||||||
|
return m.author.id == ctx.author.id and \
|
||||||
|
m.channel.id == ctx.channel.id and \
|
||||||
|
m.content.startswith('`')
|
||||||
|
|
||||||
|
while True:
|
||||||
|
try:
|
||||||
|
response = await self.bot.wait_for('message', check=check,
|
||||||
|
timeout=10.0 * 60.0)
|
||||||
|
except asyncio.TimeoutError:
|
||||||
|
await ctx.send('Exiting REPL session.')
|
||||||
|
self.sessions.remove(ctx.channel.id)
|
||||||
|
break
|
||||||
|
|
||||||
|
cleaned = self.cleanup_code(response.content)
|
||||||
|
|
||||||
|
if cleaned in ('quit', 'exit', 'exit()'):
|
||||||
|
await ctx.send('Exiting.')
|
||||||
|
self.sessions.remove(ctx.channel.id)
|
||||||
|
return
|
||||||
|
|
||||||
|
executor = exec
|
||||||
|
if cleaned.count('\n') == 0:
|
||||||
|
# single statement, potentially 'eval'
|
||||||
|
try:
|
||||||
|
code = compile(cleaned, '<repl session>', 'eval')
|
||||||
|
except SyntaxError:
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
executor = eval
|
||||||
|
|
||||||
|
if executor is exec:
|
||||||
|
try:
|
||||||
|
code = compile(cleaned, '<repl session>', 'exec')
|
||||||
|
except SyntaxError as e:
|
||||||
|
await ctx.send(self.get_syntax_error(e))
|
||||||
|
continue
|
||||||
|
|
||||||
|
variables['message'] = response
|
||||||
|
|
||||||
|
fmt = None
|
||||||
|
stdout = io.StringIO()
|
||||||
|
|
||||||
|
try:
|
||||||
|
with redirect_stdout(stdout):
|
||||||
|
result = executor(code, variables)
|
||||||
|
if inspect.isawaitable(result):
|
||||||
|
result = await result
|
||||||
|
except Exception as e:
|
||||||
|
value = stdout.getvalue()
|
||||||
|
fmt = f'```py\n{value}{traceback.format_exc()}\n```'
|
||||||
|
else:
|
||||||
|
value = stdout.getvalue()
|
||||||
|
if result is not None:
|
||||||
|
fmt = f'```py\n{value}{result}\n```'
|
||||||
|
variables['_'] = result
|
||||||
|
elif value:
|
||||||
|
fmt = f'```py\n{value}\n```'
|
||||||
|
|
||||||
|
try:
|
||||||
|
if fmt is not None:
|
||||||
|
if len(fmt) > 2000:
|
||||||
|
await ctx.send('Content too big to be printed.')
|
||||||
|
else:
|
||||||
|
await ctx.send(fmt)
|
||||||
|
except discord.Forbidden:
|
||||||
|
pass
|
||||||
|
except discord.HTTPException as e:
|
||||||
|
await ctx.send(f'Unexpected error: `{e}`')
|
||||||
|
|
||||||
|
"""---------------------------------------------------------------------"""
|
||||||
|
|
||||||
|
@checks.has_permissions(administrator=True)
|
||||||
|
@commands.command(pass_context=True, hidden=True, name='eval')
|
||||||
|
async def _eval(self, ctx, *, body: str):
|
||||||
|
"""Evaluates a code"""
|
||||||
|
|
||||||
|
env = {
|
||||||
|
'bot': self.bot,
|
||||||
|
'ctx': ctx,
|
||||||
|
'channel': ctx.channel,
|
||||||
|
'author': ctx.author,
|
||||||
|
'guild': ctx.guild,
|
||||||
|
'message': ctx.message,
|
||||||
|
'_': self._last_result
|
||||||
|
}
|
||||||
|
|
||||||
|
env.update(globals())
|
||||||
|
|
||||||
|
body = self.cleanup_code(body)
|
||||||
|
stdout = io.StringIO()
|
||||||
|
|
||||||
|
to_compile = f'async def func():\n{textwrap.indent(body, " ")}'
|
||||||
|
|
||||||
|
try:
|
||||||
|
exec(to_compile, env)
|
||||||
|
except Exception as e:
|
||||||
|
return await ctx.send(f'```py\n{e.__class__.__name__}: {e}\n```')
|
||||||
|
|
||||||
|
func = env['func']
|
||||||
|
try:
|
||||||
|
with redirect_stdout(stdout):
|
||||||
|
ret = await func()
|
||||||
|
except Exception:
|
||||||
|
value = stdout.getvalue()
|
||||||
|
await ctx.send(f'```py\n{value}{traceback.format_exc()}\n```')
|
||||||
|
else:
|
||||||
|
value = stdout.getvalue()
|
||||||
|
try:
|
||||||
|
await ctx.message.add_reaction('\u2705')
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
|
||||||
|
if ret is None:
|
||||||
|
if value:
|
||||||
|
await ctx.send(f'```py\n{value}\n```')
|
||||||
|
else:
|
||||||
|
self._last_result = ret
|
||||||
|
await ctx.send(f'```py\n{value}{ret}\n```')
|
||||||
|
|
||||||
|
|
||||||
def setup(bot):
|
def setup(bot):
|
||||||
|
|
56
cogs/afk.py
56
cogs/afk.py
|
@ -1,37 +1,28 @@
|
||||||
from discord.ext import commands
|
from discord.ext import commands
|
||||||
|
import discord
|
||||||
import random
|
import random
|
||||||
|
|
||||||
|
|
||||||
class AFK:
|
class AFK(commands.Cog):
|
||||||
"""Commandes utilitaires."""
|
"""Commandes utilitaires."""
|
||||||
|
|
||||||
def __init__(self, bot):
|
def __init__(self, bot):
|
||||||
self.bot = bot
|
self.bot = bot
|
||||||
|
self.afk_users = []
|
||||||
|
|
||||||
"""---------------------------------------------------------------------"""
|
"""---------------------------------------------------------------------"""
|
||||||
|
|
||||||
@commands.command(pass_context=True)
|
@commands.command(pass_context=True)
|
||||||
async def afk(self, ctx):
|
async def afk(self, ctx, action: str = ""):
|
||||||
|
|
||||||
user = ctx.message.author
|
|
||||||
|
|
||||||
|
if action.lower() == "list":
|
||||||
try:
|
try:
|
||||||
await user.edit(nick="[AFK] "+str(user.name))
|
await ctx.send(*self.afk_users)
|
||||||
author = ctx.message.author
|
except discord.HTTPException:
|
||||||
channel = await author.create_dm()
|
await ctx.send("Il n'y a personne d'afk...")
|
||||||
await channel.send("Ton pseudo a prit le prefix `[AFK]` pour "
|
else:
|
||||||
"monter que tu es absent,")
|
user = ctx.author
|
||||||
await channel.send("tu auras juste a mettre un message pour que "
|
self.afk_users.append(user)
|
||||||
"je signale ton retour parmis nous et que je "
|
|
||||||
"retire le prefix `[AFK]` de ton pseudo 😉")
|
|
||||||
|
|
||||||
except KeyError:
|
|
||||||
print('')
|
|
||||||
author = ctx.message.author
|
|
||||||
channel = await author.create_dm()
|
|
||||||
await channel.send("Tu auras juste a mettre un message pour que "
|
|
||||||
"je signale ton retour parmis nous 😉")
|
|
||||||
|
|
||||||
msgs = ["s'absente de discord quelques instants",
|
msgs = ["s'absente de discord quelques instants",
|
||||||
"se casse de son pc",
|
"se casse de son pc",
|
||||||
"va sortir son chien",
|
"va sortir son chien",
|
||||||
|
@ -41,22 +32,22 @@ class AFK:
|
||||||
"va manger de la poutine",
|
"va manger de la poutine",
|
||||||
"va faire caca",
|
"va faire caca",
|
||||||
"va faire pipi"]
|
"va faire pipi"]
|
||||||
msg = random.choice(msgs)
|
|
||||||
|
|
||||||
await ctx.send("**{}** {}...".format(ctx.message.author.mention, msg))
|
await ctx.send(f"**{user.mention}** {random.choice(msgs)}...")
|
||||||
|
|
||||||
"""---------------------------------------------------------------------"""
|
"""---------------------------------------------------------------------"""
|
||||||
|
|
||||||
|
@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
|
||||||
|
|
||||||
async def on_message(message):
|
|
||||||
|
|
||||||
ni = str(message.author.nick)
|
|
||||||
|
|
||||||
if ni:
|
|
||||||
ni2 = ni.split(" ")
|
|
||||||
if "[AFK]" in ni2:
|
|
||||||
user = message.author
|
user = message.author
|
||||||
await user.edit(nick=None)
|
|
||||||
|
if user in self.afk_users \
|
||||||
|
and message.content != self.bot.config.prefix[0] + "afk":
|
||||||
|
self.afk_users.remove(user)
|
||||||
|
|
||||||
msgs = ["a réssuscité",
|
msgs = ["a réssuscité",
|
||||||
"est de nouveau parmi nous",
|
"est de nouveau parmi nous",
|
||||||
|
@ -68,10 +59,9 @@ async def on_message(message):
|
||||||
"a fini de danser",
|
"a fini de danser",
|
||||||
"s'est réveillé",
|
"s'est réveillé",
|
||||||
"est de retour dans ce monde cruel"]
|
"est de retour dans ce monde cruel"]
|
||||||
msg = random.choice(msgs)
|
|
||||||
|
|
||||||
await message.channel.send("**{}** {} !".format(
|
await message.channel.send(f"**{user.mention}**"
|
||||||
message.author.mention, msg))
|
f" {random.choice(msgs)}...")
|
||||||
|
|
||||||
|
|
||||||
def setup(bot):
|
def setup(bot):
|
||||||
|
|
124
cogs/atc.py
Executable file
124
cogs/atc.py
Executable file
|
@ -0,0 +1,124 @@
|
||||||
|
import asyncio
|
||||||
|
|
||||||
|
from bs4 import BeautifulSoup
|
||||||
|
import requests
|
||||||
|
import re
|
||||||
|
|
||||||
|
import discord
|
||||||
|
from discord.ext import commands
|
||||||
|
|
||||||
|
|
||||||
|
class ATC(commands.Cog):
|
||||||
|
|
||||||
|
def __init__(self, bot):
|
||||||
|
self.bot = bot
|
||||||
|
self.playing = False
|
||||||
|
self.author = None
|
||||||
|
self.voice = None
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
async def extra(self, ctx, icao):
|
||||||
|
if icao == "stop_playing":
|
||||||
|
if self.playing and (
|
||||||
|
ctx.author.id == self.author.id
|
||||||
|
or ctx.message.channel.permissions_for(ctx.message.author).administrator is True
|
||||||
|
):
|
||||||
|
await self.voice.disconnect()
|
||||||
|
self.playing = False
|
||||||
|
await ctx.send("Écoute terminée !")
|
||||||
|
return "quit"
|
||||||
|
else:
|
||||||
|
await ctx.send("Veuillez specifier un icao")
|
||||||
|
return "quit"
|
||||||
|
if icao == "info":
|
||||||
|
em = discord.Embed(title=f"Infos sur les services utilisés par {self.bot.config.prefix[0]}atc")
|
||||||
|
em.add_field(name="Service pour les communications:",
|
||||||
|
value="[liveatc.net](https://www.liveatc.net/)",
|
||||||
|
inline=False)
|
||||||
|
em.add_field(name="Service pour les plans des aéroports:",
|
||||||
|
value="[universalweather.com](http://www.universalweather.com/)",
|
||||||
|
inline=False)
|
||||||
|
await ctx.send(embed=em)
|
||||||
|
return "quit"
|
||||||
|
|
||||||
|
"""---------------------------------------------------------------------"""
|
||||||
|
|
||||||
|
@commands.command(name="atc", no_pm=True, pass_context=True)
|
||||||
|
async def _atc(self, ctx, icao="stop_playing"):
|
||||||
|
user = ctx.author
|
||||||
|
if not user.voice:
|
||||||
|
await ctx.send('Veuillez aller dans un channel vocal.')
|
||||||
|
return
|
||||||
|
|
||||||
|
if await self.extra(self, ctx, icao) == "quit":
|
||||||
|
return
|
||||||
|
|
||||||
|
if self.playing:
|
||||||
|
await ctx.send(f"Une écoute est déja en court, "
|
||||||
|
f"demandez à {self.author.mention} de faire "
|
||||||
|
f"`.atc stop_playing` pour l'arreter")
|
||||||
|
return
|
||||||
|
self.author = user
|
||||||
|
headers = {
|
||||||
|
'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.35 Safari/537.36',
|
||||||
|
}
|
||||||
|
req = requests.post("https://www.liveatc.net/search/",
|
||||||
|
data={'icao': icao},
|
||||||
|
headers=headers)
|
||||||
|
html = BeautifulSoup(req.text, features="lxml")
|
||||||
|
regex = r"(javascript: pageTracker\._trackPageview\('\/listen\/)(.*)(\'\)\;)"
|
||||||
|
|
||||||
|
possibilities = {}
|
||||||
|
emojis = ['1⃣', '2⃣', '3⃣', '4⃣', '5⃣', '6⃣', '7⃣', '8⃣', '9⃣', '🔟',
|
||||||
|
'0⃣', '🇦', '🇧', '🇨', '🇩', '🇪', '🇫', '🇬', '🇭', '🇮']
|
||||||
|
to_react = []
|
||||||
|
|
||||||
|
idx = 0
|
||||||
|
for a in html.findAll("a", onclick=True):
|
||||||
|
val = a.get('onclick')
|
||||||
|
for match in re.finditer(regex, val):
|
||||||
|
possibilities[idx] = f"{emojis[idx]} - {match.groups()[1]}\n"
|
||||||
|
to_react.append(emojis[idx])
|
||||||
|
idx += 1
|
||||||
|
|
||||||
|
em = discord.Embed(title='Résultats pour : ' + icao,
|
||||||
|
description=str(''.join(possibilities.values())),
|
||||||
|
colour=0x4ECDC4)
|
||||||
|
em.set_image(
|
||||||
|
url=f"http://www.universalweather.com/regusers/mod-bin/uvtp_airport_image?icao={icao}")
|
||||||
|
|
||||||
|
poll_msg = await ctx.send(embed=em)
|
||||||
|
for emote in to_react:
|
||||||
|
await poll_msg.add_reaction(emote)
|
||||||
|
|
||||||
|
def check(reaction, user):
|
||||||
|
return user == ctx.author and reaction.emoji in to_react and \
|
||||||
|
reaction.message.id == poll_msg.id
|
||||||
|
|
||||||
|
async def waiter(future: asyncio.Future):
|
||||||
|
reaction, user = await self.bot.wait_for('reaction_add',
|
||||||
|
check=check)
|
||||||
|
|
||||||
|
future.set_result(emojis.index(reaction.emoji))
|
||||||
|
|
||||||
|
added_emoji = asyncio.Future()
|
||||||
|
self.bot.loop.create_task(waiter(added_emoji))
|
||||||
|
|
||||||
|
while not added_emoji.done():
|
||||||
|
await asyncio.sleep(0.1)
|
||||||
|
|
||||||
|
freq = possibilities[added_emoji.result()].split('- ')[1]
|
||||||
|
|
||||||
|
if possibilities:
|
||||||
|
self.playing = True
|
||||||
|
self.voice = await user.voice.channel.connect()
|
||||||
|
self.voice.play(
|
||||||
|
discord.FFmpegPCMAudio(f"http://yyz.liveatc.net/{freq}"))
|
||||||
|
await poll_msg.delete()
|
||||||
|
await ctx.send(f"Écoute de {freq}")
|
||||||
|
else:
|
||||||
|
await ctx.send(f"Aucun résultat trouvé pour {icao} {freq}")
|
||||||
|
|
||||||
|
|
||||||
|
def setup(bot):
|
||||||
|
bot.add_cog(ATC(bot))
|
|
@ -1,12 +1,13 @@
|
||||||
from discord.ext import commands
|
|
||||||
import discord
|
|
||||||
import platform
|
import platform
|
||||||
import socket
|
import socket
|
||||||
|
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
|
import discord
|
||||||
|
from discord.ext import commands
|
||||||
|
from discord.http import Route
|
||||||
|
|
||||||
class Basics:
|
|
||||||
|
class Basics(commands.Cog):
|
||||||
"""Commandes générales."""
|
"""Commandes générales."""
|
||||||
|
|
||||||
def __init__(self, bot):
|
def __init__(self, bot):
|
||||||
|
@ -14,7 +15,8 @@ class Basics:
|
||||||
|
|
||||||
@commands.command()
|
@commands.command()
|
||||||
async def ping(self, ctx):
|
async def ping(self, ctx):
|
||||||
ping_res = str(subprocess.Popen(["/bin/ping", "-c1", "discordapp.com"], stdout=subprocess.PIPE).stdout.read())
|
ping_res = str(subprocess.Popen(["/bin/ping", "-c1", "discordapp.com"],
|
||||||
|
stdout=subprocess.PIPE).stdout.read())
|
||||||
formated_res = [item for item in ping_res.split() if 'time=' in item]
|
formated_res = [item for item in ping_res.split() if 'time=' in item]
|
||||||
result = str(formated_res[0])[5:]
|
result = str(formated_res[0])[5:]
|
||||||
|
|
||||||
|
@ -36,7 +38,7 @@ class Basics:
|
||||||
colour=0x11FF11)
|
colour=0x11FF11)
|
||||||
await ctx.send(embed=em)
|
await ctx.send(embed=em)
|
||||||
|
|
||||||
"""--------------------------------------------------------------------------------------------------------------------------"""
|
"""---------------------------------------------------------------------"""
|
||||||
|
|
||||||
@commands.command()
|
@commands.command()
|
||||||
async def info(self, ctx):
|
async def info(self, ctx):
|
||||||
|
@ -47,21 +49,22 @@ class Basics:
|
||||||
description=text.format(os_info,
|
description=text.format(os_info,
|
||||||
platform.python_version(),
|
platform.python_version(),
|
||||||
socket.gethostname(),
|
socket.gethostname(),
|
||||||
discord.__version__),
|
discord.__version__,
|
||||||
|
Route.BASE),
|
||||||
colour=0x89C4F9)
|
colour=0x89C4F9)
|
||||||
em.set_footer(text="/home/****/bot.py")
|
em.set_footer(text="/home/****/bot.py")
|
||||||
await ctx.send(embed=em)
|
await ctx.send(embed=em)
|
||||||
|
|
||||||
"""--------------------------------------------------------------------------------------------------------------------------"""
|
"""---------------------------------------------------------------------"""
|
||||||
|
|
||||||
@commands.command()
|
@commands.command()
|
||||||
async def help(self, ctx):
|
async def help(self, ctx):
|
||||||
"""Affiches l'aide du bot"""
|
"""Affiches l'aide du bot"""
|
||||||
text = open('texts/help.md').read()
|
text = open('texts/help.md').read()
|
||||||
em = discord.Embed(title='Commandes de TuxBot', description=text,
|
text = text.split("[split]")
|
||||||
colour=0x89C4F9)
|
for text_result in text:
|
||||||
|
em = discord.Embed(title='Commandes de TuxBot', description=text_result,colour=0x89C4F9)
|
||||||
await ctx.send(embed=em)
|
await ctx.send(embed=em)
|
||||||
|
|
||||||
|
|
||||||
def setup(bot):
|
def setup(bot):
|
||||||
bot.add_cog(Basics(bot))
|
bot.add_cog(Basics(bot))
|
||||||
|
|
16
cogs/ci.py
16
cogs/ci.py
|
@ -1,18 +1,16 @@
|
||||||
from discord.ext import commands
|
import datetime
|
||||||
|
import random
|
||||||
|
|
||||||
import discord
|
import discord
|
||||||
|
import requests
|
||||||
|
from discord.ext import commands
|
||||||
|
|
||||||
from .utils import checks
|
from .utils import checks
|
||||||
from .utils import db
|
from .utils import db
|
||||||
from .utils.checks import get_user, check_date
|
from .utils.checks import get_user, check_date
|
||||||
|
|
||||||
import datetime
|
|
||||||
import random
|
|
||||||
|
|
||||||
import pymysql
|
class Identity(commands.Cog):
|
||||||
import requests
|
|
||||||
|
|
||||||
|
|
||||||
class Identity:
|
|
||||||
"""Commandes des cartes d'identité ."""
|
"""Commandes des cartes d'identité ."""
|
||||||
|
|
||||||
def __init__(self, bot):
|
def __init__(self, bot):
|
||||||
|
@ -26,7 +24,7 @@ class Identity:
|
||||||
|
|
||||||
if not result:
|
if not result:
|
||||||
# Creation table Utilisateur si premiere fois
|
# Creation table Utilisateur si premiere fois
|
||||||
sql = "CREATE TABLE users ( `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY, userid TEXT null, username TEXT null, os TEXT null, config TEXT null, useravatar TEXT null, userbirth TEXT null, pays TEXT null, cidate TEXT null, cibureau TEXT null);"
|
sql = "CREATE TABLE users ( id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, userid TEXT null, username TEXT null, os TEXT null, config TEXT null, useravatar TEXT null, userbirth TEXT null, pays TEXT null, cidate TEXT null, cibureau TEXT null);"
|
||||||
self.cursor.execute(sql)
|
self.cursor.execute(sql)
|
||||||
|
|
||||||
"""--------------------------------------------------------------------------------------------------------------------------"""
|
"""--------------------------------------------------------------------------------------------------------------------------"""
|
||||||
|
|
|
@ -4,25 +4,28 @@ from .utils import checks
|
||||||
from .utils.paginator import HelpPaginator
|
from .utils.paginator import HelpPaginator
|
||||||
|
|
||||||
|
|
||||||
class CogManager:
|
class CogManager(commands.Cog):
|
||||||
"""Gestionnaire des cogs"""
|
"""Gestionnaire des cogs"""
|
||||||
|
|
||||||
def __init__(self, bot):
|
def __init__(self, bot):
|
||||||
self.bot = bot
|
self.bot = bot
|
||||||
|
self.help = discord.Embed(title='Tuxbot - Commandes cogs', description="Tuxbot - Commandes cogs\n"
|
||||||
|
"-> .cogs <load/unload/reload/info> *{cog}* : <load/unload/reload/info> *{cog}*\n"
|
||||||
|
"-> .cogs <list> : donne la liste de tous les cogs\n"
|
||||||
|
"-> .cogs <null/!(load/unload/reload)>: affiche cette aide", colour=0x89C4F9)
|
||||||
|
|
||||||
"""--------------------------------------------------------------------------------------------------------------------------"""
|
"""---------------------------------------------------------------------"""
|
||||||
|
|
||||||
@checks.has_permissions(administrator=True)
|
@checks.has_permissions(administrator=True)
|
||||||
@commands.group(name="cogs", no_pm=True, pass_context=True, case_insensitive=True)
|
@commands.group(name="cogs", no_pm=True, pass_context=True,
|
||||||
|
case_insensitive=True)
|
||||||
async def _cogs(self, ctx):
|
async def _cogs(self, ctx):
|
||||||
"""show help about 'cogs' command"""
|
"""show help about 'cogs' command"""
|
||||||
|
|
||||||
if ctx.invoked_subcommand is None:
|
if ctx.invoked_subcommand is None:
|
||||||
text = "Tuxbot - Commandes cogs\n-> .cogs <load/unload/reload/info> *{cog}* : <load/unload/reload/info> *{cog}*\n-> .cogs <null/!(load/unload/reload)>: affiche cette aide"
|
await ctx.send(embed=self.help)
|
||||||
em = discord.Embed(title='Tuxbot - Commandes cogs', description=text, colour=0x89C4F9)
|
|
||||||
await ctx.send(embed=em)
|
|
||||||
|
|
||||||
"""--------------------------------------------------------------------------------------------------------------------------"""
|
"""---------------------------------------------------------------------"""
|
||||||
|
|
||||||
@_cogs.command(name="load", pass_context=True)
|
@_cogs.command(name="load", pass_context=True)
|
||||||
async def cogs_load(self, ctx, cog: str = ""):
|
async def cogs_load(self, ctx, cog: str = ""):
|
||||||
|
@ -37,11 +40,9 @@ class CogManager:
|
||||||
await ctx.send('\N{PISTOL}')
|
await ctx.send('\N{PISTOL}')
|
||||||
await ctx.send(f'{type(e).__name__}: {e}')
|
await ctx.send(f'{type(e).__name__}: {e}')
|
||||||
else:
|
else:
|
||||||
text = "Tuxbot - Commandes cogs\n-> .cogs <load/unload/reload/info> *{cog}* : <load/unload/reload/info> *{cog}*\n-> .cogs <null/!(load/unload/reload)>: affiche cette aide"
|
await ctx.send(embed=self.help)
|
||||||
em = discord.Embed(title='Tuxbot - Commandes cogs', description=text, colour=0x89C4F9)
|
|
||||||
await ctx.send(embed=em)
|
|
||||||
|
|
||||||
"""--------------------------------------------------------------------------------------------------------------------------"""
|
"""---------------------------------------------------------------------"""
|
||||||
|
|
||||||
@_cogs.command(name="unload", pass_context=True)
|
@_cogs.command(name="unload", pass_context=True)
|
||||||
async def cogs_unload(self, ctx, cog: str = ""):
|
async def cogs_unload(self, ctx, cog: str = ""):
|
||||||
|
@ -56,11 +57,9 @@ class CogManager:
|
||||||
await ctx.send('\N{PISTOL}')
|
await ctx.send('\N{PISTOL}')
|
||||||
await ctx.send(f'{type(e).__name__}: {e}')
|
await ctx.send(f'{type(e).__name__}: {e}')
|
||||||
else:
|
else:
|
||||||
text = "Tuxbot - Commandes cogs\n-> .cogs <load/unload/reload/info> *{cog}* : <load/unload/reload/info> *{cog}*\n-> .cogs <null/!(load/unload/reload)>: affiche cette aide"
|
await ctx.send(embed=self.help)
|
||||||
em = discord.Embed(title='Tuxbot - Commandes cogs', description=text, colour=0x89C4F9)
|
|
||||||
await ctx.send(embed=em)
|
|
||||||
|
|
||||||
"""--------------------------------------------------------------------------------------------------------------------------"""
|
"""---------------------------------------------------------------------"""
|
||||||
|
|
||||||
@_cogs.command(name="reload", pass_context=True)
|
@_cogs.command(name="reload", pass_context=True)
|
||||||
async def cogs_reload(self, ctx, cog: str = ""):
|
async def cogs_reload(self, ctx, cog: str = ""):
|
||||||
|
@ -76,11 +75,9 @@ class CogManager:
|
||||||
await ctx.send('\N{PISTOL}')
|
await ctx.send('\N{PISTOL}')
|
||||||
await ctx.send(f'{type(e).__name__}: {e}')
|
await ctx.send(f'{type(e).__name__}: {e}')
|
||||||
else:
|
else:
|
||||||
text = "Tuxbot - Commandes cogs\n-> .cogs <load/unload/reload/info> *{cog}* : <load/unload/reload/info> *{cog}*\n-> .cogs <null/!(load/unload/reload)>: affiche cette aide"
|
await ctx.send(embed=self.help)
|
||||||
em = discord.Embed(title='Tuxbot - Commandes cogs', description=text, colour=0x89C4F9)
|
|
||||||
await ctx.send(embed=em)
|
|
||||||
|
|
||||||
"""--------------------------------------------------------------------------------------------------------------------------"""
|
"""---------------------------------------------------------------------"""
|
||||||
|
|
||||||
@_cogs.command(name="info", pass_context=True)
|
@_cogs.command(name="info", pass_context=True)
|
||||||
async def cogs_info(self, ctx, cog: str = ""):
|
async def cogs_info(self, ctx, cog: str = ""):
|
||||||
|
@ -96,14 +93,23 @@ class CogManager:
|
||||||
p = await HelpPaginator.from_cog(ctx, entity)
|
p = await HelpPaginator.from_cog(ctx, entity)
|
||||||
await p.paginate()
|
await p.paginate()
|
||||||
|
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
await ctx.send('\N{PISTOL}')
|
await ctx.send('\N{PISTOL}')
|
||||||
await ctx.send(f'{type(e).__name__}: {e}')
|
await ctx.send(f'{type(e).__name__}: {e}')
|
||||||
else:
|
else:
|
||||||
text = "Tuxbot - Commandes cogs\n-> .cogs <load/unload/reload/info> *{cog}* : <load/unload/reload/info> *{cog}*\n-> .cogs <null/!(load/unload/reload)>: affiche cette aide"
|
await ctx.send(embed=self.help)
|
||||||
em = discord.Embed(title='Tuxbot - Commandes cogs', description=text, colour=0x89C4F9)
|
|
||||||
await ctx.send(embed=em)
|
"""---------------------------------------------------------------------"""
|
||||||
|
|
||||||
|
@_cogs.command(name="list", pass_context=True)
|
||||||
|
async def cogs_list(self, ctx):
|
||||||
|
"""list all cogs"""
|
||||||
|
|
||||||
|
cogs = ""
|
||||||
|
for cog in self.bot.cogs:
|
||||||
|
cogs += f"{cog} *`({self.bot.cogs[cog].__module__})`*:" \
|
||||||
|
f" {len(self.bot.get_cog_commands(cog))} commandes\n"
|
||||||
|
await ctx.send(cogs)
|
||||||
|
|
||||||
|
|
||||||
def setup(bot):
|
def setup(bot):
|
||||||
|
|
|
@ -1,20 +1,19 @@
|
||||||
from discord.ext import commands
|
from discord.ext import commands
|
||||||
import discord
|
|
||||||
import asyncio
|
|
||||||
import discord
|
|
||||||
|
|
||||||
import re
|
import re
|
||||||
|
|
||||||
|
|
||||||
class FilterMessages:
|
class FilterMessages(commands.Cog):
|
||||||
"""Flitre des messages"""
|
"""Flitre des messages"""
|
||||||
|
|
||||||
def __init__(self, bot):
|
def __init__(self, bot):
|
||||||
self.bot = bot
|
self.bot = bot
|
||||||
|
|
||||||
|
@commands.Cog.listener()
|
||||||
async def on_message(self, message):
|
async def on_message(self, message):
|
||||||
no_pub_guild = [280805240977227776, 303633056944881686, 274247231534792704]
|
no_pub_guild = [280805240977227776, 303633056944881686,
|
||||||
lien_channel = [280805783795662848, 508794201509593088]
|
274247231534792704]
|
||||||
|
lien_channel = [280805783795662848, 508794201509593088,
|
||||||
|
516017286948061204]
|
||||||
sondage_channel = [394146769107419146, 477147964393914388]
|
sondage_channel = [394146769107419146, 477147964393914388]
|
||||||
|
|
||||||
if message.author.bot \
|
if message.author.bot \
|
||||||
|
@ -26,20 +25,29 @@ class FilterMessages:
|
||||||
invalid_link_regex = re.compile(r"^(\[[^\]]+\]|<\:[a-z0-9]+\:[0-9]+>) .+ https?:\/\/\S*$", re.IGNORECASE)
|
invalid_link_regex = re.compile(r"^(\[[^\]]+\]|<\:[a-z0-9]+\:[0-9]+>) .+ https?:\/\/\S*$", re.IGNORECASE)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if message.guild.id in no_pub_guild: ## discord invitation send by a non-admin and a non-authorized_id
|
if message.guild.id in no_pub_guild:
|
||||||
if isinstance(discord_invite_regex.search(message.content), re.Match):
|
if isinstance(discord_invite_regex.search(message.content), re.Match):
|
||||||
author = self.bot.get_user(message.author.id)
|
author = self.bot.get_user(message.author.id)
|
||||||
await message.delete()
|
await message.delete()
|
||||||
await author.send("La pub pour les serveurs discord n'est pas autorisée ici")
|
await author.send("La pub pour les serveurs discord n'est pas autorisée ici")
|
||||||
|
|
||||||
if message.channel.id in lien_channel \
|
if message.channel.id in lien_channel \
|
||||||
and not isinstance(invalid_link_regex.search(message.content), re.Match): ## link send without pattern
|
and not isinstance(invalid_link_regex.search(message.content), re.Match):
|
||||||
author = self.bot.get_user(message.author.id)
|
author = self.bot.get_user(message.author.id)
|
||||||
await message.delete()
|
await message.delete()
|
||||||
await author.send("Votre message `" + content + "` a été supprimé du channel `liens` car il ne respecte pas la structure définie. Pour partager un lien veuillez suivre la structure suivante : ` [Sujet] Descirption http(s)://....`")
|
await author.send(f"Votre message `{message.content}` a été "
|
||||||
await author.send("Si vous voulez commenter ou discuter à propos d'un lien, veuillez le faire dans le channel `#discussion-des-liens`.")
|
f"supprimé du channel `liens` ou `projets` "
|
||||||
|
f"car il ne respecte pas la structure "
|
||||||
|
f"définie. Pour partager un lien veuillez "
|
||||||
|
f"suivre la structure suivante :"
|
||||||
|
f" ` [Sujet] Descirption http(s)://....`")
|
||||||
|
await author.send("Si vous voulez commenter ou discuter à "
|
||||||
|
"propos d'un lien ou d'un projet, veuillez "
|
||||||
|
"le faire dans le channel"
|
||||||
|
" `#discussion-des-liens` ou"
|
||||||
|
" `#discussion-projets`.")
|
||||||
|
|
||||||
if message.channel.id in sondage_channel: ## a non-sondage send by a non-admin
|
if message.channel.id in sondage_channel:
|
||||||
prefix_lenght = len(await self.bot.get_prefix(message))
|
prefix_lenght = len(await self.bot.get_prefix(message))
|
||||||
command = (message.content.split()[0])[prefix_lenght:]
|
command = (message.content.split()[0])[prefix_lenght:]
|
||||||
if command != "sondage":
|
if command != "sondage":
|
||||||
|
|
45
cogs/funs.py
45
cogs/funs.py
|
@ -7,37 +7,38 @@ import random
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
|
|
||||||
class Funs:
|
class Funs(commands.Cog):
|
||||||
"""Commandes funs."""
|
"""Commandes funs."""
|
||||||
|
|
||||||
def __init__(self, bot):
|
def __init__(self, bot):
|
||||||
self.bot = bot
|
self.bot = bot
|
||||||
|
|
||||||
"""--------------------------------------------------------------------------------------------------------------------------"""
|
"""---------------------------------------------------------------------"""
|
||||||
|
|
||||||
@commands.command()
|
@commands.command()
|
||||||
async def avatar(self, ctx, user: discord.Member = None):
|
async def avatar(self, ctx, user: discord.Member = None):
|
||||||
"""Récuperer l'avatar de ..."""
|
"""Récuperer l'avatar de ..."""
|
||||||
|
|
||||||
if user == None:
|
if user is None:
|
||||||
user = ctx.message.author
|
user = ctx.message.author
|
||||||
|
|
||||||
embed = discord.Embed(title="Avatar de : " + user.name,
|
embed = discord.Embed(title="Avatar de : " + user.name,
|
||||||
url=user.avatar_url_as(format="png"),
|
url=user.avatar_url_as(format="png"),
|
||||||
description=f"[Voir en plus grand]({user.avatar_url_as(format='png')})")
|
description=f"[Voir en plus grand]"
|
||||||
embed.set_thumbnail(url=user.avatar_url_as(format="png"))
|
f"({user.avatar_url_as(format='png')})")
|
||||||
|
embed.set_thumbnail(url=user.user.avatar_url_as(format="png"))
|
||||||
await ctx.send(embed=embed)
|
await ctx.send(embed=embed)
|
||||||
|
|
||||||
"""--------------------------------------------------------------------------------------------------------------------------"""
|
"""---------------------------------------------------------------------"""
|
||||||
|
|
||||||
@commands.command(pass_context=True)
|
@commands.command(pass_context=True)
|
||||||
async def poke(self, ctx, user: discord.Member):
|
async def poke(self, ctx, user: discord.Member):
|
||||||
"""Poke quelqu'un"""
|
"""Poke quelqu'un"""
|
||||||
await ctx.send(":clap: Hey {0} tu t'es fait poker par {1} !".format(
|
await ctx.send(f":clap: Hey {user.mention} tu t'es fait poker par"
|
||||||
user.mention, ctx.message.author.name))
|
f" {ctx.message.author} !")
|
||||||
await ctx.message.delete()
|
await ctx.message.delete()
|
||||||
|
|
||||||
"""--------------------------------------------------------------------------------------------------------------------------"""
|
"""---------------------------------------------------------------------"""
|
||||||
|
|
||||||
@commands.command()
|
@commands.command()
|
||||||
async def btcprice(self, ctx):
|
async def btcprice(self, ctx):
|
||||||
|
@ -50,14 +51,16 @@ class Funs:
|
||||||
btc = 1
|
btc = 1
|
||||||
|
|
||||||
if btc == 1:
|
if btc == 1:
|
||||||
await loading.edit(content="Impossible d'accèder à l'API blockchain.info, "
|
await loading.edit(content="Impossible d'accèder à l'API"
|
||||||
"veuillez réessayer ultérieurment ! :c")
|
" blockchain.info, veuillez réessayer"
|
||||||
|
" ultérieurment ! :c")
|
||||||
else:
|
else:
|
||||||
frbtc = str(btc["EUR"]["last"]).replace(".", ",")
|
frbtc = str(btc["EUR"]["last"]).replace(".", ",")
|
||||||
usbtc = str(btc["USD"]["last"]).replace(".", ",")
|
usbtc = str(btc["USD"]["last"]).replace(".", ",")
|
||||||
await loading.edit(content="Un bitcoin est égal à : {0}$US soit {1}€.".format(usbtc, frbtc))
|
await loading.edit(content=f"Un bitcoin est égal à :"
|
||||||
|
f" {usbtc}$US soit {frbtc}€.")
|
||||||
|
|
||||||
"""--------------------------------------------------------------------------------------------------------------------------"""
|
"""---------------------------------------------------------------------"""
|
||||||
|
|
||||||
@commands.command()
|
@commands.command()
|
||||||
async def joke(self, ctx, number: str = 0):
|
async def joke(self, ctx, number: str = 0):
|
||||||
|
@ -66,22 +69,22 @@ class Funs:
|
||||||
jk = json.load(js)
|
jk = json.load(js)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if int(number) <= 15 and int(number) > 0:
|
if 15 >= int(number) > 0:
|
||||||
clef = str(number)
|
clef = str(number)
|
||||||
else:
|
else:
|
||||||
clef = str(random.randint(1, 15))
|
clef = str(random.randint(1, 15))
|
||||||
except:
|
except Exception:
|
||||||
clef = str(random.randint(1, 15))
|
clef = str(random.randint(1, 15))
|
||||||
|
|
||||||
|
|
||||||
joke = jk["{}".format(clef)]
|
joke = jk["{}".format(clef)]
|
||||||
|
|
||||||
embed = discord.Embed(title="Blague _{}_ : ".format(clef), description=joke['content'], colour=0x03C9A9)
|
embed = discord.Embed(title="Blague _{}_ : ".format(clef),
|
||||||
|
description=joke['content'], colour=0x03C9A9)
|
||||||
embed.set_footer(text="Par " + joke['author'])
|
embed.set_footer(text="Par " + joke['author'])
|
||||||
embed.set_thumbnail(url='https://outout.tech/tuxbot/blobjoy.png')
|
embed.set_thumbnail(url='https://outout.tech/tuxbot/blobjoy.png')
|
||||||
await ctx.send(embed=embed)
|
await ctx.send(embed=embed)
|
||||||
|
|
||||||
"""--------------------------------------------------------------------------------------------------------------------------"""
|
"""---------------------------------------------------------------------"""
|
||||||
|
|
||||||
@commands.command()
|
@commands.command()
|
||||||
async def ethylotest(self, ctx):
|
async def ethylotest(self, ctx):
|
||||||
|
@ -109,7 +112,7 @@ class Funs:
|
||||||
await asyncio.sleep(1)
|
await asyncio.sleep(1)
|
||||||
await ctx.send(":police_car: " + result_p)
|
await ctx.send(":police_car: " + result_p)
|
||||||
|
|
||||||
"""--------------------------------------------------------------------------------------------------------------------------"""
|
"""---------------------------------------------------------------------"""
|
||||||
|
|
||||||
@commands.command()
|
@commands.command()
|
||||||
async def coin(self, ctx):
|
async def coin(self, ctx):
|
||||||
|
@ -134,7 +137,7 @@ class Funs:
|
||||||
await ctx.send(result.format(":moneybag: Et la pièce retombe sur ...",
|
await ctx.send(result.format(":moneybag: Et la pièce retombe sur ...",
|
||||||
":robot:"))
|
":robot:"))
|
||||||
|
|
||||||
"""--------------------------------------------------------------------------------------------------------------------------"""
|
"""---------------------------------------------------------------------"""
|
||||||
|
|
||||||
@commands.command()
|
@commands.command()
|
||||||
async def pokemon(self, ctx):
|
async def pokemon(self, ctx):
|
||||||
|
@ -169,7 +172,7 @@ class Funs:
|
||||||
await ctx.send(":trophy: Le gagnant est **{}** !".format(
|
await ctx.send(":trophy: Le gagnant est **{}** !".format(
|
||||||
winer["Name"]))
|
winer["Name"]))
|
||||||
|
|
||||||
"""--------------------------------------------------------------------------------------------------------------------------"""
|
"""---------------------------------------------------------------------"""
|
||||||
|
|
||||||
@commands.command()
|
@commands.command()
|
||||||
async def randomcat(self, ctx):
|
async def randomcat(self, ctx):
|
||||||
|
|
|
@ -1,17 +1,19 @@
|
||||||
from discord.ext import commands
|
import aiohttp
|
||||||
|
import datetime
|
||||||
import discord
|
import discord
|
||||||
|
import imghdr
|
||||||
|
import os
|
||||||
|
import shutil
|
||||||
from PIL import Image
|
from PIL import Image
|
||||||
from PIL import ImageOps
|
from PIL import ImageOps
|
||||||
|
from discord.ext import commands
|
||||||
|
|
||||||
from .utils import checks
|
|
||||||
from .utils import db
|
from .utils import db
|
||||||
|
from .utils.checks import get_user
|
||||||
from .utils.passport_generator import generate_passport
|
from .utils.passport_generator import generate_passport
|
||||||
from .utils.checks import get_user, check_date
|
|
||||||
|
|
||||||
import asyncio, aiohttp, io, time, imghdr, os, shutil, json, textwrap, re, math, datetime
|
|
||||||
|
|
||||||
class Passport:
|
class Passport(commands.Cog):
|
||||||
"""Commandes des passeports ."""
|
"""Commandes des passeports ."""
|
||||||
|
|
||||||
def __init__(self, bot):
|
def __init__(self, bot):
|
||||||
|
|
69
cogs/role.py
69
cogs/role.py
|
@ -1,7 +1,8 @@
|
||||||
from discord.ext import commands
|
from discord.ext import commands
|
||||||
import discord
|
import discord
|
||||||
|
|
||||||
class Role:
|
|
||||||
|
class Role(commands.Cog):
|
||||||
"""Commandes role."""
|
"""Commandes role."""
|
||||||
|
|
||||||
def __init__(self, bot):
|
def __init__(self, bot):
|
||||||
|
@ -13,7 +14,8 @@ class Role:
|
||||||
self.ANDROID_ROLE = 393087862972612627
|
self.ANDROID_ROLE = 393087862972612627
|
||||||
self.BSD_ROLE = 401791543708745738
|
self.BSD_ROLE = 401791543708745738
|
||||||
|
|
||||||
@commands.group(name="role", no_pm=True, pass_context=True, case_insensitive=True)
|
@commands.group(name="role", no_pm=True, pass_context=True,
|
||||||
|
case_insensitive=True)
|
||||||
async def _role(self, ctx):
|
async def _role(self, ctx):
|
||||||
"""Affiche l'aide sur la commande role"""
|
"""Affiche l'aide sur la commande role"""
|
||||||
if ctx.message.guild.id != 280805240977227776:
|
if ctx.message.guild.id != 280805240977227776:
|
||||||
|
@ -21,12 +23,14 @@ class Role:
|
||||||
|
|
||||||
if ctx.invoked_subcommand is None:
|
if ctx.invoked_subcommand is None:
|
||||||
text = open('texts/roles.md').read()
|
text = open('texts/roles.md').read()
|
||||||
em = discord.Embed(title='Gestionnaires de rôles', description=text,colour=0x89C4F9)
|
em = discord.Embed(title='Gestionnaires de rôles',
|
||||||
|
description=text, colour=0x89C4F9)
|
||||||
await ctx.send(embed=em)
|
await ctx.send(embed=em)
|
||||||
|
|
||||||
"""--------------------------------------------------------------------------------------------------------------------------"""
|
"""---------------------------------------------------------------------"""
|
||||||
|
|
||||||
@_role.command(name="arch", aliases=["archlinux", "arch_linux"], pass_context=True)
|
@_role.command(name="arch", aliases=["archlinux", "arch_linux"],
|
||||||
|
pass_context=True)
|
||||||
async def role_arch(self, ctx):
|
async def role_arch(self, ctx):
|
||||||
"""Ajoute/retire le role 'Arch user'"""
|
"""Ajoute/retire le role 'Arch user'"""
|
||||||
roles = ctx.message.author.roles
|
roles = ctx.message.author.roles
|
||||||
|
@ -37,12 +41,16 @@ class Role:
|
||||||
user = ctx.message.author
|
user = ctx.message.author
|
||||||
if self.ARCH_ROLE in role_id:
|
if self.ARCH_ROLE in role_id:
|
||||||
await user.remove_roles(discord.Object(id=self.ARCH_ROLE))
|
await user.remove_roles(discord.Object(id=self.ARCH_ROLE))
|
||||||
await ctx.send(ctx.message.author.mention + " > Pourquoi tu viens de supprimer Arch Linux, c'était trop compliqué pour toi ? <:sad:343723037331292170>")
|
await ctx.send(f"{ctx.message.author.mention} > Pourquoi tu viens "
|
||||||
|
f"de supprimer Arch Linux, c'était trop compliqué "
|
||||||
|
f"pour toi ? <:sad:343723037331292170>")
|
||||||
else:
|
else:
|
||||||
await user.add_roles(discord.Object(id=self.ARCH_ROLE))
|
await user.add_roles(discord.Object(id=self.ARCH_ROLE))
|
||||||
await ctx.send(ctx.message.author.mention + " > How un ArchLinuxien, c'est bon les ``yaourt`` ? <:hap:354275645574086656>")
|
await ctx.send(f"{ctx.message.author.mention} > How un "
|
||||||
|
f"ArchLinuxien, c'est bon les ``yaourt`` ? "
|
||||||
|
f"<:hap:354275645574086656>")
|
||||||
|
|
||||||
"""--------------------------------------------------------------------------------------------------------------------------"""
|
"""---------------------------------------------------------------------"""
|
||||||
|
|
||||||
@_role.command(name="debian", pass_context=True)
|
@_role.command(name="debian", pass_context=True)
|
||||||
async def role_debian(self, ctx):
|
async def role_debian(self, ctx):
|
||||||
|
@ -55,12 +63,15 @@ class Role:
|
||||||
user = ctx.message.author
|
user = ctx.message.author
|
||||||
if self.DEBIAN_ROLE in role_id:
|
if self.DEBIAN_ROLE in role_id:
|
||||||
await user.remove_roles(discord.Object(id=self.DEBIAN_ROLE))
|
await user.remove_roles(discord.Object(id=self.DEBIAN_ROLE))
|
||||||
await ctx.send(ctx.message.author.mention + " > Adieu ! Tu verras, APT te manquera ! ")
|
await ctx.send(f"{ctx.message.author.mention} > Adieu ! Tu verras, "
|
||||||
|
f"APT te manquera ! ")
|
||||||
else:
|
else:
|
||||||
await user.add_roles(discord.Object(id=self.DEBIAN_ROLE))
|
await user.add_roles(discord.Object(id=self.DEBIAN_ROLE))
|
||||||
await ctx.send(ctx.message.author.mention + " > Un utilisateur de Debian, encore et encore ! <:stuck_out_tongue:343723077412323339>")
|
await ctx.send(f"{ctx.message.author.mention} > Un utilisateur de "
|
||||||
|
f"Debian, encore et encore ! "
|
||||||
|
f"<:stuck_out_tongue:343723077412323339>")
|
||||||
|
|
||||||
"""--------------------------------------------------------------------------------------------------------------------------"""
|
"""---------------------------------------------------------------------"""
|
||||||
|
|
||||||
@_role.command(name="rhel", pass_context=True)
|
@_role.command(name="rhel", pass_context=True)
|
||||||
async def role_rhel(self, ctx):
|
async def role_rhel(self, ctx):
|
||||||
|
@ -73,12 +84,16 @@ class Role:
|
||||||
user = ctx.message.author
|
user = ctx.message.author
|
||||||
if self.RHEL_ROLE in role_id:
|
if self.RHEL_ROLE in role_id:
|
||||||
await user.remove_roles(discord.Object(id=self.RHEL_ROLE))
|
await user.remove_roles(discord.Object(id=self.RHEL_ROLE))
|
||||||
await ctx.send(ctx.message.author.mention + " > Pourquoi tu t'en vas, il sont déjà assez seul là-bas <:sad:343723037331292170>")
|
await ctx.send(f"{ctx.message.author.mention} > Pourquoi tu t'en "
|
||||||
|
f"vas, il sont déjà assez seul là-bas "
|
||||||
|
f"<:sad:343723037331292170>")
|
||||||
else:
|
else:
|
||||||
await user.add_roles(discord.Object(id=self.RHEL_ROLE))
|
await user.add_roles(discord.Object(id=self.RHEL_ROLE))
|
||||||
await ctx.send(ctx.message.author.mention + " > Mais, voila quelqu'un qui porte des chapeaux ! <:hap:354275645574086656>")
|
await ctx.send(f"{ctx.message.author.mention} > Mais, voila "
|
||||||
|
f"quelqu'un qui porte des chapeaux ! "
|
||||||
|
f"<:hap:354275645574086656>")
|
||||||
|
|
||||||
"""--------------------------------------------------------------------------------------------------------------------------"""
|
"""---------------------------------------------------------------------"""
|
||||||
|
|
||||||
@_role.command(name="android", pass_context=True)
|
@_role.command(name="android", pass_context=True)
|
||||||
async def role_android(self, ctx):
|
async def role_android(self, ctx):
|
||||||
|
@ -91,12 +106,18 @@ class Role:
|
||||||
user = ctx.message.author
|
user = ctx.message.author
|
||||||
if self.ANDROID_ROLE in role_id:
|
if self.ANDROID_ROLE in role_id:
|
||||||
await user.remove_roles(discord.Object(id=self.ANDROID_ROLE))
|
await user.remove_roles(discord.Object(id=self.ANDROID_ROLE))
|
||||||
await ctx.send(ctx.message.author.mention + " > How, me dit pas que tu as compris que les Android's allaient exterminer le monde ? <:trollface:375327667160875008>")
|
await ctx.send(f"{ctx.message.author.mention} >How, me dit pas "
|
||||||
|
f"que tu as compris que les Android's allaient "
|
||||||
|
f"exterminer le monde ? "
|
||||||
|
f"<:trollface:375327667160875008>")
|
||||||
else:
|
else:
|
||||||
await user.add_roles(discord.Object(id=self.ANDROID_ROLE))
|
await user.add_roles(discord.Object(id=self.ANDROID_ROLE))
|
||||||
await ctx.send(ctx.message.author.mention + " > Hey, un utilisateur d'Android, prêt à continuer l'extermination de WP et iOS ? <:stuck_out_tongue:343723077412323339>")
|
await ctx.send(f"{ctx.message.author.mention} > Hey, un utilisateur"
|
||||||
|
f" d'Android, prêt à continuer l'extermination de "
|
||||||
|
f"WP et iOS ? "
|
||||||
|
f"<:stuck_out_tongue:343723077412323339>")
|
||||||
|
|
||||||
"""--------------------------------------------------------------------------------------------------------------------------"""
|
"""---------------------------------------------------------------------"""
|
||||||
|
|
||||||
@_role.command(name="bsd", pass_context=True)
|
@_role.command(name="bsd", pass_context=True)
|
||||||
async def role_bsd(self, ctx):
|
async def role_bsd(self, ctx):
|
||||||
|
@ -109,18 +130,22 @@ class Role:
|
||||||
user = ctx.message.author
|
user = ctx.message.author
|
||||||
if self.BSD_ROLE in role_id:
|
if self.BSD_ROLE in role_id:
|
||||||
await user.remove_roles(discord.Object(id=self.BSD_ROLE))
|
await user.remove_roles(discord.Object(id=self.BSD_ROLE))
|
||||||
await ctx.send(ctx.message.author.mention + " > Ohhhh fait gaffe ou le démon va te piquer")
|
await ctx.send(f"{ctx.message.author.mention} > Ohhhh fait gaffe "
|
||||||
|
f"ou le démon va te piquer")
|
||||||
else:
|
else:
|
||||||
await user.add_roles(discord.Object(id=self.BSD_ROLE))
|
await user.add_roles(discord.Object(id=self.BSD_ROLE))
|
||||||
await ctx.send(ctx.message.author.mention + " > Quelqu'un sous BSD ! Au moins il a pas besoin de mettre GNU devant son OS à chaque fois :d")
|
await ctx.send(f"{ctx.message.author.mention} > Quelqu'un sous "
|
||||||
|
f"BSD ! Au moins il a pas besoin de mettre GNU "
|
||||||
|
f"devant son OS à chaque fois :d")
|
||||||
|
|
||||||
"""--------------------------------------------------------------------------------------------------------------------------"""
|
"""---------------------------------------------------------------------"""
|
||||||
|
|
||||||
@_role.command(name="staff", pass_context=True, hidden=True)
|
@_role.command(name="staff", pass_context=True, hidden=True)
|
||||||
async def role_staff(self, ctx):
|
async def role_staff(self, ctx):
|
||||||
"""Easter egg"""
|
"""Easter egg"""
|
||||||
user = ctx.message.author
|
|
||||||
await ctx.send(ctx.message.author.mention + " > Vous n'avez pas le rôle staff, tu crois quoi :joy:")
|
await ctx.send(f"{ctx.message.author.mention} > Vous n'avez pas "
|
||||||
|
f"le rôle staff, tu crois quoi :joy:")
|
||||||
|
|
||||||
|
|
||||||
def setup(bot):
|
def setup(bot):
|
||||||
|
|
|
@ -4,8 +4,10 @@ import asyncio
|
||||||
import urllib.request
|
import urllib.request
|
||||||
import wikipedia
|
import wikipedia
|
||||||
|
|
||||||
|
wikipedia.set_lang("fr")
|
||||||
|
|
||||||
class Search:
|
|
||||||
|
class Search(commands.Cog):
|
||||||
"""Commandes de WWW."""
|
"""Commandes de WWW."""
|
||||||
|
|
||||||
def __init__(self, bot):
|
def __init__(self, bot):
|
||||||
|
@ -24,7 +26,7 @@ class Search:
|
||||||
@_search.command(pass_context=True, name="docubuntu")
|
@_search.command(pass_context=True, name="docubuntu")
|
||||||
async def search_docubuntu(self, ctx, args):
|
async def search_docubuntu(self, ctx, args):
|
||||||
attends = await ctx.send("_Je te cherche ça {} !_".format(
|
attends = await ctx.send("_Je te cherche ça {} !_".format(
|
||||||
ctx.author.mention))
|
ctx.message.author.mention))
|
||||||
html = urllib.request.urlopen("https://doc.ubuntu-fr.org/" +
|
html = urllib.request.urlopen("https://doc.ubuntu-fr.org/" +
|
||||||
args).read()
|
args).read()
|
||||||
if "avez suivi un lien" in str(html):
|
if "avez suivi un lien" in str(html):
|
||||||
|
@ -50,7 +52,7 @@ class Search:
|
||||||
@_search.command(pass_context=True, name="docarch")
|
@_search.command(pass_context=True, name="docarch")
|
||||||
async def search_docarch(self, ctx, args):
|
async def search_docarch(self, ctx, args):
|
||||||
attends = await ctx.send("_Je te cherche ça {} !_".format(
|
attends = await ctx.send("_Je te cherche ça {} !_".format(
|
||||||
ctx.author.mention))
|
ctx.message.author.mention))
|
||||||
html = urllib.request.urlopen("https://wiki.archlinux.org/index.php/" +
|
html = urllib.request.urlopen("https://wiki.archlinux.org/index.php/" +
|
||||||
args).read()
|
args).read()
|
||||||
if "There is currently no text in this page" in str(html):
|
if "There is currently no text in this page" in str(html):
|
||||||
|
@ -73,24 +75,11 @@ class Search:
|
||||||
await ctx.send(embed=embed)
|
await ctx.send(embed=embed)
|
||||||
|
|
||||||
@_search.command(pass_context=True, name="wikipedia")
|
@_search.command(pass_context=True, name="wikipedia")
|
||||||
async def search_wikipedia(self, ctx: commands.Context, *, args):
|
async def search_wikipedia(self, ctx: commands.Context, args):
|
||||||
"""Fait une recherche sur wikipd"""
|
"""Fait une recherche sur wikipd"""
|
||||||
|
|
||||||
params = args.split(" ")
|
|
||||||
|
|
||||||
lang = [x for x in params if x.startswith("lang=")]
|
|
||||||
if lang:
|
|
||||||
lang = lang[0]
|
|
||||||
params.remove(lang)
|
|
||||||
lang = lang.replace("lang=", "")
|
|
||||||
wikipedia.set_lang(lang)
|
|
||||||
else:
|
|
||||||
wikipedia.set_lang("fr")
|
|
||||||
|
|
||||||
params = ' '.join(params)
|
|
||||||
|
|
||||||
wait = await ctx.send("_Je cherche..._")
|
wait = await ctx.send("_Je cherche..._")
|
||||||
results = wikipedia.search(params)
|
results = wikipedia.search(args)
|
||||||
nbmr = 0
|
nbmr = 0
|
||||||
mmssgg = ""
|
mmssgg = ""
|
||||||
|
|
||||||
|
@ -98,7 +87,7 @@ class Search:
|
||||||
nbmr = nbmr + 1
|
nbmr = nbmr + 1
|
||||||
mmssgg = mmssgg + "**{}**: {} \n".format(str(nbmr), value)
|
mmssgg = mmssgg + "**{}**: {} \n".format(str(nbmr), value)
|
||||||
|
|
||||||
em = discord.Embed(title='Résultats de : ' + params,
|
em = discord.Embed(title='Résultats de : ' + args,
|
||||||
description = mmssgg,
|
description = mmssgg,
|
||||||
colour=0x4ECDC4)
|
colour=0x4ECDC4)
|
||||||
em.set_thumbnail(url="https://upload.wikimedia.org/wikipedia/commons/"
|
em.set_thumbnail(url="https://upload.wikimedia.org/wikipedia/commons/"
|
||||||
|
@ -128,14 +117,14 @@ class Search:
|
||||||
while not emoji.done():
|
while not emoji.done():
|
||||||
await asyncio.sleep(0.1)
|
await asyncio.sleep(0.1)
|
||||||
|
|
||||||
sPage = int(sending.index(emoji.result()))
|
page = int(sending.index(emoji.result()))
|
||||||
|
|
||||||
args_ = results[sPage]
|
args_ = results[page]
|
||||||
|
|
||||||
try:
|
try:
|
||||||
await msg.delete()
|
await msg.delete()
|
||||||
await ctx.trigger_typing()
|
await ctx.trigger_typing()
|
||||||
wait = await ctx.send(ctx.author.mention +
|
wait = await ctx.send(ctx.message.author.mention +
|
||||||
" ah ok sympa cette recherche, je l'effectue de suite !")
|
" ah ok sympa cette recherche, je l'effectue de suite !")
|
||||||
wp = wikipedia.page(args_)
|
wp = wikipedia.page(args_)
|
||||||
wp_contenu = wp.summary[:200] + "..."
|
wp_contenu = wp.summary[:200] + "..."
|
||||||
|
@ -161,7 +150,7 @@ class Search:
|
||||||
await ctx.send(":open_mouth: Une **erreur interne** est survenue,"
|
await ctx.send(":open_mouth: Une **erreur interne** est survenue,"
|
||||||
" si cela ce reproduit contactez votre"
|
" si cela ce reproduit contactez votre"
|
||||||
" administrateur ou faites une Issue sur"
|
" administrateur ou faites une Issue sur"
|
||||||
" ``github`` !")
|
" ``gitea`` !")
|
||||||
|
|
||||||
|
|
||||||
def setup(bot):
|
def setup(bot):
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
from discord.ext import commands
|
import datetime
|
||||||
|
import socket
|
||||||
|
|
||||||
import discord
|
import discord
|
||||||
|
from discord.ext import commands
|
||||||
|
|
||||||
import datetime, socket
|
|
||||||
|
|
||||||
class SendLogs:
|
class SendLogs(commands.Cog):
|
||||||
"""Send logs to a specific channel"""
|
"""Send logs to a specific channel"""
|
||||||
|
|
||||||
def __init__(self, bot):
|
def __init__(self, bot):
|
||||||
|
@ -12,46 +14,60 @@ class SendLogs:
|
||||||
self.log_channel = None
|
self.log_channel = None
|
||||||
self.main_server_id = int(self.bot.config.main_server_id)
|
self.main_server_id = int(self.bot.config.main_server_id)
|
||||||
|
|
||||||
|
@commands.Cog.listener()
|
||||||
async def on_resumed(self):
|
async def on_resumed(self):
|
||||||
em = discord.Embed(title="Et hop je me reconnecte à l'api 😃", colour=0x5cb85c)
|
em = discord.Embed(title="Et hop je me reconnecte à l'api 😃",
|
||||||
|
colour=0x5cb85c)
|
||||||
em.timestamp = datetime.datetime.utcnow()
|
em.timestamp = datetime.datetime.utcnow()
|
||||||
await self.log_channel.send(embed=em)
|
await self.log_channel.send(embed=em)
|
||||||
|
|
||||||
|
@commands.Cog.listener()
|
||||||
async def on_ready(self):
|
async def on_ready(self):
|
||||||
self.log_channel = self.bot.get_channel(int(self.bot.config.log_channel_id))
|
self.log_channel = self.bot.get_channel(int(self.bot.config.log_channel_id))
|
||||||
em = discord.Embed(title="Je suis opérationnel 😃", description=f"*Instance lancée sur {socket.gethostname()}*", colour=0x5cb85c)
|
em = discord.Embed(title="Je suis opérationnel 😃",
|
||||||
|
description=f"*Instance lancée sur "
|
||||||
|
f"{socket.gethostname()}*", colour=0x5cb85c)
|
||||||
em.timestamp = datetime.datetime.utcnow()
|
em.timestamp = datetime.datetime.utcnow()
|
||||||
await self.log_channel.send(embed=em)
|
await self.log_channel.send(embed=em)
|
||||||
|
|
||||||
"""--------------------------------------------------------------------------------------------------------------------------"""
|
"""---------------------------------------------------------------------"""
|
||||||
|
|
||||||
|
@commands.Cog.listener()
|
||||||
async def on_guild_join(self, guild: discord.Guild):
|
async def on_guild_join(self, guild: discord.Guild):
|
||||||
em = discord.Embed(title=f"On m'a ajouté à : {str(guild.name)} 😃", colour=0x51A351)
|
em = discord.Embed(title=f"On m'a ajouté à : {str(guild.name)} 😃",
|
||||||
|
colour=0x51A351)
|
||||||
em.timestamp = datetime.datetime.utcnow()
|
em.timestamp = datetime.datetime.utcnow()
|
||||||
await self.log_channel.send(embed=em)
|
await self.log_channel.send(embed=em)
|
||||||
|
|
||||||
|
@commands.Cog.listener()
|
||||||
async def on_guild_remove(self, guild: discord.Guild):
|
async def on_guild_remove(self, guild: discord.Guild):
|
||||||
em = discord.Embed(title=f"On m'a viré de : {str(guild.name)} 😦", colour=0xBD362F)
|
em = discord.Embed(title=f"On m'a viré de : {str(guild.name)} 😦",
|
||||||
|
colour=0xBD362F)
|
||||||
em.timestamp = datetime.datetime.utcnow()
|
em.timestamp = datetime.datetime.utcnow()
|
||||||
await self.log_channel.send(embed=em)
|
await self.log_channel.send(embed=em)
|
||||||
|
|
||||||
"""--------------------------------------------------------------------------------------------------------------------------"""
|
"""---------------------------------------------------------------------"""
|
||||||
|
|
||||||
|
@commands.Cog.listener()
|
||||||
async def on_member_join(self, member):
|
async def on_member_join(self, member):
|
||||||
if member.guild.id == self.main_server_id:
|
if member.guild.id == self.main_server_id:
|
||||||
em = discord.Embed(title=f"{str(member)} *`({str(member.id)})`* nous a rejoint 😃", colour=0x51A351)
|
em = discord.Embed(title=f"{str(member)} *`({str(member.id)})`* "
|
||||||
em.set_footer(text="Compte crée le " + str(member.created_at), )
|
f"nous a rejoint 😃", colour=0x51A351)
|
||||||
|
em.set_footer(text=f"Compte crée le {member.created_at}")
|
||||||
em.timestamp = datetime.datetime.utcnow()
|
em.timestamp = datetime.datetime.utcnow()
|
||||||
await self.log_channel.send(embed=em)
|
await self.log_channel.send(embed=em)
|
||||||
|
|
||||||
|
@commands.Cog.listener()
|
||||||
async def on_member_remove(self, member):
|
async def on_member_remove(self, member):
|
||||||
if member.guild.id == self.main_server_id:
|
if member.guild.id == self.main_server_id:
|
||||||
em = discord.Embed(title=f"{str(member)} *`({str(member.id)})`* nous a quitter 😦", colour=0xBD362F)
|
em = discord.Embed(title=f"{str(member)} *`({str(member.id)})`* "
|
||||||
|
f"nous a quitté 😦", colour=0xBD362F)
|
||||||
em.timestamp = datetime.datetime.utcnow()
|
em.timestamp = datetime.datetime.utcnow()
|
||||||
await self.log_channel.send(embed=em)
|
await self.log_channel.send(embed=em)
|
||||||
|
|
||||||
"""--------------------------------------------------------------------------------------------------------------------------"""
|
"""---------------------------------------------------------------------"""
|
||||||
|
|
||||||
|
@commands.Cog.listener()
|
||||||
async def on_message_delete(self, message):
|
async def on_message_delete(self, message):
|
||||||
if message.guild.id == self.main_server_id and not message.author.bot:
|
if message.guild.id == self.main_server_id and not message.author.bot:
|
||||||
async def is_a_command(message):
|
async def is_a_command(message):
|
||||||
|
@ -63,18 +79,27 @@ class SendLogs:
|
||||||
return self.bot.get_command(str(command))
|
return self.bot.get_command(str(command))
|
||||||
|
|
||||||
if await is_a_command(message) is None:
|
if await is_a_command(message) is None:
|
||||||
em = discord.Embed(title=f"Message supprimé dans : {str(message.channel.name)}", colour=0xBD362F)
|
em = discord.Embed(title=f"Message supprimé dans :"
|
||||||
em.add_field(name=f"{str(message.author)} *`({str(message.author.id)})`* a supprimé :", value=str(message.content))
|
f" {str(message.channel.name)}",
|
||||||
|
colour=0xBD362F)
|
||||||
|
em.add_field(name=f"{str(message.author)} "
|
||||||
|
f"*`({str(message.author.id)})`* "
|
||||||
|
f"a supprimé :", value=str(message.content))
|
||||||
em.timestamp = datetime.datetime.utcnow()
|
em.timestamp = datetime.datetime.utcnow()
|
||||||
await self.log_channel.send(embed=em)
|
await self.log_channel.send(embed=em)
|
||||||
|
|
||||||
|
@commands.Cog.listener()
|
||||||
async def on_message_edit(self, before, after):
|
async def on_message_edit(self, before, after):
|
||||||
if before.guild.id == self.main_server_id and not before.author.bot:
|
if before.guild.id == self.main_server_id and not before.author.bot:
|
||||||
em = discord.Embed(title="Message edité dans : " + str(before.channel.name), colour=0x0088CC)
|
em = discord.Embed(title=f"Message edité dans : "
|
||||||
em.add_field(name=f"{str(before.author)} *`({str(before.author.id)})`* a edité :", value=str(before.content))
|
f"{before.channel.name}", colour=0x0088CC)
|
||||||
|
em.add_field(name=f"{str(before.author)} "
|
||||||
|
f"*`({str(before.author.id)})`* a"
|
||||||
|
f" edité :", value=str(before.content))
|
||||||
em.add_field(name="Pour remplacer par :", value=str(after.content))
|
em.add_field(name="Pour remplacer par :", value=str(after.content))
|
||||||
em.timestamp = datetime.datetime.utcnow()
|
em.timestamp = datetime.datetime.utcnow()
|
||||||
await self.log_channel.send(embed=em)
|
await self.log_channel.send(embed=em)
|
||||||
|
|
||||||
|
|
||||||
def setup(bot):
|
def setup(bot):
|
||||||
bot.add_cog(SendLogs(bot))
|
bot.add_cog(SendLogs(bot))
|
||||||
|
|
|
@ -1,11 +1,10 @@
|
||||||
from discord.ext import commands
|
|
||||||
import discord
|
|
||||||
import random
|
|
||||||
import asyncio
|
import asyncio
|
||||||
import datetime
|
|
||||||
|
import discord
|
||||||
|
from discord.ext import commands
|
||||||
|
|
||||||
|
|
||||||
class Sondage:
|
class Sondage(commands.Cog):
|
||||||
"""Commandes sondage."""
|
"""Commandes sondage."""
|
||||||
|
|
||||||
def __init__(self, bot):
|
def __init__(self, bot):
|
||||||
|
@ -19,14 +18,18 @@ class Sondage:
|
||||||
time = [x for x in options if x.startswith("time=")]
|
time = [x for x in options if x.startswith("time=")]
|
||||||
if time:
|
if time:
|
||||||
time = time[0]
|
time = time[0]
|
||||||
|
if time:
|
||||||
options.remove(time)
|
options.remove(time)
|
||||||
|
if len(options) <= 1:
|
||||||
|
raise commands.errors.MissingRequiredArgument
|
||||||
|
if len(options) >= 22:
|
||||||
|
return await ctx.send(f"{ctx.message.author.mention}> "
|
||||||
|
f":octagonal_sign: Vous ne pouvez pas "
|
||||||
|
f"mettre plus de 20 réponses !")
|
||||||
|
if time:
|
||||||
time = int(time.strip("time="))
|
time = int(time.strip("time="))
|
||||||
else:
|
else:
|
||||||
time = 0
|
time = 0
|
||||||
if len(options) <= 1:
|
|
||||||
raise commands.errors.MissingRequiredArgument
|
|
||||||
if len(options) >= 21:
|
|
||||||
return await ctx.send(ctx.author.mention + "> :octagonal_sign: Vous ne pouvez pas mettre plus de 20 réponses !")
|
|
||||||
emoji = ['1⃣',
|
emoji = ['1⃣',
|
||||||
'2⃣',
|
'2⃣',
|
||||||
'3⃣',
|
'3⃣',
|
||||||
|
@ -49,12 +52,12 @@ class Sondage:
|
||||||
'🇮'
|
'🇮'
|
||||||
]
|
]
|
||||||
to_react = []
|
to_react = []
|
||||||
confirmation_msg = "**{}?**:\n\n".format(options[0].rstrip("?"))
|
confirmation_msg = f"**{options[0].rstrip('?')}?**:\n\n"
|
||||||
for idx, option in enumerate(options[1:]):
|
for idx, option in enumerate(options[1:]):
|
||||||
confirmation_msg += "{} - {}\n".format(emoji[idx], option)
|
confirmation_msg += "{} - {}\n".format(emoji[idx], option)
|
||||||
to_react.append(emoji[idx])
|
to_react.append(emoji[idx])
|
||||||
confirmation_msg += "*Sondage proposé par* " + \
|
confirmation_msg += "*Sondage proposé par* " + \
|
||||||
str(ctx.author.mention)
|
str(ctx.message.author.mention)
|
||||||
if time == 0:
|
if time == 0:
|
||||||
confirmation_msg += ""
|
confirmation_msg += ""
|
||||||
else:
|
else:
|
||||||
|
@ -103,5 +106,6 @@ class Sondage:
|
||||||
colour=0xEEEEEE)
|
colour=0xEEEEEE)
|
||||||
await ctx.send(embed=em)
|
await ctx.send(embed=em)
|
||||||
|
|
||||||
|
|
||||||
def setup(bot):
|
def setup(bot):
|
||||||
bot.add_cog(Sondage(bot))
|
bot.add_cog(Sondage(bot))
|
||||||
|
|
|
@ -1,15 +1,16 @@
|
||||||
from discord.ext import commands
|
import datetime
|
||||||
import discord
|
|
||||||
import random
|
|
||||||
import json
|
import json
|
||||||
import datetime, pytz
|
import pytz
|
||||||
import calendar
|
import random
|
||||||
|
|
||||||
import requests
|
|
||||||
import urllib
|
import urllib
|
||||||
|
import socket
|
||||||
|
|
||||||
|
import discord
|
||||||
|
import requests
|
||||||
|
from discord.ext import commands
|
||||||
|
|
||||||
|
|
||||||
class Utility:
|
class Utility(commands.Cog):
|
||||||
"""Commandes utilitaires."""
|
"""Commandes utilitaires."""
|
||||||
|
|
||||||
def __init__(self, bot):
|
def __init__(self, bot):
|
||||||
|
@ -178,7 +179,7 @@ class Utility:
|
||||||
await ctx.send(embed=em)
|
await ctx.send(embed=em)
|
||||||
|
|
||||||
|
|
||||||
"""--------------------------------------------------------------------------------------------------------------------------"""
|
"""---------------------------------------------------------------------"""
|
||||||
|
|
||||||
@commands.command()
|
@commands.command()
|
||||||
async def ytdiscover(self, ctx):
|
async def ytdiscover(self, ctx):
|
||||||
|
@ -195,7 +196,7 @@ class Utility:
|
||||||
embed.set_thumbnail(url='https://outout.tech/tuxbot/yt.png')
|
embed.set_thumbnail(url='https://outout.tech/tuxbot/yt.png')
|
||||||
await ctx.send(embed=embed)
|
await ctx.send(embed=embed)
|
||||||
|
|
||||||
"""--------------------------------------------------------------------------------------------------------------------------"""
|
"""---------------------------------------------------------------------"""
|
||||||
|
|
||||||
@commands.command(name='hastebin', pass_context=True)
|
@commands.command(name='hastebin', pass_context=True)
|
||||||
async def _hastebin(self, ctx, *, data):
|
async def _hastebin(self, ctx, *, data):
|
||||||
|
@ -205,29 +206,61 @@ class Utility:
|
||||||
post = requests.post("https://hastebin.com/documents", data=data)
|
post = requests.post("https://hastebin.com/documents", data=data)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
await ctx.send(f"{ctx.message.author.mention} message posté avec succès sur :\nhttps://hastebin.com/{post.json()['key']}.txt")
|
await ctx.send(f"{ctx.author.mention} message posté avec succès sur :\nhttps://hastebin.com/{post.json()['key']}.txt")
|
||||||
except json.JSONDecodeError:
|
except json.JSONDecodeError:
|
||||||
await ctx.send("Impossible de poster ce message. L'API doit être HS.")
|
await ctx.send("Impossible de poster ce message. L'API doit être HS.")
|
||||||
|
|
||||||
"""---------------------------------------------------------------------"""
|
"""---------------------------------------------------------------------"""
|
||||||
|
|
||||||
@commands.command(name='iplocalise', pass_context=True)
|
@commands.command(name='iplocalise', pass_context=True)
|
||||||
async def _iplocalise(self, ctx, ipaddress):
|
async def _iplocalise(self, ctx, ipaddress, iptype=""):
|
||||||
|
realipaddress = ipaddress
|
||||||
"""Recup headers."""
|
"""Recup headers."""
|
||||||
if ipaddress.startswith("http://"):
|
if ipaddress.startswith("http://"):
|
||||||
|
if ipaddress[-1:] == '/':
|
||||||
|
ipaddress = ipaddress[:-1]
|
||||||
ipaddress = ipaddress.split("http://")[1]
|
ipaddress = ipaddress.split("http://")[1]
|
||||||
if ipaddress.startswith("https://"):
|
if ipaddress.startswith("https://"):
|
||||||
|
if ipaddress[-1:] == '/':
|
||||||
|
ipaddress = ipaddress[:-1]
|
||||||
ipaddress = ipaddress.split("https://")[1]
|
ipaddress = ipaddress.split("https://")[1]
|
||||||
|
|
||||||
|
if(iptype=="ipv6" or iptype=="v6"):
|
||||||
|
try:
|
||||||
|
ipaddress = socket.getaddrinfo(ipaddress, None, socket.AF_INET6)[1][4][0]
|
||||||
|
except:
|
||||||
|
await ctx.send("Erreur, cette adresse n'est pas disponible en IPv6.")
|
||||||
|
return
|
||||||
|
|
||||||
iploading = await ctx.send("_réfléchis..._")
|
iploading = await ctx.send("_réfléchis..._")
|
||||||
ipapi = urllib.request.urlopen("http://ip-api.com/json/" + ipaddress)
|
ipapi = urllib.request.urlopen("http://ip-api.com/json/" + ipaddress)
|
||||||
ipinfo = json.loads(ipapi.read().decode())
|
ipinfo = json.loads(ipapi.read().decode())
|
||||||
|
|
||||||
if ipinfo["status"] != "fail":
|
if ipinfo["status"] != "fail":
|
||||||
await iploading.edit(content="L'adresse IP ``{query}`` appartient à ``{org}`` et se situe à ``{city}``, dans ``{regionName}``, ``{country}``.".format(**ipinfo))
|
if ipinfo['query']:
|
||||||
else:
|
embed = discord.Embed(title=f"Informations pour ``{realipaddress}`` *`({ipinfo['query']})`*", color=0x5858d7)
|
||||||
await iploading.edit(content=f"Erreur, impossible d'avoir des informations sur l'adresse IP {ipinfo['query']}")
|
|
||||||
|
|
||||||
"""--------------------------------------------------------------------------------------------------------------------------"""
|
if ipinfo['org']:
|
||||||
|
embed.add_field(name="Appartient à :", value=ipinfo['org'], inline = False)
|
||||||
|
|
||||||
|
if ipinfo['city']:
|
||||||
|
embed.add_field(name="Se situe à :", value=ipinfo['city'], inline = True)
|
||||||
|
|
||||||
|
|
||||||
|
if ipinfo['country']:
|
||||||
|
if ipinfo['regionName']:
|
||||||
|
regionName = ipinfo['regionName']
|
||||||
|
else:
|
||||||
|
regionName = "N/A"
|
||||||
|
embed.add_field(name="Region :", value=f"{regionName} ({ipinfo['country']})", inline = True)
|
||||||
|
|
||||||
|
embed.set_thumbnail(url=f"https://www.countryflags.io/{ipinfo['countryCode']}/flat/64.png")
|
||||||
|
await ctx.send(embed=embed)
|
||||||
|
else:
|
||||||
|
await ctx.send(content=f"Erreur, impossible d'avoir des informations sur l'adresse IP ``{ipinfo['query']}``")
|
||||||
|
await iploading.delete()
|
||||||
|
|
||||||
|
"""---------------------------------------------------------------------"""
|
||||||
@commands.command(name='getheaders', pass_context=True)
|
@commands.command(name='getheaders', pass_context=True)
|
||||||
async def _getheaders(self, ctx, *, adresse):
|
async def _getheaders(self, ctx, *, adresse):
|
||||||
"""Recuperer les HEADERS :d"""
|
"""Recuperer les HEADERS :d"""
|
||||||
|
@ -268,17 +301,23 @@ class Utility:
|
||||||
print("ERROR @ getheaders @ Exception : {} - adress {}".format(e, adresse))
|
print("ERROR @ getheaders @ Exception : {} - adress {}".format(e, adresse))
|
||||||
await ctx.send("{0} Impossible d'accèder à {1}, es-tu sur que l'adresse {1} est correcte et que le serveur est allumé ?".format(ctx.author.mention, adresse))
|
await ctx.send("{0} Impossible d'accèder à {1}, es-tu sur que l'adresse {1} est correcte et que le serveur est allumé ?".format(ctx.author.mention, adresse))
|
||||||
else:
|
else:
|
||||||
await ctx.send("{0} Merci de faire commencer {1} par ``https://``, ``http://`` ou ``ftp://``.".format(ctx.message.author.mention, adresse))
|
await ctx.send("{0} Merci de faire commencer {1} par ``https://``, ``http://`` ou ``ftp://``.".format(ctx.author.mention, adresse))
|
||||||
|
|
||||||
"""--------------------------------------------------------------------------------------------------------------------------"""
|
"""---------------------------------------------------------------------"""
|
||||||
|
|
||||||
@commands.command(name='github', pass_context=True)
|
@commands.command(name='git', pass_context=True)
|
||||||
async def _github(ctx):
|
async def _git(self, ctx):
|
||||||
"""Pour voir mon code"""
|
"""Pour voir mon code"""
|
||||||
text = "How tu veux voir mon repos Github pour me disséquer ? Pas de soucis ! Je suis un Bot, je ne ressens pas la douleur !\n https://github.com/outout14/tuxbot-bot"
|
text = "How tu veux voir mon repos Gitea pour me disséquer ? " \
|
||||||
|
"Pas de soucis ! Je suis un Bot, je ne ressens pas la " \
|
||||||
|
"douleur !\n https://git.gnous.eu/gnous/tuxbot"
|
||||||
em = discord.Embed(title='Repos TuxBot-Bot', description=text, colour=0xE9D460)
|
em = discord.Embed(title='Repos TuxBot-Bot', description=text, colour=0xE9D460)
|
||||||
em.set_author(name='Outout', icon_url="https://avatars0.githubusercontent.com/u/14958554?v=3&s=400")
|
em.set_author(name='Gnous', icon_url="https://cdn.discordapp.com/"
|
||||||
|
"icons/280805240977227776/"
|
||||||
|
"9ba1f756c9d9bfcf27989d0d0abb3862"
|
||||||
|
".png")
|
||||||
await ctx.send(embed=em)
|
await ctx.send(embed=em)
|
||||||
|
|
||||||
|
|
||||||
def setup(bot):
|
def setup(bot):
|
||||||
bot.add_cog(Utility(bot))
|
bot.add_cog(Utility(bot))
|
||||||
|
|
0
cogs/utils/cli_colors.py
Normal file → Executable file
0
cogs/utils/cli_colors.py
Normal file → Executable file
|
@ -1,67 +0,0 @@
|
||||||
import json
|
|
||||||
import os
|
|
||||||
import uuid
|
|
||||||
import asyncio
|
|
||||||
|
|
||||||
class Config:
|
|
||||||
"""The "database" object. Internally based on ``json``."""
|
|
||||||
|
|
||||||
def __init__(self, name, **options):
|
|
||||||
self.name = name
|
|
||||||
self.object_hook = options.pop('object_hook', None)
|
|
||||||
self.encoder = options.pop('encoder', None)
|
|
||||||
self.loop = options.pop('loop', asyncio.get_event_loop())
|
|
||||||
self.lock = asyncio.Lock()
|
|
||||||
if options.pop('load_later', False):
|
|
||||||
self.loop.create_task(self.load())
|
|
||||||
else:
|
|
||||||
self.load_from_file()
|
|
||||||
|
|
||||||
def load_from_file(self):
|
|
||||||
try:
|
|
||||||
with open(self.name, 'r') as f:
|
|
||||||
self._db = json.load(f, object_hook=self.object_hook)
|
|
||||||
except FileNotFoundError:
|
|
||||||
self._db = {}
|
|
||||||
|
|
||||||
async def load(self):
|
|
||||||
with await self.lock:
|
|
||||||
await self.loop.run_in_executor(None, self.load_from_file)
|
|
||||||
|
|
||||||
def _dump(self):
|
|
||||||
temp = '%s-%s.tmp' % (uuid.uuid4(), self.name)
|
|
||||||
with open(temp, 'w', encoding='utf-8') as tmp:
|
|
||||||
json.dump(self._db.copy(), tmp, ensure_ascii=True, cls=self.encoder, separators=(',', ':'))
|
|
||||||
|
|
||||||
# atomically move the file
|
|
||||||
os.replace(temp, self.name)
|
|
||||||
|
|
||||||
async def save(self):
|
|
||||||
with await self.lock:
|
|
||||||
await self.loop.run_in_executor(None, self._dump)
|
|
||||||
|
|
||||||
def get(self, key, *args):
|
|
||||||
"""Retrieves a config entry."""
|
|
||||||
return self._db.get(key, *args)
|
|
||||||
|
|
||||||
async def put(self, key, value, *args):
|
|
||||||
"""Edits a config entry."""
|
|
||||||
self._db[key] = value
|
|
||||||
await self.save()
|
|
||||||
|
|
||||||
async def remove(self, key):
|
|
||||||
"""Removes a config entry."""
|
|
||||||
del self._db[key]
|
|
||||||
await self.save()
|
|
||||||
|
|
||||||
def __contains__(self, item):
|
|
||||||
return item in self._db
|
|
||||||
|
|
||||||
def __getitem__(self, item):
|
|
||||||
return self._db[item]
|
|
||||||
|
|
||||||
def __len__(self):
|
|
||||||
return len(self._db)
|
|
||||||
|
|
||||||
def all(self):
|
|
||||||
return self._db
|
|
|
@ -1,5 +1,6 @@
|
||||||
import pymysql
|
import pymysql
|
||||||
|
|
||||||
|
|
||||||
def connect_to_db(self):
|
def connect_to_db(self):
|
||||||
mysqlHost = self.bot.config.mysql["host"]
|
mysqlHost = self.bot.config.mysql["host"]
|
||||||
mysqlUser = self.bot.config.mysql["username"]
|
mysqlUser = self.bot.config.mysql["username"]
|
||||||
|
@ -7,12 +8,15 @@ def connect_to_db(self):
|
||||||
mysqlDB = self.bot.config.mysql["dbname"]
|
mysqlDB = self.bot.config.mysql["dbname"]
|
||||||
|
|
||||||
try:
|
try:
|
||||||
return pymysql.connect(host=mysqlHost, user=mysqlUser, passwd=mysqlPass, db=mysqlDB, charset='utf8')
|
return pymysql.connect(host=mysqlHost, user=mysqlUser,
|
||||||
|
passwd=mysqlPass, db=mysqlDB, charset='utf8')
|
||||||
except KeyError:
|
except KeyError:
|
||||||
print("Rest in peperoni, Impossible de se connecter a la base de données.")
|
print(
|
||||||
|
"Rest in peperoni, Impossible de se connecter a la base de données.")
|
||||||
print(str(KeyError))
|
print(str(KeyError))
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
def reconnect_to_db(self):
|
def reconnect_to_db(self):
|
||||||
if not self.conn:
|
if not self.conn:
|
||||||
mysqlHost = self.bot.config.mysql["host"]
|
mysqlHost = self.bot.config.mysql["host"]
|
||||||
|
@ -20,5 +24,6 @@ def reconnect_to_db(self):
|
||||||
mysqlPass = self.bot.config.mysql["password"]
|
mysqlPass = self.bot.config.mysql["password"]
|
||||||
mysqlDB = self.bot.config.mysql["dbname"]
|
mysqlDB = self.bot.config.mysql["dbname"]
|
||||||
|
|
||||||
return pymysql.connect(host=mysqlHost, user=mysqlUser, passwd=mysqlPass, db=mysqlDB, charset='utf8')
|
return pymysql.connect(host=mysqlHost, user=mysqlUser,
|
||||||
|
passwd=mysqlPass, db=mysqlDB, charset='utf8')
|
||||||
return self.conn
|
return self.conn
|
0
cogs/utils/menu.py
Normal file → Executable file
0
cogs/utils/menu.py
Normal file → Executable file
0
cogs/utils/passport_generator.py
Normal file → Executable file
0
cogs/utils/passport_generator.py
Normal file → Executable file
113
cogs/vocal.py
Executable file
113
cogs/vocal.py
Executable file
|
@ -0,0 +1,113 @@
|
||||||
|
import asyncio
|
||||||
|
import os
|
||||||
|
import re
|
||||||
|
import subprocess
|
||||||
|
import uuid
|
||||||
|
|
||||||
|
import discord
|
||||||
|
from discord.ext import commands
|
||||||
|
from gtts import gTTS
|
||||||
|
|
||||||
|
|
||||||
|
class Vocal(commands.Cog):
|
||||||
|
|
||||||
|
def __init__(self, bot):
|
||||||
|
self.bot = bot
|
||||||
|
self.playing = False
|
||||||
|
self.author = None
|
||||||
|
self.voice = None
|
||||||
|
|
||||||
|
"""---------------------------------------------------------------------"""
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def get_duration(file):
|
||||||
|
popen = subprocess.Popen(("ffprobe",
|
||||||
|
"-show_entries",
|
||||||
|
"format=duration",
|
||||||
|
"-i", file),
|
||||||
|
stdout=subprocess.PIPE,
|
||||||
|
stderr=subprocess.PIPE)
|
||||||
|
output, err = popen.communicate()
|
||||||
|
match = re.search(r"[-+]?\d*\.\d+|\d+", str(output))
|
||||||
|
return float(match.group())
|
||||||
|
|
||||||
|
@commands.command(name="voc", no_pm=True, pass_context=True)
|
||||||
|
async def _voc(self, ctx, *, message=""):
|
||||||
|
if message == "":
|
||||||
|
await ctx.send("Veuillez écrire un message...")
|
||||||
|
return
|
||||||
|
if message == "stop_playing" \
|
||||||
|
and (
|
||||||
|
ctx.author.id == self.author.id
|
||||||
|
or ctx.message.channel.permissions_for(
|
||||||
|
ctx.message.author
|
||||||
|
).administrator is True
|
||||||
|
) \
|
||||||
|
and self.playing is True:
|
||||||
|
|
||||||
|
await ctx.send('stop')
|
||||||
|
await self.voice.disconnect()
|
||||||
|
self.playing = False
|
||||||
|
return
|
||||||
|
|
||||||
|
if self.playing is True:
|
||||||
|
await ctx.send("Je suis déja en train de parler,"
|
||||||
|
" merci de réenvoyer ton message"
|
||||||
|
" quand j'aurais fini.")
|
||||||
|
return
|
||||||
|
|
||||||
|
user = ctx.author
|
||||||
|
self.author = user
|
||||||
|
|
||||||
|
if user.voice:
|
||||||
|
self.playing = True
|
||||||
|
filename = f"data/tmp/voc/{uuid.uuid1()}.mp3"
|
||||||
|
lang = [x for x in message.split(" ") if x.startswith("lang=")]
|
||||||
|
|
||||||
|
loading = await ctx.send("*Chargement du message en cours...*")
|
||||||
|
|
||||||
|
if lang:
|
||||||
|
choice_lang = (lang[0])[5:]
|
||||||
|
message = f"{user.display_name} à dit: {message.strip(lang[0])}" if len(ctx.author.voice.channel.members) >= 4 else message.strip(lang[0])
|
||||||
|
|
||||||
|
try:
|
||||||
|
tts = gTTS(
|
||||||
|
text=message,
|
||||||
|
lang=str(choice_lang))
|
||||||
|
except ValueError:
|
||||||
|
tts = gTTS(
|
||||||
|
text=message,
|
||||||
|
lang="fr")
|
||||||
|
await ctx.send("La langue n'est pas supportée,"
|
||||||
|
" le francais a donc été choisi")
|
||||||
|
else:
|
||||||
|
message = f"{user.display_name} à dit: {message}" if len(ctx.author.voice.channel.members) >= 4 else message
|
||||||
|
tts = gTTS(text=message,
|
||||||
|
lang="fr")
|
||||||
|
|
||||||
|
tts.save(filename)
|
||||||
|
|
||||||
|
self.voice = await user.voice.channel.connect()
|
||||||
|
self.voice.play(discord.FFmpegPCMAudio(filename))
|
||||||
|
counter = 0
|
||||||
|
duration = self.get_duration(filename)
|
||||||
|
while not counter >= duration:
|
||||||
|
if self.playing:
|
||||||
|
await loading.edit(
|
||||||
|
content=f"Lecture du message de {self.author.display_name} en cours : {counter}sec/{duration}sec")
|
||||||
|
await asyncio.sleep(1)
|
||||||
|
counter += 1
|
||||||
|
else:
|
||||||
|
break
|
||||||
|
await self.voice.disconnect()
|
||||||
|
|
||||||
|
await loading.edit(content="Lecture terminée")
|
||||||
|
self.voice = None
|
||||||
|
os.remove(filename)
|
||||||
|
self.playing = False
|
||||||
|
else:
|
||||||
|
await ctx.send('Veuillez aller dans un channel vocal.')
|
||||||
|
|
||||||
|
|
||||||
|
def setup(bot):
|
||||||
|
bot.add_cog(Vocal(bot))
|
0
config.py.example
Executable file → Normal file
0
config.py.example
Executable file → Normal file
0
data/.DS_Store
vendored
Normal file → Executable file
0
data/.DS_Store
vendored
Normal file → Executable file
0
data/images/.DS_Store
vendored
Normal file → Executable file
0
data/images/.DS_Store
vendored
Normal file → Executable file
0
data/images/roles/android.png
Normal file → Executable file
0
data/images/roles/android.png
Normal file → Executable file
Before Width: | Height: | Size: 1,012 B After Width: | Height: | Size: 1,012 B |
BIN
data/images/roles/redhat.png
Executable file
BIN
data/images/roles/redhat.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 1.1 KiB |
0
data/images/roles/small/android.png
Normal file → Executable file
0
data/images/roles/small/android.png
Normal file → Executable file
Before Width: | Height: | Size: 518 B After Width: | Height: | Size: 518 B |
3
init.sh
Executable file
3
init.sh
Executable file
|
@ -0,0 +1,3 @@
|
||||||
|
#pip install -U "https://github.com/Rapptz/discord.py/archive/rewrite.zip#egg=discord.py[voice]"
|
||||||
|
python3 -m pip install -U discord.py[voice]
|
||||||
|
pip install -r requirements.txt
|
43
launch.py
43
launch.py
|
@ -1,43 +0,0 @@
|
||||||
#! /usr/bin/env python3
|
|
||||||
|
|
||||||
import locale
|
|
||||||
from dialog import Dialog
|
|
||||||
from subprocess import call
|
|
||||||
import os
|
|
||||||
|
|
||||||
locale.setlocale(locale.LC_ALL, '')
|
|
||||||
d = Dialog(dialog="dialog")
|
|
||||||
d.set_background_title("Tuxbot Manager v0.5a")
|
|
||||||
|
|
||||||
while True:
|
|
||||||
|
|
||||||
mmenu, rmenu = d.menu("Que souhaitez vous faire ?", choices = [("(1)", "Lancer Tuxbot"), ("(2)", "Eteindre Tuxbot"), ("(3)", "Mettre à jour Tuxbot"), ("(4)", "Quitter")])
|
|
||||||
|
|
||||||
if rmenu == "(1)":
|
|
||||||
d.gauge_start("Lancement")
|
|
||||||
d.gauge_update(10)
|
|
||||||
# try:
|
|
||||||
# call(["screen", "-S", "tuxbot", "-X","quit"])
|
|
||||||
# except:
|
|
||||||
# d.gauge_update(35)
|
|
||||||
d.gauge_update(40)
|
|
||||||
call(["screen","-S","tuxbot", "-d", "-m", "python3", "bot.py"])
|
|
||||||
d.gauge_update(100)
|
|
||||||
d.gauge_stop()
|
|
||||||
d.msgbox("Tuxbot est correctement lancé ! Merci de faire .ping sur discord pour vérifier.")
|
|
||||||
|
|
||||||
if rmenu == "(2)":
|
|
||||||
d.gauge_start("Arrêt")
|
|
||||||
d.gauge_update(10)
|
|
||||||
call(["screen", "-S", "tuxbot", "-X","quit"])
|
|
||||||
d.gauge_update(100)
|
|
||||||
d.gauge_stop()
|
|
||||||
d.msgbox("Tuxbot s'est correctement arrêté. Faites vite ;-) !")
|
|
||||||
|
|
||||||
if rmenu == "(4)":
|
|
||||||
d.pause("A bientôt !\n(C) 2018 Gnous.EU Dev Team.", seconds=2)
|
|
||||||
call(["clear"])
|
|
||||||
exit()
|
|
||||||
|
|
||||||
if rmenu == "(3)":
|
|
||||||
d.msgbox("Fonctionnalité indisponible pour le moment du fait que le serveur GIT de tuxbot est hors service.")
|
|
|
@ -1,9 +0,0 @@
|
||||||
{
|
|
||||||
"token": "bot token",
|
|
||||||
"bots_key": "not required",
|
|
||||||
"client_id": "client id (Pas obligatoire)",
|
|
||||||
"game": "Eating apples - .help",
|
|
||||||
"prefix": [
|
|
||||||
"."
|
|
||||||
]
|
|
||||||
}
|
|
|
@ -6,7 +6,7 @@ Ici ce trouve le code source du bot provenant du serveur Discord ["Gnous.eu"](h
|
||||||
[Voir le guide d'installation](https://wiki.gnous.eu/wiki/Tuxbot/Install)
|
[Voir le guide d'installation](https://wiki.gnous.eu/wiki/Tuxbot/Install)
|
||||||
|
|
||||||
## Fabriqué avec
|
## Fabriqué avec
|
||||||
* [PyCharm](https://www.jetbrains.com/pycharm/) - Editeur de texte payant :3
|
* [PyCharm](https://www.jetbrains.com/pycharm/) - IDE payant :3
|
||||||
* [discord.py](https://github.com/Rapptz/discord.py) - API Python pour discord
|
* [discord.py](https://github.com/Rapptz/discord.py) - API Python pour discord
|
||||||
|
|
||||||
## Versions
|
## Versions
|
||||||
|
@ -14,7 +14,7 @@ Liste des versions : [Cliquer pour afficher](https://github.com/outout14/tuxbot-
|
||||||
|
|
||||||
## Auteurs
|
## Auteurs
|
||||||
* **Maël** _alias_ [@outout14](https://github.com/outout14)
|
* **Maël** _alias_ [@outout14](https://github.com/outout14)
|
||||||
* **Romain** _alias_ [Romain](https://github.com/Rom194)
|
* **Romain** _alias_ [Romain](https://git.gnous.eu/Romain)
|
||||||
|
|
||||||
## License
|
## License
|
||||||
Ce projet est sous licence ``Creative Commons BY-NC-SA 4.0`` - voir le fichier [LICENSE.md](LICENSE.md) pour plus d'informations
|
Ce projet est sous licence ``Creative Commons BY-NC-SA 4.0`` - voir le fichier [LICENSE.md](LICENSE.md) pour plus d'informations
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
git+https://github.com/Rapptz/discord.py@rewrite
|
pymysql
|
||||||
asyncio
|
gtts
|
||||||
beautifulsoup4
|
beautifulsoup4
|
||||||
|
lxml==4.2.4
|
||||||
bs4
|
bs4
|
||||||
pytz
|
pytz
|
||||||
requests
|
requests
|
||||||
wikipedia
|
wikipedia
|
||||||
pymysql
|
|
||||||
pillow
|
pillow
|
|
@ -11,16 +11,17 @@
|
||||||
-> .sondage : Affiche l'aide pour la commande sondage
|
-> .sondage : Affiche l'aide pour la commande sondage
|
||||||
-> .role _nomdurole_ : Ajoute/Retire le rôle en question
|
-> .role _nomdurole_ : Ajoute/Retire le rôle en question
|
||||||
-> .iplocalise _IP ou NDD_ : affiche la localisation et le propriétaire de l'ip (ou de l'IP lié a un nom de domaine)
|
-> .iplocalise _IP ou NDD_ : affiche la localisation et le propriétaire de l'ip (ou de l'IP lié a un nom de domaine)
|
||||||
|
-> .iplocalise _IP ou NDD_ **ipv6**: affiche la localisation et le propriétaire de l'ip en forçant sur l'IPv6 (ou de l'IP lié a un nom de domaine)
|
||||||
-> .getheaders _IP ou NDD_ : affiche les en-têtes (headers) d'une IP/Nom de domaine via HTTP/HTTPS/FTP
|
-> .getheaders _IP ou NDD_ : affiche les en-têtes (headers) d'une IP/Nom de domaine via HTTP/HTTPS/FTP
|
||||||
-> .btcprice : Affiche le prix du bitcoin
|
-> .btcprice : Affiche le prix du bitcoin
|
||||||
|
[split]
|
||||||
**Commandes Funs**
|
**Commandes Funs**
|
||||||
-> .joke : Affiche une blague aléatoire
|
-> .joke : Affiche une blague aléatoire
|
||||||
-> .ethylotest : Simule un ethylotest détraqué
|
-> .ethylotest : Simule un ethylotest détraqué
|
||||||
-> .pokemon : Lance un combat de pokémons
|
-> .pokemon : Lance un combat de pokémons
|
||||||
-> .coin : Simule un pile ou face
|
-> .coin : Simule un pile ou face
|
||||||
-> .randomcat : Affiche des image de chats :3
|
-> .randomcat : Affiche des image de chats :3
|
||||||
|
[split]
|
||||||
**Commandes Carte d'Identité**
|
**Commandes Carte d'Identité**
|
||||||
-> .ci : Affiche l'aide sur les cartes d'identité
|
-> .ci : Affiche l'aide sur les cartes d'identité
|
||||||
-> .ci show _pseudo_ : Affiche la carte d'identité de _pseudo_
|
-> .ci show _pseudo_ : Affiche la carte d'identité de _pseudo_
|
||||||
|
@ -30,10 +31,10 @@
|
||||||
-> .ci setcountry : Défini votre pays
|
-> .ci setcountry : Défini votre pays
|
||||||
-> .ci update : Met à jour votre image si vous l'avez changé :wink:
|
-> .ci update : Met à jour votre image si vous l'avez changé :wink:
|
||||||
-> .ci delete : Supprime votre carte d'identité **a tous jamais**
|
-> .ci delete : Supprime votre carte d'identité **a tous jamais**
|
||||||
|
[split]
|
||||||
**Commandes diverses** :
|
**Commandes diverses** :
|
||||||
-> .info : Affiche des informations sur le bot
|
-> .info : Affiche des informations sur le bot
|
||||||
-> .help : Affiche ce message
|
-> .help : Affiche ce message
|
||||||
-> .clock : Affiche la liste des horloges des villes
|
-> .clock : Affiche la liste des horloges des villes
|
||||||
-> .ping : Ping le bot
|
-> .ping : Ping le bot
|
||||||
-> .github : Affiche le repos Github du Bot :heart:
|
-> .git : Affiche le repos Gitea du Bot :heart:
|
||||||
|
|
|
@ -1,24 +1,24 @@
|
||||||
|
|
||||||
<:stafftools:314348604095594498> **Développement** :
|
:tools: **Développement** :
|
||||||
└> Outout : [outout.xyz](https://outout.xyz/)
|
└> Outout : [outout.xyz](https://outout.xyz/)
|
||||||
└> Romain : [son github](http://git.dyjix.eu/Romain)
|
└> Romain : [son github](http://git.gnous.eu/Romain)
|
||||||
└> Langage : [Python3](http://www.python.org/)
|
└> Langage : [Python3](http://www.python.org/)
|
||||||
└> Api : [discord.py {3}](https://github.com/Rapptz/discord.py)
|
└> Api : [discord.py {3}](https://github.com/Rapptz/discord.py)
|
||||||
|
└> Discord Api : [{4}]({4})
|
||||||
└> En se basant sur : [RobotDanny](https://github.com/Rapptz/RoboDanny)
|
└> En se basant sur : [RobotDanny](https://github.com/Rapptz/RoboDanny)
|
||||||
|
|
||||||
<:server:334347432835940352> **Hébergé sur "{2}"**:
|
<:server:577916597239283742> **Hébergé sur "{2}"**:
|
||||||
└> <:tux:282212977627758593> OS : {0}
|
└> <:tux:282212977627758593> OS : {0}
|
||||||
└> <:python:334346615366221825> Version : {1}
|
└> Version : {1}
|
||||||
|
|
||||||
<:contact:334347787200233483> **Contact** :
|
:telephone: **Contact** :
|
||||||
└> <:discord:314003252830011395> : Outout#8406
|
└> <:DiscordLogoColor:577915413573402624> : Outout#8406
|
||||||
└> <:twitter:314349922877046786> : [@outoutxyz](https://twitter.com/outouxyz)
|
└> <:twitter:577915119032336387> : [@outoutxyz](https://twitter.com/outouxyz)
|
||||||
└> <:mail:334345653419245571> : [mael@gnous.eu](mailto:mael@gnous.eu)
|
└> :mailbox: : [mael@gnous.eu](mailto:mael@gnous.eu)
|
||||||
└> <:discord:314003252830011395> : Romain#5117
|
└> <:DiscordLogoColor:577915413573402624> : Romain#5117
|
||||||
|
|
||||||
|
|
||||||
<:discord:314003252830011395> **Serveurs** :
|
<:DiscordLogoColor:577915413573402624> **Serveur** :
|
||||||
└> :tux: Serveur de TuxBot : [rejoindre](https://discord.gg/5UZy8Pn)
|
└> Serveur GnousEU : [rejoindre](https://discord.gg/NFW3EeS)
|
||||||
└> <:tux:514930485751971866> Serveur GNU/Linux-Fr : [rejoindre](https://discord.gg/B5TzW7x)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
0
texts/rpoll.md
Normal file → Executable file
0
texts/rpoll.md
Normal file → Executable file
Loading…
Reference in a new issue