Add bots option to exclude other bot users from autoplay logic (#301)
* Add bots option to exclude other bot users from autoplay logic * Refactor get_user_count_in_channel to make it more readable * Remove commandline option and rename config key for "bots" * Remove --bots from argparse * Correct when_nobody_in_channel_ignore config read typo * Fix when_nobody_in_channel_ignore configuration read order
This commit is contained in:
@ -65,6 +65,7 @@ tmp_folder_max_size = 10
|
|||||||
username = botamusique
|
username = botamusique
|
||||||
volume = 0.8
|
volume = 0.8
|
||||||
when_nobody_in_channel = nothing
|
when_nobody_in_channel = nothing
|
||||||
|
when_nobody_in_channel_ignore =
|
||||||
|
|
||||||
[webinterface]
|
[webinterface]
|
||||||
access_address = http://127.0.0.1:8181
|
access_address = http://127.0.0.1:8181
|
||||||
|
@ -134,6 +134,10 @@ port = 64738
|
|||||||
# - leave empty (do nothing)
|
# - leave empty (do nothing)
|
||||||
#when_nobody_in_channel =
|
#when_nobody_in_channel =
|
||||||
|
|
||||||
|
# 'when_nobody_in_channel_ignore': Specify the list of users that should be ignored, from the list of active users.
|
||||||
|
# This is typically used when other bots are present in the channel.
|
||||||
|
#when_nobody_in_channel_ignore =
|
||||||
|
|
||||||
# 'youtube_query_cookie': Sometimes youtube will block the request of our bot and
|
# 'youtube_query_cookie': Sometimes youtube will block the request of our bot and
|
||||||
# request the bot to complete a captcha to verify the request is not made by a
|
# request the bot to complete a captcha to verify the request is not made by a
|
||||||
# bot.
|
# bot.
|
||||||
|
16
mumbleBot.py
16
mumbleBot.py
@ -103,6 +103,7 @@ class MumbleBot:
|
|||||||
tokens = var.config.get("server", "tokens")
|
tokens = var.config.get("server", "tokens")
|
||||||
tokens = tokens.split(',')
|
tokens = tokens.split(',')
|
||||||
|
|
||||||
|
|
||||||
if args.user:
|
if args.user:
|
||||||
self.username = args.user
|
self.username = args.user
|
||||||
else:
|
else:
|
||||||
@ -132,8 +133,11 @@ class MumbleBot:
|
|||||||
self.join_channel()
|
self.join_channel()
|
||||||
self.mumble.set_bandwidth(self.bandwidth)
|
self.mumble.set_bandwidth(self.bandwidth)
|
||||||
|
|
||||||
|
bots = var.config.get("bot", "when_nobody_in_channel_ignore",fallback="")
|
||||||
|
self.bots = set(bots.split(','))
|
||||||
self._user_in_channel = self.get_user_count_in_channel()
|
self._user_in_channel = self.get_user_count_in_channel()
|
||||||
|
|
||||||
|
|
||||||
# ====== Volume ======
|
# ====== Volume ======
|
||||||
self.volume_helper = util.VolumeHelper()
|
self.volume_helper = util.VolumeHelper()
|
||||||
|
|
||||||
@ -374,8 +378,18 @@ class MumbleBot:
|
|||||||
# =======================
|
# =======================
|
||||||
|
|
||||||
def get_user_count_in_channel(self):
|
def get_user_count_in_channel(self):
|
||||||
|
# Get the channel, based on the channel id
|
||||||
own_channel = self.mumble.channels[self.mumble.users.myself['channel_id']]
|
own_channel = self.mumble.channels[self.mumble.users.myself['channel_id']]
|
||||||
return len(own_channel.get_users())
|
|
||||||
|
# Build set of unique usernames
|
||||||
|
users = set([user.get_property("name") for user in own_channel.get_users()])
|
||||||
|
|
||||||
|
# Exclude all bots from the set of usernames
|
||||||
|
users = users.difference(self.bots)
|
||||||
|
|
||||||
|
# Return the number of elements in the set, as the final user count
|
||||||
|
return len(users)
|
||||||
|
|
||||||
|
|
||||||
def users_changed(self, user, message):
|
def users_changed(self, user, message):
|
||||||
# only check if there is one more user currently in the channel
|
# only check if there is one more user currently in the channel
|
||||||
|
Reference in New Issue
Block a user