Kamoulox 2.0

This commit is contained in:
BFlow 2020-04-10 16:53:48 +02:00
parent 009e6d91cd
commit 79f4f81ff8

View file

@ -10,6 +10,7 @@ import aiocron
import asyncio
import giphy_client
import gitlab
import lxml
from time import sleep
from discord.ext import tasks, commands
@ -17,6 +18,7 @@ from subprocess import *
from sys import argv
from pathlib import Path
from giphy_client.rest import ApiException
from bs4 import BeautifulSoup as bs
class Mybot(commands.Cog):
def __init__(self, bot):
@ -193,9 +195,24 @@ class Mybot(commands.Cog):
@commands.command(help="Je menotte une cornemuse et je fume Eddy Malou")
async def kamoulox(self, ctx):
kamoulox_request = requests.get('https://kmlproject.com/Launcher/LKamoulox.php')
kamoulox_sentence = kamoulox_request.content.decode('utf-8')
await ctx.send(kamoulox_sentence)
sans_verbe = get_word('nom').text + " " + get_word('complement').get('m') + " et " + get_word('nom').text + " " + get_word('complement').get('m') + "."
nom1 = get_word('nom')
nom2 = get_word('nom')
un1 = "un"
un2 = "un"
if nom1.get('gender') == 'F':
un1 = "une"
if nom2.get('gender') == 'F':
un2 = "une"
phrase1 = get_word('verbe').text + " " + un1 + " " + nom1.text + " " + random.choice([get_word('complement').get('m'), ""])
phrase2 = get_word('verbe').text + " " + un2 + " " + nom2.text + " " + random.choice([get_word('complement').get('m'), ""])
avec_verbe = phrase1 + " et " + phrase2 + "."
piece = random.choice(['pile', 'face'])
if piece == "pile":
sans_verbe
elif piece == "face":
avec_verbe
await ctx.send(piece)
@tasks.loop(seconds=1.5)
async def play_next(self):
@ -211,6 +228,67 @@ class Mybot(commands.Cog):
if len(self.sounds_history) >5:
self.sounds_history = self.sounds_history[:5]
def get_word(word_type):
content = []
with open("base_kml.xml", "r") as file:
content = file.readlines()
content = "".join(content)
bs_content = bs(content, 'lxml')
if word_type == 'nom':
nom = bs_content.resources.nom.find_all('word')
result = random.choice(nom)
return result
elif word_type == 'nom_propre':
nom_propre = bs_content.resources.nompropre.find_all('word')
result = random.choice(nom_propre)
return result
elif word_type == 'verbe':
verbe = bs_content.resources.verbe.find_all('word')
result = random.choice(verbe)
return result
elif word_type == 'complement':
complement = bs_content.resources.complement.find_all('word')
result = random.choice(complement)
return result
elif word_type == 'nom_special':
nom_special = bs_content.resources.complement.find_all('word')
result = random.choice(nom_special)
return result
elif word_type == 'prenom':
prenom = bs_content.resources.prenom.find_all('word')
result = random.choice(prenom)
return result
elif word_type == 'prescuse':
prescuse = bs_content.resources.prescuse.find_all('word')
result = random.choice(prescuse)
return result
elif word_type == 'scuse1':
scuse1 = bs_content.resources.scuse1.find_all('word')
result = random.choice(scuse1)
return result
elif word_type == 'scuse2':
scuse2 = bs_content.resources.scuse2.find_all('word')
result = random.choice(scuse2)
return result
elif word_type == 'presulte':
presulte = bs_content.resources.presulte.find_all('word')
result = random.choice(presulte)
return result
elif word_type == 'sulte':
sulte = bs_content.resources.sulte.find_all('word')
result = random.choice(sulte)
return result
elif word_type == 'postsulte':
postsulte = bs_content.resources.presulte.find_all('word')
result = random.choice(postsulte)
return result
elif word_type == 'mail':
mail = bs_content.resources.mail.find_all('word')
result = random.choice(mail)
return result
else:
result = 'Nique bien ta mère!'
return result
def main():
token = "NjI3MTM3NDY1MDA5ODMxOTQ2.XY4Raw.pw8sAen3bNR5aYsoTChQOudM0L8"