reply on commands only on the predefined text channel
This commit is contained in:
parent
0e93dd745c
commit
2feffba344
10
main.py
10
main.py
|
@ -46,24 +46,28 @@ async def on_message(message):
|
||||||
if message.author == bot.user:
|
if message.author == bot.user:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
if not str(message.channel.id) == text_channel_id:
|
||||||
|
return
|
||||||
|
|
||||||
print('<' + message.author.nick + '> ' + message.content)
|
print('<' + message.author.nick + '> ' + message.content)
|
||||||
|
|
||||||
if message.content == '!version':
|
if message.content == '!version':
|
||||||
await message.channel.send('] radiobot ' + bot_version + ' - python: ' + os.environ['PYTHON_VERSION'])
|
await message.channel.send('] radiobot ' + bot_version + ' - python ' + os.environ['PYTHON_VERSION'])
|
||||||
|
|
||||||
@bot.event
|
@bot.event
|
||||||
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 is not None:
|
print("User connected to " + str(after.channel.id))
|
||||||
if after.channel.id == [voice_channel_id]:
|
if after.channel.id == [voice_channel_id]:
|
||||||
clients_before = len(before.channel.members)
|
clients_before = len(before.channel.members)
|
||||||
|
|
||||||
# If nobody in the channel based on before, invoke join the channel
|
# If nobody in the channel based on before, invoke join the channel
|
||||||
if clients_before == 0:
|
if clients_before == 0:
|
||||||
|
print("Connecting to voice channel " + voice_channel_id)
|
||||||
voiceChannel = await after.channel.connect()
|
voiceChannel = await after.channel.connect()
|
||||||
|
|
||||||
# if channel members > 0, leave the channel
|
# if channel members > 0, leave the channel
|
||||||
if clients_before == 1:
|
if clients_before == 1:
|
||||||
print("gg")
|
print("Disconnecting from voice channel " + voice_channel_id)
|
||||||
await voiceChannel.disconnect()
|
await voiceChannel.disconnect()
|
||||||
|
|
||||||
# Start the bot with multiprocess compatiblity
|
# Start the bot with multiprocess compatiblity
|
||||||
|
|
Loading…
Reference in a new issue