classification par ordre alphabetique du bot
This commit is contained in:
parent
991849e907
commit
e46ea1f626
1 changed files with 197 additions and 197 deletions
|
@ -27,119 +27,25 @@ class Mybot(commands.Cog):
|
|||
self.sounds_history = []
|
||||
self.play_next.start()
|
||||
|
||||
@commands.command()
|
||||
async def join(self, ctx):
|
||||
channel = [x for x in self.bot.get_all_channels() if x.name == "Général"][0]
|
||||
await channel.connect()
|
||||
await asyncio.sleep(2)
|
||||
@tasks.loop(seconds=1.5)
|
||||
async def play_next(self):
|
||||
if self.sounds:
|
||||
audio_file, ctx = self.sounds[0]
|
||||
source = discord.PCMVolumeTransformer(discord.FFmpegPCMAudio(audio_file))
|
||||
if not ctx.voice_client.is_playing() and ctx.voice_client.is_connected():
|
||||
ctx.voice_client.play(source, after=lambda e: print('Player error: %s' % e) if e else None)
|
||||
self.sounds.pop(0)
|
||||
self.sounds_history.reverse()
|
||||
self.sounds_history.append((audio_file, ctx))
|
||||
self.sounds_history.reverse()
|
||||
if len(self.sounds_history) > 5:
|
||||
self.sounds_history = self.sounds_history[:5]
|
||||
|
||||
#Les commandes interagir avec le bot.
|
||||
@commands.command()
|
||||
async def disconnect(self, ctx):
|
||||
await ctx.guild.voice_client.disconnect()
|
||||
|
||||
@commands.guild_only()
|
||||
@commands.command()
|
||||
async def joke(self, ctx, folder=None):
|
||||
user = ctx.message.author.name
|
||||
if not folder or not ctx.message.content:
|
||||
audio_file = random.choice([f for f in Path(here + '/Audio/').glob('**/*.mp3')])
|
||||
else:
|
||||
folder = folder.lower()
|
||||
audio_file = random.choice([f for f in Path(here + '/Audio/').glob('**/*.mp3') if folder in str(f).lower()])
|
||||
self.sounds.append((audio_file,ctx))
|
||||
|
||||
@commands.command()
|
||||
async def repeat(self, ctx):
|
||||
#if ctx.message.author.name == self.bot.user.name:
|
||||
# return
|
||||
user = ctx.message.author.name
|
||||
source = self.sounds_history[0]
|
||||
self.sounds.append(source)
|
||||
|
||||
@commands.command(help='Gif me')
|
||||
async def gif(self, ctx):
|
||||
query = ctx.message.content.replace('!gif ','')
|
||||
print(query)
|
||||
api_instance = giphy_client.DefaultApi()
|
||||
api_key = "udhL9Rgdme3HpAoFhWVZoYM0l0XwkzLz"
|
||||
lang = 'fr'
|
||||
try:
|
||||
api_response = api_instance.gifs_search_get(api_key, query, lang=lang, limit=10)
|
||||
api_response.to_dict()['data'][0]
|
||||
get_url = random.choice(api_response.to_dict()['data'])
|
||||
get_url['url']
|
||||
await ctx.channel.send(get_url['url'])
|
||||
except ApiException as e:
|
||||
await ctx.channel.send("Exception when calling DefaultApi->gifs_search_get: %s\n" % e)
|
||||
|
||||
@commands.command()
|
||||
async def welcome(self, ctx):
|
||||
#if ctx.message.author.name == self.bot.user.name:
|
||||
# return
|
||||
user = ctx.message.author.name
|
||||
print(user)
|
||||
try:
|
||||
audio_file = random.choice([f for f in os.listdir(here + '/Audio/%s/' % user) if f.endswith('.mp3')])
|
||||
audio_file = here + '/Audio/%s/' % user + audio_file
|
||||
except:
|
||||
audio_file = random.choice([f for f in Path(here + '/Audio/').glob('**/*.mp3')])
|
||||
self.sounds.append((audio_file,ctx))
|
||||
|
||||
@commands.command(help='Update local repo')
|
||||
async def update(self, message):
|
||||
output = Popen('git pull'.split(), stdout=PIPE).communicate()[0]
|
||||
await message.channel.send(output.decode('utf-8'))
|
||||
|
||||
@commands.command(help='Restart Bot')
|
||||
async def restart(self, ctx):
|
||||
await self.bot.logout()
|
||||
|
||||
@commands.command(help='Restart Bot')
|
||||
async def restart_queue(self, ctx):
|
||||
self.play_next.restart()
|
||||
|
||||
@commands.command(help='check if bot always online')
|
||||
async def ping(self, message):
|
||||
await message.channel.send('pong')
|
||||
|
||||
@commands.command(help='count lines numbers in quote file')
|
||||
async def lines(self, ctx):
|
||||
path = here + '/' + ctx.channel
|
||||
with open(path, 'r') as f:
|
||||
lines = f.read().splitlines()
|
||||
nb_lines = len(lines)
|
||||
with ctx.channel.typing():
|
||||
await asyncio.sleep(0.5)
|
||||
await ctx.channel.send("j'ai %s lignes dans mon stock" % nb_lines)
|
||||
|
||||
@commands.command(help='slap this ass')
|
||||
async def slap(self, ctx, user=None):
|
||||
slap_multiple = [
|
||||
"%s prend un coup de pied au cul",
|
||||
"Descente du coude sur %s",
|
||||
"%s est propulsé par dessus la TROISIEME CORDE!",
|
||||
"Le mec en rose, c'est moi et le mec en jaune c'est %s! https://giphy.com/gifs/gSIz6gGLhguOY",
|
||||
]
|
||||
if not user or not ctx.message.mentions:
|
||||
online_members = []
|
||||
members = ctx.guild.members
|
||||
for member in members:
|
||||
if str(member.status) == "online":
|
||||
online_members.append(member)
|
||||
user = random.choice(online_members)
|
||||
user = user.mention
|
||||
elif ctx.message.mentions:
|
||||
user = ctx.message.mentions[0]
|
||||
user = user.mention
|
||||
if user == self.bot.user.mention:
|
||||
with ctx.channel.typing():
|
||||
await asyncio.sleep(0.5)
|
||||
await ctx.channel.send("je tribuche par terre et je sais pas comment")
|
||||
else:
|
||||
with ctx.channel.typing():
|
||||
await asyncio.sleep(len(slap_multiple)/4)
|
||||
await ctx.channel.send(random.choice(slap_multiple) % user)
|
||||
|
||||
@commands.command(help="Interrogation issues \n Args: list, search[mot clé] et add[nom de l'issue]")
|
||||
async def issue(self, ctx, *args):
|
||||
if args:
|
||||
|
@ -171,6 +77,102 @@ class Mybot(commands.Cog):
|
|||
else:
|
||||
await ctx.channel.send('unknown command')
|
||||
|
||||
@commands.command()
|
||||
async def join(self, ctx):
|
||||
channel = [x for x in self.bot.get_all_channels() if x.name == "Général"][0]
|
||||
await channel.connect()
|
||||
await asyncio.sleep(2)
|
||||
|
||||
@commands.command(help='count lines numbers in quote file')
|
||||
async def lines(self, ctx):
|
||||
path = here + '/' + ctx.channel
|
||||
with open(path, 'r') as f:
|
||||
lines = f.read().splitlines()
|
||||
nb_lines = len(lines)
|
||||
with ctx.channel.typing():
|
||||
await asyncio.sleep(0.5)
|
||||
await ctx.channel.send("j'ai %s lignes dans mon stock" % nb_lines)
|
||||
|
||||
@commands.command(help='check if bot always online')
|
||||
async def ping(self, message):
|
||||
await message.channel.send('pong')
|
||||
|
||||
@commands.command()
|
||||
async def repeat(self, ctx):
|
||||
# if ctx.message.author.name == self.bot.user.name:
|
||||
# return
|
||||
user = ctx.message.author.name
|
||||
source = self.sounds_history[0]
|
||||
self.sounds.append(source)
|
||||
|
||||
@commands.command(help='Restart Bot')
|
||||
async def restart(self, ctx):
|
||||
await self.bot.logout()
|
||||
|
||||
@commands.command(help='Restart Bot')
|
||||
async def restart_queue(self, ctx):
|
||||
self.play_next.restart()
|
||||
|
||||
@commands.command(help='Update local repo')
|
||||
async def update(self, message):
|
||||
output = Popen('git pull'.split(), stdout=PIPE).communicate()[0]
|
||||
await message.channel.send(output.decode('utf-8'))
|
||||
|
||||
#Les commandes pour faire mumuse avec le bot.
|
||||
@commands.command(help="randomsur l'avenir des gens.")
|
||||
async def avenir(self, ctx):
|
||||
|
||||
list_mot = ("tu seras curé, tu t'occuperas plus spécialement du catéchisme. ",
|
||||
"tu seras animateur de soirées pour les gays pride. ",
|
||||
"tu seras gynecologue dans une maison de retraite.",
|
||||
"tu iras vivre en thaïland à cause de ton job. car tu seras ladyboy dans un bar.",
|
||||
"tu sera DSI chez jacky et Michel",
|
||||
"tu seras arroseur de plante aquatique.")
|
||||
choix = random.choice(list_mot)
|
||||
with ctx.channel.typing():
|
||||
await asyncio.sleep(len(choix) / 4)
|
||||
await ctx.channel.send(choix)
|
||||
|
||||
@commands.command(help="optionnal args : ")
|
||||
async def contrepeterie(self, ctx, *args):
|
||||
response = None
|
||||
path = here + '/ressources/contrepeteries.txt'
|
||||
lines = open(path).read().splitlines()
|
||||
myline = random.choice(lines)
|
||||
|
||||
try:
|
||||
response = "%s" % (myline)
|
||||
except:
|
||||
response = "Unknow error, try: !contrepeterie [mot clef]"
|
||||
await ctx.send(response)
|
||||
|
||||
@commands.command(help='Gif me')
|
||||
async def gif(self, ctx):
|
||||
query = ctx.message.content.replace('!gif ', '')
|
||||
print(query)
|
||||
api_instance = giphy_client.DefaultApi()
|
||||
api_key = "udhL9Rgdme3HpAoFhWVZoYM0l0XwkzLz"
|
||||
lang = 'fr'
|
||||
try:
|
||||
api_response = api_instance.gifs_search_get(api_key, query, lang=lang, limit=10)
|
||||
api_response.to_dict()['data'][0]
|
||||
get_url = random.choice(api_response.to_dict()['data'])
|
||||
get_url['url']
|
||||
await ctx.channel.send(get_url['url'])
|
||||
except ApiException as e:
|
||||
await ctx.channel.send("Exception when calling DefaultApi->gifs_search_get: %s\n" % e)
|
||||
|
||||
@commands.guild_only()
|
||||
@commands.command()
|
||||
async def joke(self, ctx, folder=None):
|
||||
user = ctx.message.author.name
|
||||
if not folder or not ctx.message.content:
|
||||
audio_file = random.choice([f for f in Path(here + '/Audio/').glob('**/*.mp3')])
|
||||
else:
|
||||
folder = folder.lower()
|
||||
audio_file = random.choice([f for f in Path(here + '/Audio/').glob('**/*.mp3') if folder in str(f).lower()])
|
||||
self.sounds.append((audio_file, ctx))
|
||||
|
||||
@commands.command(help="optionnal args : [livre] [character]")
|
||||
async def kaamelott(self, ctx, *args):
|
||||
response = None
|
||||
|
@ -200,19 +202,6 @@ class Mybot(commands.Cog):
|
|||
response = "Unknow error, try: !kaamelott [livre] [character]"
|
||||
await ctx.send(response)
|
||||
|
||||
@commands.command(help="optionnal args : ")
|
||||
async def contrepeterie(self, ctx, *args):
|
||||
response = None
|
||||
path = here + '/ressources/contrepeteries.txt'
|
||||
lines = open(path).read().splitlines()
|
||||
myline =random.choice(lines)
|
||||
|
||||
try:
|
||||
response = "%s" % (myline)
|
||||
except:
|
||||
response = "Unknow error, try: !contrepeterie [mot clef]"
|
||||
await ctx.send(response)
|
||||
|
||||
@commands.command(help="Je menotte une cornemuse et je fume Eddy Malou")
|
||||
async def kamoulox(self, ctx):
|
||||
sans_verbe = get_word('nom').text + " " + get_word('complement').get('m') + " et " + get_word('nom').text + " " + get_word('complement').get('m') + "."
|
||||
|
@ -304,39 +293,49 @@ class Mybot(commands.Cog):
|
|||
channel = [x for x in self.bot.get_all_channels() if x.name == "général"][0]
|
||||
await channel.send(sentence)
|
||||
|
||||
|
||||
@tasks.loop(seconds=1.5)
|
||||
async def play_next(self):
|
||||
if self.sounds:
|
||||
audio_file,ctx = self.sounds[0]
|
||||
source = discord.PCMVolumeTransformer(discord.FFmpegPCMAudio(audio_file))
|
||||
if not ctx.voice_client.is_playing() and ctx.voice_client.is_connected():
|
||||
ctx.voice_client.play(source, after=lambda e: print('Player error: %s' % e) if e else None)
|
||||
self.sounds.pop(0)
|
||||
self.sounds_history.reverse()
|
||||
self.sounds_history.append((audio_file,ctx))
|
||||
self.sounds_history.reverse()
|
||||
if len(self.sounds_history) >5:
|
||||
self.sounds_history = self.sounds_history[:5]
|
||||
|
||||
@commands.command(help= "randomsur l'avenir des gens.")
|
||||
async def avenir(self, ctx):
|
||||
|
||||
list_mot = ("tu seras curé, tu t'occuperas plus spécialement du catéchisme. ",
|
||||
"tu seras animateur de soirées pour les gays pride. ",
|
||||
"tu seras gynecologue dans une maison de retraite.",
|
||||
"tu iras vivre en thaïland à cause de ton job. car tu seras ladyboy dans un bar.",
|
||||
"tu sera DSI chez jacky et Michel",
|
||||
"tu seras arroseur de plante aquatique.")
|
||||
choix = random.choice(list_mot)
|
||||
@commands.command(help='slap this ass')
|
||||
async def slap(self, ctx, user=None):
|
||||
slap_multiple = [
|
||||
"%s prend un coup de pied au cul",
|
||||
"Descente du coude sur %s",
|
||||
"%s est propulsé par dessus la TROISIEME CORDE!",
|
||||
"Le mec en rose, c'est moi et le mec en jaune c'est %s! https://giphy.com/gifs/gSIz6gGLhguOY",
|
||||
]
|
||||
if not user or not ctx.message.mentions:
|
||||
online_members = []
|
||||
members = ctx.guild.members
|
||||
for member in members:
|
||||
if str(member.status) == "online":
|
||||
online_members.append(member)
|
||||
user = random.choice(online_members)
|
||||
user = user.mention
|
||||
elif ctx.message.mentions:
|
||||
user = ctx.message.mentions[0]
|
||||
user = user.mention
|
||||
if user == self.bot.user.mention:
|
||||
with ctx.channel.typing():
|
||||
await asyncio.sleep(len(choix)/4)
|
||||
await ctx.channel.send(choix)
|
||||
|
||||
|
||||
await asyncio.sleep(0.5)
|
||||
await ctx.channel.send("je tribuche par terre et je sais pas comment")
|
||||
else:
|
||||
with ctx.channel.typing():
|
||||
await asyncio.sleep(len(slap_multiple) / 4)
|
||||
await ctx.channel.send(random.choice(slap_multiple) % user)
|
||||
|
||||
@commands.command()
|
||||
async def welcome(self, ctx):
|
||||
# if ctx.message.author.name == self.bot.user.name:
|
||||
# return
|
||||
user = ctx.message.author.name
|
||||
print(user)
|
||||
try:
|
||||
audio_file = random.choice([f for f in os.listdir(here + '/Audio/%s/' % user) if f.endswith('.mp3')])
|
||||
audio_file = here + '/Audio/%s/' % user + audio_file
|
||||
except:
|
||||
audio_file = random.choice([f for f in Path(here + '/Audio/').glob('**/*.mp3')])
|
||||
self.sounds.append((audio_file, ctx))
|
||||
|
||||
def get_word(word_type):
|
||||
"""Chercher les mots pour la fonction kamoulox dans le fichier xml"""
|
||||
content = []
|
||||
with open(here + "/ressources/base_kml.xml", "r", encoding="ISO-8859-1") as file:
|
||||
content = file.readlines()
|
||||
|
@ -398,6 +397,7 @@ def get_word(word_type):
|
|||
result = 'Nique bien ta mère!'
|
||||
return result
|
||||
|
||||
#Le do[main]e du bot.
|
||||
def main():
|
||||
token = "NjI3MTM3NDY1MDA5ODMxOTQ2.XY4Raw.pw8sAen3bNR5aYsoTChQOudM0L8"
|
||||
bot = commands.Bot(command_prefix='!')
|
||||
|
@ -406,23 +406,6 @@ def main():
|
|||
if "test" in argv[-1]:
|
||||
test=True
|
||||
|
||||
@bot.event
|
||||
async def on_ready():
|
||||
print('yeah baby!')
|
||||
if test:
|
||||
await bot.logout()
|
||||
for channel in bot.get_all_channels():
|
||||
if channel.name == "général":
|
||||
current_chan = channel
|
||||
await current_chan.send('Le troll est dans la place !')
|
||||
ctx = await bot.get_context(current_chan.last_message)
|
||||
join = bot.get_command('join')
|
||||
await join.invoke(ctx)
|
||||
for channel in bot.get_all_channels():
|
||||
if channel.name == "Général":
|
||||
for member in channel.members:
|
||||
await member.edit(mute=False)
|
||||
|
||||
@aiocron.crontab('50 9-23/1 * * *')
|
||||
async def kron():
|
||||
kron_choice = random.choice(["kaamelott", "slap", "kamoulox", False, False, False])
|
||||
|
@ -437,21 +420,6 @@ def main():
|
|||
random_cmd = bot.get_command(kron_choice)
|
||||
await random_cmd.invoke(ctx)
|
||||
|
||||
@aiocron.crontab('*/5 * * * *')
|
||||
async def pipelette():
|
||||
for channel in bot.get_all_channels():
|
||||
if channel.name == "Général" and\
|
||||
len(channel.members) > 1 and\
|
||||
random.choice([True,True,True]):
|
||||
for channel in bot.get_all_channels():
|
||||
if channel.name == "général":
|
||||
current_chan = channel
|
||||
await asyncio.sleep(random.choice(range(350)))
|
||||
ctx = await bot.get_context(current_chan.last_message)
|
||||
ctx.message.content = ""
|
||||
joke = bot.get_command('joke')
|
||||
await joke.invoke(ctx)
|
||||
|
||||
@bot.event
|
||||
async def on_message(message):
|
||||
print(message.content)
|
||||
|
@ -476,6 +444,23 @@ def main():
|
|||
await message.channel.send(response)
|
||||
await bot.process_commands(message)
|
||||
|
||||
@bot.event
|
||||
async def on_ready():
|
||||
print('yeah baby!')
|
||||
if test:
|
||||
await bot.logout()
|
||||
for channel in bot.get_all_channels():
|
||||
if channel.name == "général":
|
||||
current_chan = channel
|
||||
await current_chan.send('Le troll est dans la place !')
|
||||
ctx = await bot.get_context(current_chan.last_message)
|
||||
join = bot.get_command('join')
|
||||
await join.invoke(ctx)
|
||||
for channel in bot.get_all_channels():
|
||||
if channel.name == "Général":
|
||||
for member in channel.members:
|
||||
await member.edit(mute=False)
|
||||
|
||||
@bot.event
|
||||
async def on_voice_state_update(member, before, after):
|
||||
if before.channel is None and after.channel:
|
||||
|
@ -488,6 +473,21 @@ def main():
|
|||
await asyncio.sleep(2)
|
||||
await welcome.invoke(ctx)
|
||||
|
||||
@aiocron.crontab('*/5 * * * *')
|
||||
async def pipelette():
|
||||
for channel in bot.get_all_channels():
|
||||
if channel.name == "Général" and\
|
||||
len(channel.members) > 1 and\
|
||||
random.choice([True,True,True]):
|
||||
for channel in bot.get_all_channels():
|
||||
if channel.name == "général":
|
||||
current_chan = channel
|
||||
await asyncio.sleep(random.choice(range(350)))
|
||||
ctx = await bot.get_context(current_chan.last_message)
|
||||
ctx.message.content = ""
|
||||
joke = bot.get_command('joke')
|
||||
await joke.invoke(ctx)
|
||||
|
||||
bot.add_cog(Mybot(bot))
|
||||
bot.run(token)
|
||||
|
||||
|
|
Loading…
Reference in a new issue