merge with azlux's branch

This commit is contained in:
Terry Geng 2020-02-05 23:29:48 +08:00
commit 4e905c1c56
4 changed files with 17 additions and 15 deletions

View File

@ -76,7 +76,7 @@ If you want information about autoStart and auto-Restart the bot, [you can have
### Custom commands ### Custom commands
You can copy the file `configuration.default.ini` to `configuration.ini` and customize all variable. Everything can be change but don't remove the default file. You can copy the file `configuration.default.ini` to `configuration.ini` and customize all variable. Everything can be change but don't remove the default file.
you have the section : you have the sections :
- server : configuration about the server and bot name. This is overrided by the `./mumbleBot.py` parameters. - server : configuration about the server and bot name. This is overrided by the `./mumbleBot.py` parameters.
- bot : basic configuration of the bot : comment, folder, volume at start .... - bot : basic configuration of the bot : comment, folder, volume at start ....
- webinterface : basic configuration about the interface (disabled by default) - webinterface : basic configuration about the interface (disabled by default)
@ -110,4 +110,4 @@ The following people joined the collaborators for a faster development, big than
- @slipenbois - @slipenbois
- @mertkutay - @mertkutay
Feel free to ask me if you want to help activelly without using pull requests. Feel free to ask me if you want to help activelly without using pull requests.

View File

@ -110,7 +110,9 @@ no_possible = it's not possible to do that
removing_item = Removing entry %s from queue removing_item = Removing entry %s from queue
user_ban = You are ban, not allowed to do that ! user_ban = You are ban, not allowed to do that !
url_ban = This url isn't allowed ! url_ban = This url isn't allowed !
rbqueryresult = This is the result of your query, send !rbplay 'ID' to play a station 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
help = Command available: help = Command available:
<br />!file [path] <br />!file [path]

View File

@ -61,7 +61,7 @@ type : file
user user
""" """
version = 4 version = 5
class MumbleBot: class MumbleBot:
@ -377,13 +377,13 @@ class MumbleBot:
logging.info('bot: Querying radio stations') logging.info('bot: Querying radio stations')
if not parameter: if not parameter:
logging.debug('rbquery without parameter') logging.debug('rbquery without parameter')
msg += 'You have to add a query text to search for a matching radio stations.' msg = var.config.get('strings', 'rb_query_empty')
self.send_msg(msg, text) self.send_msg(msg, text)
else: else:
logging.debug('bot: Found query parameter: ' + parameter) logging.debug('bot: Found query parameter: ' + parameter)
# self.send_msg('Searching for stations - this may take some seconds...', text) # self.send_msg('Searching for stations - this may take some seconds...', text)
rb_stations = radiobrowser.getstations_byname(parameter) rb_stations = radiobrowser.getstations_byname(parameter)
msg = var.config.get('strings', 'rbqueryresult') + " :" msg = var.config.get('strings', 'rb_query_result') + " :"
msg += '\n<table><tr><th>!rbplay ID</th><th>Station Name</th><th>Genre</th><th>Codec/Bitrate</th><th>Country</th></tr>' msg += '\n<table><tr><th>!rbplay ID</th><th>Station Name</th><th>Genre</th><th>Codec/Bitrate</th><th>Country</th></tr>'
if not rb_stations: if not rb_stations:
logging.debug('bot: No matches found for rbquery ' + parameter) logging.debug('bot: No matches found for rbquery ' + parameter)
@ -404,8 +404,8 @@ class MumbleBot:
self.send_msg(msg, text) self.send_msg(msg, text)
# Shorten message if message too long (stage I) # Shorten message if message too long (stage I)
else: else:
logging.debug('bot: Result too long stage I') logging.debug('Result too long stage I')
msg = var.config.get('strings', 'rbqueryresult') + " :" + ' (shortened L1)' msg = var.config.get('strings', 'rb_query_result') + " :" + ' (shortened L1)'
msg += '\n<table><tr><th>!rbplay ID</th><th>Station Name</th></tr>' msg += '\n<table><tr><th>!rbplay ID</th><th>Station Name</th></tr>'
for s in rb_stations: for s in rb_stations:
stationid = s['id'] stationid = s['id']
@ -417,8 +417,8 @@ class MumbleBot:
self.send_msg(msg, text) self.send_msg(msg, text)
# Shorten message if message too long (stage II) # Shorten message if message too long (stage II)
else: else:
logging.debug('bot: Result too long stage II') logging.debug('Result too long stage II')
msg = var.config.get('strings', 'rbqueryresult') + " :" + ' (shortened L2)' msg = var.config.get('strings', 'rb_query_result') + " :" + ' (shortened L2)'
msg += '!rbplay ID - Station Name' msg += '!rbplay ID - Station Name'
for s in rb_stations: for s in rb_stations:
stationid = s['id'] stationid = s['id']
@ -434,8 +434,8 @@ class MumbleBot:
elif command == var.config.get('command', 'rb_play'): elif command == var.config.get('command', 'rb_play'):
logging.debug('bot: Play a station by ID') logging.debug('bot: Play a station by ID')
if not parameter: if not parameter:
logging.debug('bot: rbplay without parameter') logging.debug('rbplay without parameter')
msg += 'Please enter a station ID from rbquery. Example: !rbplay 96748' msg = var.config.get('strings', 'rb_play_empty')
self.send_msg(msg, text) self.send_msg(msg, text)
else: else:
logging.debug('bot: Retreiving url for station ID ' + parameter) logging.debug('bot: Retreiving url for station ID ' + parameter)
@ -857,7 +857,7 @@ class MumbleBot:
# Main loop of the Bot # Main loop of the Bot
def loop(self): def loop(self):
raw_music = "" raw_music = ""
while not self.exit and self.mumble.isAlive(): while not self.exit and self.mumble.is_alive():
while self.mumble.sound_output.get_buffer_size() > 0.5 and not self.exit: while self.mumble.sound_output.get_buffer_size() > 0.5 and not self.exit:
# If the buffer isn't empty, I cannot send new music part, so I wait # If the buffer isn't empty, I cannot send new music part, so I wait
@ -988,4 +988,4 @@ if __name__ == '__main__':
var.config = config var.config = config
var.db = db var.db = db
var.botamusique = MumbleBot(args) var.botamusique = MumbleBot(args)
var.botamusique.loop() var.botamusique.loop()

@ -1 +1 @@
Subproject commit 437d2ebec6e18b5ad69b77020596c250a5e1b785 Subproject commit 8ccfb0e7cf7183cc6766591b985dfc1bcf5a2d37