Add more controls (#71)

* add more ducking command

* fix current music command

* provide more controls, like pause, resume, clear.

* add more controls in the web interface

* refactored and improved:
1. move get_music_tag_info to util, and
2. refined logic related to it.
3. now playlist will check for tag info thus update_music_tag_info is
useless and was removed
4. add "add folder" feature to !file asked in #65,
5. fix bugs related to !file

* truncate file list if too long

* fixed several tiny bugs

* fixed several tiny bugs continue

* fixed several tiny bugs continue continue

* fixed several tiny bugs continue**3

* fixed several tiny bugs continue**4

* added !filematch command to add files that match a regex pattern.

* truncate long message

* fix web interface delete file issue

* refresh after delete file

* add regex to listfile command

* refactored command part, added partial match support for commands

* organized

* added random command

* typo

* typo

* Fixed many bugs.

* Added workaround for azlux/pymumble#44 to fix the memory leak.

* changed logging style.

* fixed bugs related to random and resume

* fix now playing

* fixed issue related to download

* fixed issue related to download 2

* fixed thumbnail issue

* fixed add url problem in web interface

* REFACTORED, turned db.ini into sqlite3 database.

* fixed remove song problem

* fixed radio get title problem. auto download if tmp file is deleted

* fixed current index not loaded from database

* fixed: order of songs loaded from the database

* fixed: some obscure bugs. beautified error of commands

* added a workaround for TerryGeng/botamusique#1.

* beautified

* fixed: channel not loaded in the config

* fixed: auto checked for updates

* fixed: mysterious bug: sometimes "now playing" string cannot be properly
displayed.
The real reason is: do use <br />, do not use <br>. I tried hours to
find out this.

* chore: unified debug messages that refer to music items

* feav: fetch ffmpeg stderr mentioned in #72, reformatted logs.

* fix: async download not working

* fix: async download not working, still

* fix: async download not working, finished

* feat: queue command: ▶current playing item◀

* feat: support more than one command prefix

* chore: added some WARNINGs into default config file to avoid people to touch it.

* refactor: packed all string contants into constants.py, just to avoid people messing it around.

* refactor: required by azlux. Added a configuration.example.ini to keep people away from configuration.default.ini
This commit is contained in:
Terry Geng
2020-02-25 02:17:02 +08:00
committed by GitHub
parent 951934602e
commit 97f2326d9b
13 changed files with 1684 additions and 835 deletions

View File

@ -1,20 +1,45 @@
# ========================================================
# botamusique Default Configuration File
# Version 6
# ========================================================
# WARNING:
# ******************************
# **DO NOT MODIFIED THIS FILE.**
# ******************************
#
# Please create your own configuration file, and
# ONLY ADD ITEMS YOU WANT TO MODIFY into it. Other
# items will be loaded from this file automatically.
# DO NOT DIRECTLY COPY THIS FILE.
#
# That is because this file will be overridden
# during updates. New options will be added and
# old options (like [strings]) will be updated.
# ========================================================
[server]
host = 127.0.0.1
port = 64738
password =
channel =
tokens = # example: token1,token2
# example: token1,token2
tokens =
certificate =
[bot]
username = botamusique
comment = Hi, I'm here to play radio, local music or youtube/soundcloud music. Have fun !
comment = Hi, I'm here to play radio, local music or youtube/soundcloud music. Have fun!
# default volume from 0 to 1.
volume = 0.1
admin = User1;User2; # Allow user to kill the bot
# Users allowed to kill the bot, or ban URLs.
admin = User1;User2;
# Folder that stores your local songs.
music_folder = music_folder/
# Folder that stores the downloaded music.
tmp_folder = /tmp/
pip3_path = venv/bin/pip
auto_update = True
auto_check_update = True
logfile =
# in MB, 0 for no cache, -1 for unlimited size
@ -27,6 +52,10 @@ announce_current_music = True
allow_other_channel_message = False
allow_private_message = True
# If save_playlist is set True, the bot will save current
# playlist before quitting and reload it the next time it start.
save_playlist = True
# Maximum track played when a playlist is added.
max_track_playlist = 20
@ -39,6 +68,7 @@ ducking_volume = 0.05
ducking_threshold = 3000
[webinterface]
# Set enabled to True if you'd like to use the web interface to manage your playlist, upload files, etc.
enabled = False
is_web_proxified = True
listening_addr = 127.0.0.1
@ -47,16 +77,38 @@ listening_port = 8181
# Set this option to True to enable password protection for the web interface
require_auth = False
user =
password =
password =
[command]
#This it the char (only on letter) the bot will recognize as a command
command_symbol = !
#this option split username, in case you use such kind of mumo plugins https://wiki.mumble.info/wiki/Mumo#Set_Status
[debug]
# Set ffmpeg to True if you want to display DEBUG level log of ffmpeg.
ffmpeg = False
mumbleConnection = False
# This is a list of default radio stations.
[radio]
ponyville = http://192.99.131.205:8000/stream.mp3 "Here a command of !radio comment"
luna = http://radio.ponyvillelive.com:8002/stream "calm and orchestra music"
radiobrony = http://62.210.138.34:8000/live "Borny music of a friend"
celestiaradio = http://celestia.aiverse.org:8000/mp3_256
jazz = http://jazz-wr04.ice.infomaniak.ch/jazz-wr04-128.mp3 "Jazz Yeah !"
# ========================================================
# WARNING: WE DO NOT SUGGEST YOU MODIFY THE FOLLOWING
# PARTS, EXCEPT YOU KNOW WHAT YOU ARE DOING.
# ========================================================
[commands]
# This is a list of characters the bot recognizes as command prefix.
command_symbol = !:
# This option split username, in case you use such kind of mumo plugins https://wiki.mumble.info/wiki/Mumo#Set_Status
split_username_at_space = False
play_file = file
play_file = file, f
play_file_match = filematch, fm
play_url = url
play_radio = radio
play_playlist = playlist
@ -65,17 +117,22 @@ rb_query = rbquery
rb_play = rbplay
help = help
pause = pause
play = p, play
stop = stop
list = list
remove = rm
clear = clear
skip = skip
current_music = np
volume = v
current_music = np, now
volume = volume
kill = kill
stop_and_getout = oust
joinme = joinme
queue = queue
repeat = repeat
random = random
update = update
list_file = listfile
user_ban = userban
user_unban = userunban
@ -84,72 +141,91 @@ url_unban = urlunban
ducking = duck
ducking_threshold = duckthres
ducking_volume = duckv
#command to reload the ban list
reload = reload
[radio]
ponyville = http://192.99.131.205:8000/stream.mp3 "Here a command of !radio comment"
luna = http://radio.ponyvillelive.com:8002/stream "calm and orchestra music"
radiobrony = http://62.210.138.34:8000/live "Borny music of a friend"
celestiaradio = http://celestia.aiverse.org:8000/mp3_256
jazz = http://jazz-wr04.ice.infomaniak.ch/jazz-wr04-128.mp3 "Jazz Yeah !"
drop_database = dropdatabase
[strings]
current_volume = volume : %d%%
change_volume = volume : %d%% by %s
bad_command = Incorrect command
not_admin = You are not an admin !
not_playing = No music right now
bad_file = Bad file requested
current_volume = Current volume: {volume}
current_ducking_volume = Volume on ducking: {volume} by {user}
change_volume = Volume set to {volume} by {user}
change_ducking_volume = Volume on ducking set to {volume} by {user}
bad_command = {command}: command not found
bad_parameter = {command}: invalid parameter
error_executing_command = {command}: Command failed with error: {error}.
not_admin = You are not an admin!
not_playing = Nothing is playing right now
no_file = File not found
wrong_pattern = Invalid regex: {error}
file_added = Added: {item}
multiple_file_added = Multiple files added:
bad_url = Bad URL requested
preconfigurated_radio = Preconfigurated Radio available
unable_download = Error while downloading the music...
preconfigurated_radio = Preconfigurated Radio available:
unable_download = Error while downloading music...
which_command = Do you mean <br /> {commands}
multiple_matches = Track not found! Possible candidates:
queue_contents = The next items in the queue are:
queue_empty = No more music in the playlist!
now_playing = Now playing %s<br />%s
not_in_my_channel = You're not in my channel, command refused !
queue_contents = Items on the playlist:
queue_empty = Playlist is empty!
now_playing = Now playing {item}<br />{thumb}
not_in_my_channel = You're not in my channel, command refused!
pm_not_allowed = Private message aren't allowed.
too_long = This music is too long, skipping !
download_in_progress = Download of %s in progress
no_possible = it's not possible to do that
removing_item = Removing entry %s from queue
user_ban = You are ban, not allowed to do that !
url_ban = This url isn't allowed !
rb_query_result = This is the result of your query, send !rbplay 'ID' to play a station
rb_query_empty = You have to add a query text to search for a matching radio stations.
rb_play_empty = Please enter a station ID from rbquery. Example: !rbplay 96748
too_long = This music is too long, skip!
download_in_progress = Download of {item} in progress
removing_item = Removed entry {item} from playlist
user_ban = You are banned, not allowed to do that!
url_ban = This url is banned!
rb_query_result = This is the result of your query, send !rbplay 'ID' to play a station:
rb_play_empty = Please specify a radio station ID!
paused = Music paused.
stopped = Music stopped.
cleared = Playlist emptied.
database_dropped = Database dropped. All records have gone.
new_version_found = <h3>Update Available!</h3> New version of botamusique is available, send <i>!update</i> to update!
start_updating = Start updating...
help = Command available:
<br />!file [path]
<br />!url [url] - youtube or soundcloud
<br />!playlist [url] [offset] - youtube or soundcloud playlist (the offset is the track number the bot will start to play - 1 by default)
<br />!radio [url] - url of a stream
<br />!rbquery - Search http://www.radio-browser.info for a radio station
<br />!rbplay - Play a radio station from !rbquery search results (eg. !rbplay 96746)
<br />!list - display list of available tracks
<br />!queue - display items in queue
<br />!np - display the current music
<br />!skip - jump to the next music of the playlist (of remove the X items if you add a number)
<br />!stop - stop and clear the playlist
<br />!oust - stop + Go to default channel
<br />!v - get or change the volume (in %)
<br />!joinme - join your own channel
<br />!duck [on/off] - enable or disable ducking function
<br />!duckthres - set the threshold of volume to activate ducking (3000 by default)
help = <h3>Commands</h3>
<b>Control</b>
<ul>
<li> <b>!play </b> (or <b>!p</b>) [{num}] - resume from pausing / start to play (the num-th song is num is given) </li>
<li> <b>!<u>pa</u>use </b> - pause </li>
<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>!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>
</ul>
<b>Playlist</b>
<ul>
<li> <b>!<u>n</u>ow </b> (or <b>!np</b>) - display the current song </li>
<li> <b>!<u>q</u>ueue </b> - display items in the playlist </li>
<li> <b>!file </b>(or <b>!f</b>) {path/folder/index/keyword} - append file to the playlist by its path or index returned by !listfile </li>
<li> <b>!<u>filem</u>atch </b>(or <b>!fm</b>) {pattern} - add all files that match regex {pattern} </li>
<li> <b>!<u>ur</u>l </b> {url} - append youtube or soundcloud music to the playlist </li>
<li> <b>!<u>playl</u>ist </b> {url} [{offset}] - append items in a youtube or soundcloud playlist, and start with the {offset}-th item </li>
<li> <b>!rm </b> {num} - remove the num-th song on the playlist </li>
<li> <b>!<u>rep</u>eat </b> [{num}] - repeat current song {num} (1 by default) times.</li>
<li> <b>!<u>ran</u>dom </b> - randomize the playlist.</li>
<li> <b>!<u>rad</u>io </b> {url} - append a radio {url} to the playlist </li>
<li> <b>!<u>rbq</u>uery </b> {keyword} - query http://www.radio-browser.info for a radio station </li>
<li> <b>!<u>rbp</u>lay </b> {id} - play a radio station with {id} (eg. !rbplay 96746) </li>
<li> <b>!<u>l</u>istfile </b> [{pattern}] - display list of available files (that match the regex pattern if {pattern} is given) </li>
<li> <b>!<u>o</u>ust </b> - stop playing and go to default channel </li>
</ul>
<b>Other</b>
<ul>
<li> <b>!<u>j</u>oinme </b> - join your own channel </li>
</ul>
admin_help = Admin command:
<br />!kill (kill the bot)
<br />!update (update the bot)
<br />!userban [user] (ban a user)
<br />!userunban [user] (unban a user)
<br />!urlban [url] (ban an url)
<br />!urlunban [url] (unban an url)
<br />!reload (reload the ban config)
admin_help = <h3>Admin command</h3>
<ul>
<li><b>!<u>k</u>ill </b> - kill the bot</li>
<li><b>!<u>up</u>date </b> - update the bot</li>
<li><b>!<u>userb</u>an </b> {user} - ban a user</li>
<li><b>!<u>useru</u>nban </b> {user} - unban a user</li>
<li><b>!<u>urlb</u>an </b> {url} - ban an url</li>
<li><b>!<u>urlu</u>nban </b> {url} - unban an url</li>
<li><b>!dropdatabase</b> - clear the entire database, YOU SHOULD KNOW WHAT YOU ARE DOING.</li>
</ul>
[debug]
ffmpeg = False
mumbleConnection = False