add text & voice channle in config file
This commit is contained in:
parent
e790569a27
commit
4999c52437
2 changed files with 24 additions and 8 deletions
|
@ -1,6 +1,8 @@
|
||||||
[DEFAULT]
|
[DEFAULT]
|
||||||
|
|
||||||
audio_path = /tmp/
|
audio_path = /tmp/
|
||||||
|
voice_channel = channel_name
|
||||||
|
text_channel = channel_name
|
||||||
|
|
||||||
[discord]
|
[discord]
|
||||||
token = <discord_token>
|
token = <discord_token>
|
||||||
|
|
|
@ -56,11 +56,15 @@ class Mybot(commands.Cog):
|
||||||
gif_token=None,
|
gif_token=None,
|
||||||
audio_path=None,
|
audio_path=None,
|
||||||
nickname=None,
|
nickname=None,
|
||||||
|
voice_channel=None,
|
||||||
|
text_channel=None,
|
||||||
):
|
):
|
||||||
self.gl_url = gl_url
|
self.gl_url = gl_url
|
||||||
self.audio_path = audio_path
|
self.audio_path = audio_path
|
||||||
self.gl_token = gl_token
|
self.gl_token = gl_token
|
||||||
self.gif_token = gif_token
|
self.gif_token = gif_token
|
||||||
|
self.voice_channel = voice_channel
|
||||||
|
self.text_channel = text_channel
|
||||||
self.bot = bot
|
self.bot = bot
|
||||||
self.sounds = []
|
self.sounds = []
|
||||||
self.nickname = nickname
|
self.nickname = nickname
|
||||||
|
@ -148,7 +152,7 @@ class Mybot(commands.Cog):
|
||||||
|
|
||||||
@commands.command()
|
@commands.command()
|
||||||
async def join(self, ctx):
|
async def join(self, ctx):
|
||||||
channel = [x for x in self.bot.get_all_channels() if x.name == "Général"][0]
|
channel = [x for x in self.bot.get_all_channels() if x.name == self.voice_channel][0]
|
||||||
await channel.connect()
|
await channel.connect()
|
||||||
await asyncio.sleep(2)
|
await asyncio.sleep(2)
|
||||||
|
|
||||||
|
@ -387,7 +391,7 @@ class Mybot(commands.Cog):
|
||||||
@commands.command(help="Faire dire des choses au bot")
|
@commands.command(help="Faire dire des choses au bot")
|
||||||
async def say(self, ctx, *message):
|
async def say(self, ctx, *message):
|
||||||
sentence = ' '.join(message)
|
sentence = ' '.join(message)
|
||||||
channel = [x for x in self.bot.get_all_channels() if x.name == "général"][0]
|
channel = [x for x in self.bot.get_all_channels() if x.name == self.text_channel][0]
|
||||||
guild = self.bot.guilds[0]
|
guild = self.bot.guilds[0]
|
||||||
if sentence.startswith('!'):
|
if sentence.startswith('!'):
|
||||||
command_name = sentence.split()[0].replace('!', '')
|
command_name = sentence.split()[0].replace('!', '')
|
||||||
|
@ -567,6 +571,14 @@ def main():
|
||||||
nickname = config['DEFAULT']['nickname']
|
nickname = config['DEFAULT']['nickname']
|
||||||
else:
|
else:
|
||||||
nickname = None
|
nickname = None
|
||||||
|
if "voice_channel" in config['DEFAULT']:
|
||||||
|
voice_channel = config['DEFAULT']['voice_channel']
|
||||||
|
else:
|
||||||
|
voice_channel = None
|
||||||
|
if "text_channel" in config['DEFAULT']:
|
||||||
|
text_channel = config['DEFAULT']['text_channel']
|
||||||
|
else:
|
||||||
|
text_channel = None
|
||||||
audio_path = config['DEFAULT']['audio_path']
|
audio_path = config['DEFAULT']['audio_path']
|
||||||
token = config['discord']['token']
|
token = config['discord']['token']
|
||||||
gl_url = config['gitlab']['url']
|
gl_url = config['gitlab']['url']
|
||||||
|
@ -586,7 +598,7 @@ def main():
|
||||||
if kron_choice:
|
if kron_choice:
|
||||||
await asyncio.sleep(random.choice(range(3550)))
|
await asyncio.sleep(random.choice(range(3550)))
|
||||||
for channel in bot.get_all_channels():
|
for channel in bot.get_all_channels():
|
||||||
if channel.name == "général":
|
if channel.name == text_channel:
|
||||||
current_chan = channel
|
current_chan = channel
|
||||||
ctx = await bot.get_context(current_chan.last_message)
|
ctx = await bot.get_context(current_chan.last_message)
|
||||||
ctx.message.content = ""
|
ctx.message.content = ""
|
||||||
|
@ -629,7 +641,7 @@ def main():
|
||||||
if test:
|
if test:
|
||||||
await bot.close()
|
await bot.close()
|
||||||
for channel in bot.get_all_channels():
|
for channel in bot.get_all_channels():
|
||||||
if channel.name == "général":
|
if channel.name == text_channel:
|
||||||
current_chan = channel
|
current_chan = channel
|
||||||
if nickname:
|
if nickname:
|
||||||
await bot.user.edit(nick=nickname)
|
await bot.user.edit(nick=nickname)
|
||||||
|
@ -638,7 +650,7 @@ def main():
|
||||||
join = bot.get_command('join')
|
join = bot.get_command('join')
|
||||||
await join.invoke(ctx)
|
await join.invoke(ctx)
|
||||||
for channel in bot.get_all_channels():
|
for channel in bot.get_all_channels():
|
||||||
if channel.name == "Général":
|
if channel.name == voice_channel:
|
||||||
for member in channel.members:
|
for member in channel.members:
|
||||||
await member.edit(mute=False)
|
await member.edit(mute=False)
|
||||||
|
|
||||||
|
@ -646,7 +658,7 @@ def main():
|
||||||
async def on_voice_state_update(member, before, after):
|
async def on_voice_state_update(member, before, after):
|
||||||
if before.channel is None and after.channel:
|
if before.channel is None and after.channel:
|
||||||
for channel in bot.get_all_channels():
|
for channel in bot.get_all_channels():
|
||||||
if channel.name == "général":
|
if channel.name == text_channel:
|
||||||
current_chan = channel
|
current_chan = channel
|
||||||
ctx = await bot.get_context(current_chan.last_message)
|
ctx = await bot.get_context(current_chan.last_message)
|
||||||
ctx.message.author = member
|
ctx.message.author = member
|
||||||
|
@ -657,11 +669,11 @@ def main():
|
||||||
@aiocron.crontab('*/5 * * * *')
|
@aiocron.crontab('*/5 * * * *')
|
||||||
async def pipelette():
|
async def pipelette():
|
||||||
for channel in bot.get_all_channels():
|
for channel in bot.get_all_channels():
|
||||||
if channel.name == "Général" and\
|
if channel.name == voice_channel and\
|
||||||
len(channel.members) > 1 and\
|
len(channel.members) > 1 and\
|
||||||
random.choice([True,True,True]):
|
random.choice([True,True,True]):
|
||||||
for channel in bot.get_all_channels():
|
for channel in bot.get_all_channels():
|
||||||
if channel.name == "général":
|
if channel.name == text_channel:
|
||||||
current_chan = channel
|
current_chan = channel
|
||||||
await asyncio.sleep(random.choice(range(350)))
|
await asyncio.sleep(random.choice(range(350)))
|
||||||
ctx = await bot.get_context(current_chan.last_message)
|
ctx = await bot.get_context(current_chan.last_message)
|
||||||
|
@ -677,6 +689,8 @@ def main():
|
||||||
gif_token=gif_token,
|
gif_token=gif_token,
|
||||||
audio_path=audio_path,
|
audio_path=audio_path,
|
||||||
nickname=nickname,
|
nickname=nickname,
|
||||||
|
voice_channel=voice_channel,
|
||||||
|
text_channel=text_channel,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
bot.run(token)
|
bot.run(token)
|
||||||
|
|
Loading…
Reference in a new issue