autostop now supports pause/stop
This commit is contained in:
parent
3a906ea183
commit
b6ea3c5bff
@ -98,8 +98,10 @@ port = 64738
|
|||||||
#ducking_volume = 0.05
|
#ducking_volume = 0.05
|
||||||
#ducking_threshold = 3000
|
#ducking_threshold = 3000
|
||||||
|
|
||||||
# 'auto_stop': If a user leaves and the bot is left alone, stop and clear the playlist
|
# 'when_nobody_in_channel': should the music stop playing when everybody left the channel
|
||||||
#auto_stop = False
|
# it should be one of "pause" (pause current song), "stop" (also clears playlist) or "nothing" (keep playing music)
|
||||||
|
# If a user leaves and the bot is left alone, stop and clear the playlist
|
||||||
|
#when_nobody_in_channel = nothing
|
||||||
|
|
||||||
# [webinterface] stores settings related to the web interface.
|
# [webinterface] stores settings related to the web interface.
|
||||||
[webinterface]
|
[webinterface]
|
||||||
|
17
mumbleBot.py
17
mumbleBot.py
@ -149,10 +149,13 @@ class MumbleBot:
|
|||||||
self.ducking_sound_received)
|
self.ducking_sound_received)
|
||||||
self.mumble.set_receive_sound(True)
|
self.mumble.set_receive_sound(True)
|
||||||
|
|
||||||
if not var.db.has_option("bot", "auto_stop") and var.config.getboolean("bot", "auto_stop", fallback=False)\
|
if var.config.get("bot", "when_nobody_in_channel") in ['pause', 'stop', 'nothing']:
|
||||||
or var.config.getboolean("bot", "auto_stop"):
|
self.log.warn('Config "when_nobody_in_channel" is not on of "pause", "stop" or "nothing", falling back to "nothing".')
|
||||||
|
|
||||||
|
if var.config.get("bot", "when_nobody_in_channel", fallback='nothing') in ['pause', 'stop']:
|
||||||
self.mumble.callbacks.set_callback(pymumble.constants.PYMUMBLE_CLBK_USERREMOVED, self.users_changed)
|
self.mumble.callbacks.set_callback(pymumble.constants.PYMUMBLE_CLBK_USERREMOVED, self.users_changed)
|
||||||
self.mumble.callbacks.set_callback(pymumble.constants.PYMUMBLE_CLBK_USERUPDATED, self.users_changed)
|
self.mumble.callbacks.set_callback(pymumble.constants.PYMUMBLE_CLBK_USERUPDATED, self.users_changed)
|
||||||
|
|
||||||
# Debug use
|
# Debug use
|
||||||
self._loop_status = 'Idle'
|
self._loop_status = 'Idle'
|
||||||
self._display_rms = False
|
self._display_rms = False
|
||||||
@ -324,9 +327,15 @@ class MumbleBot:
|
|||||||
|
|
||||||
def users_changed(self, user, message):
|
def users_changed(self, user, message):
|
||||||
own_channel = self.mumble.channels[self.mumble.users.myself['channel_id']]
|
own_channel = self.mumble.channels[self.mumble.users.myself['channel_id']]
|
||||||
|
if len(own_channel.get_users()) > 1:
|
||||||
|
return
|
||||||
|
|
||||||
# if the bot is the only user left in the channel
|
# if the bot is the only user left in the channel
|
||||||
if len(own_channel.get_users()) == 1:
|
self.log.info('bot: Other users in the channel left. Stopping music now.')
|
||||||
self.log.info('Other users in the channel left. Stopping music now.')
|
|
||||||
|
if var.config.get("bot", "when_nobody_in_channel") == "pause":
|
||||||
|
self.pause()
|
||||||
|
else:
|
||||||
self.clear()
|
self.clear()
|
||||||
|
|
||||||
# =======================
|
# =======================
|
||||||
|
Loading…
x
Reference in New Issue
Block a user