feat: remove item once played in one-shot mode. make it as close to the old version as possible, #79

This commit is contained in:
Terry Geng 2020-02-27 00:59:09 +08:00
parent 45f6923534
commit a03f82d90a
3 changed files with 8 additions and 4 deletions

View File

@ -199,8 +199,8 @@ help = <h3>Commands</h3>
<li> <b>!<u>st</u>op </b> - stop playing </li>
<li> <b>!<u>sk</u>ip </b> - jump to the next song </li>
<li> <b>!<u>v</u>olume </b> {volume} - get or change the volume (from 0 to 100) </li>
<li> <b>!<u>m</u>ode </b> [{mode}] - get or set the playback mode, {mode} should be one of <i>one-shot</i> (play the playlist
once), <i>repeat</i> (looping through the playlist), <i>random</i> (randomize the playlist)</li>
<li> <b>!<u>m</u>ode </b> [{mode}] - get or set the playback mode, {mode} should be one of <i>one-shot</i> (remove
item once played), <i>repeat</i> (looping through the playlist), <i>random</i> (randomize the playlist)</li>
<li> <b>!duck </b> on/off - enable or disable ducking function </li>
<li> <b>!duckv </b> - set the volume of the bot when ducking is activated </li>
<li> <b>!<u>duckt</u>hres </b> - set the threshold of volume to activate ducking (3000 by default) </li>

View File

@ -29,7 +29,7 @@ port = 64738
#volume = 0.1
# 'playback_mode' defined the playback mode of the bot.
# it should be one of "one-shot" (play the playlist once), "repeat" (looping through the playlist),
# it should be one of "one-shot" (remove item once played), "repeat" (looping through the playlist),
# or "random" (randomize the playlist).
# This option will be overridden by value in the database.
#playback_mode = one-shot

View File

@ -59,7 +59,11 @@ class PlayList(list):
logging.debug("playlist: Next into the queue")
if self.current_index < len(self) - 1:
self.current_index += 1
if self.mode == "one-shot":
super().__delitem__(self.current_index)
else:
self.current_index += 1
return self[self.current_index]
else:
self.current_index = 0