fix command and messages and add quotes functions
This commit is contained in:
parent
3c24bf434e
commit
c62385f79b
2 changed files with 40 additions and 16 deletions
BIN
Benjamin_Prejent.mp3
Normal file
BIN
Benjamin_Prejent.mp3
Normal file
Binary file not shown.
|
@ -6,6 +6,8 @@ import random
|
||||||
import discord
|
import discord
|
||||||
from discord.ext import commands
|
from discord.ext import commands
|
||||||
|
|
||||||
|
import os
|
||||||
|
|
||||||
def quotes():
|
def quotes():
|
||||||
quotes = [
|
quotes = [
|
||||||
"Pour savoir s’y a du vent, il faut mettre son doigt dans le cul du coq.",
|
"Pour savoir s’y a du vent, il faut mettre son doigt dans le cul du coq.",
|
||||||
|
@ -20,18 +22,18 @@ def quotes():
|
||||||
response = random.choice(quotes)
|
response = random.choice(quotes)
|
||||||
return response
|
return response
|
||||||
|
|
||||||
def main():
|
class Mybot(discord.Client):
|
||||||
client = discord.Client()
|
|
||||||
token = "NjI3MTM3NDY1MDA5ODMxOTQ2.XY4Raw.pw8sAen3bNR5aYsoTChQOudM0L8"
|
|
||||||
|
|
||||||
bot = commands.Bot(command_prefix='!')
|
bot = commands.Bot(command_prefix='!')
|
||||||
|
|
||||||
@bot.command(name='ping', help='Responds with a random quote')
|
async def join(ctx):
|
||||||
async def ping(ctx):
|
author = message.author
|
||||||
await ctx.send('pong')
|
channel = author.voice_channel
|
||||||
|
await self.join_voice_channel(channel)
|
||||||
|
|
||||||
@bot.command(name='test', help='Responds with a random quote')
|
async def ping(self, message):
|
||||||
async def nine_nine(ctx):
|
await message.channel.send('pong')
|
||||||
|
|
||||||
|
async def test(self, message):
|
||||||
quotes = [
|
quotes = [
|
||||||
"Pour savoir s’y a du vent, il faut mettre son doigt dans le cul du coq.",
|
"Pour savoir s’y a du vent, il faut mettre son doigt dans le cul du coq.",
|
||||||
"Y'a des méchants ?",
|
"Y'a des méchants ?",
|
||||||
|
@ -43,17 +45,39 @@ def main():
|
||||||
]
|
]
|
||||||
|
|
||||||
response = random.choice(quotes)
|
response = random.choice(quotes)
|
||||||
await ctx.send(response)
|
await message.channel.send(response)
|
||||||
|
|
||||||
@bot.event
|
|
||||||
async def on_message(message):
|
async def on_message(self, message):
|
||||||
print(message.content)
|
print(message.content)
|
||||||
if message.author == bot.user:
|
if message.author == self.user:
|
||||||
return
|
return
|
||||||
|
if message.content.startswith('!') and not message.content.startswith('!on_'):
|
||||||
|
try:
|
||||||
|
print('self.' + message.content[1:] + '(message)')
|
||||||
|
await eval('self.' + message.content[1:] + '(message)')
|
||||||
|
except:
|
||||||
|
await message.channel.send("%s ? Ouais, c'est pas faux !" % message.content[1:])
|
||||||
if message.content == 'pwet':
|
if message.content == 'pwet':
|
||||||
await message.channel.send('pong')
|
await message.channel.send('pong')
|
||||||
elif 'ben' in str(message.author):
|
else:
|
||||||
await message.channel.send(quotes())
|
if self.user in message.mentions and len(message.mentions) < 3:
|
||||||
|
path = '/tmp/%s.log' % message.channel
|
||||||
|
with open(path, 'a') as f :
|
||||||
|
f.write(message.content + '\n')
|
||||||
|
with open(path, 'r') as f :
|
||||||
|
lines = f.read().splitlines()
|
||||||
|
response = random.choice(lines).replace(str(self.user.id), str(message.author.id))
|
||||||
|
await message.channel.send(response)
|
||||||
|
|
||||||
|
return
|
||||||
|
|
||||||
|
def main():
|
||||||
|
token = "NjI3MTM3NDY1MDA5ODMxOTQ2.XY4Raw.pw8sAen3bNR5aYsoTChQOudM0L8"
|
||||||
|
client = Mybot()
|
||||||
|
client.run(token)
|
||||||
|
|
||||||
|
|
||||||
bot.run(token)
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue