add autojoin, restart, update && test
This commit is contained in:
parent
506de7133e
commit
a3cd80ba8e
1 changed files with 33 additions and 1 deletions
|
@ -10,6 +10,10 @@ from discord.ext import commands
|
|||
import os
|
||||
import requests
|
||||
|
||||
from subprocess import *
|
||||
|
||||
from sys import argv
|
||||
|
||||
class Mybot(commands.Cog):
|
||||
def __init__(self, bot):
|
||||
self.bot = bot
|
||||
|
@ -18,6 +22,7 @@ class Mybot(commands.Cog):
|
|||
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()
|
||||
sleep(2)
|
||||
|
||||
@commands.command()
|
||||
async def disconnect(self, ctx):
|
||||
|
@ -25,11 +30,21 @@ class Mybot(commands.Cog):
|
|||
|
||||
@commands.command()
|
||||
async def welcome(self, ctx):
|
||||
if ctx.message.author.name == self.bot.user.name:
|
||||
return
|
||||
user = ctx.message.author.name
|
||||
audio_file = random.choice([f for f in os.listdir('/home/mika/kabot/kabot/kabot/Audio/%s/' % user) if f.endswith('.mp3')])
|
||||
source = discord.PCMVolumeTransformer(discord.FFmpegPCMAudio("/home/mika/kabot/kabot/kabot/Audio/%s/%s" % (user,audio_file)))
|
||||
ctx.voice_client.play(source, after=lambda e: print('Player error: %s' % e) if e else None)
|
||||
return
|
||||
|
||||
@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='check if bot always online')
|
||||
async def ping(self, message):
|
||||
|
@ -70,6 +85,23 @@ def main():
|
|||
token = "NjI3MTM3NDY1MDA5ODMxOTQ2.XY4Raw.pw8sAen3bNR5aYsoTChQOudM0L8"
|
||||
bot = commands.Bot(command_prefix='!')
|
||||
|
||||
test = False
|
||||
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)
|
||||
|
||||
@bot.event
|
||||
async def on_message(message):
|
||||
print(message.content)
|
||||
|
|
Loading…
Reference in a new issue