1
0
mirror of https://github.com/azlux/botamusique synced 2024-11-23 13:56:17 +00:00

Compare commits

...

4 Commits

Author SHA1 Message Date
Terry Geng
02abdd6389
Merge pull request #300 from azlux/ci
fix(CI): OpenSSL problem in Node v17. Switch back to v16.
2021-12-02 09:16:26 -05:00
Terry Geng
6005897276 fix(CI): OpenSSL problem in Node v17. Switch back to v16. 2021-12-02 09:13:37 -05:00
Terry Geng
7a5e4938a7
Merge pull request #299 from azlux/pause
fix: Music wrongly started if two people left in channel.
2021-12-02 09:10:05 -05:00
Terry Geng
3e1f810b0e fix: Music wrongly started if two people left in channel.
Fix #298
2021-12-02 08:31:56 -05:00
2 changed files with 16 additions and 8 deletions

View File

@ -9,7 +9,7 @@ volumes:
steps:
- name: build-web
image: node
image: node:16
commands:
- (cd web && npm install && npm run build)
when:

View File

@ -131,6 +131,8 @@ class MumbleBot:
self.join_channel()
self.mumble.set_bandwidth(self.bandwidth)
self._user_in_channel = self.get_user_count_in_channel()
# ====== Volume ======
self.volume_helper = util.VolumeHelper()
@ -351,28 +353,34 @@ class MumbleBot:
return False
# =======================
# Users changed
# Other Mumble Events
# =======================
def users_changed(self, user, message):
def get_user_count_in_channel(self):
own_channel = self.mumble.channels[self.mumble.users.myself['channel_id']]
return len(own_channel.get_users())
def users_changed(self, user, message):
# only check if there is one more user currently in the channel
# else when the music is paused and somebody joins, music would start playing again
if len(own_channel.get_users()) == 2:
user_count = self.get_user_count_in_channel()
if user_count > self._user_in_channel and user_count == 2:
if var.config.get("bot", "when_nobody_in_channel") == "pause_resume":
self.resume()
elif var.config.get("bot", "when_nobody_in_channel") == "pause" and self.is_pause:
self.send_channel_msg(tr("auto_paused"))
elif len(own_channel.get_users()) == 1 and len(var.playlist) != 0:
elif user_count == 1 and len(var.playlist) != 0:
# if the bot is the only user left in the channel and the playlist isn't empty
self.log.info('bot: Other users in the channel left. Stopping music now.')
if var.config.get("bot", "when_nobody_in_channel") == "stop":
self.log.info('bot: No user in my channel. Stop music now.')
self.clear()
else:
self.log.info('bot: No user in my channel. Pause music now.')
self.pause()
self._user_in_channel = user_count
# =======================
# Launch and Download
# =======================