Shorten query results if too long
This commit is contained in:
parent
a68e9b683d
commit
d78c480709
22
mumbleBot.py
22
mumbleBot.py
@ -387,10 +387,28 @@ class MumbleBot:
|
||||
genre = s['genre']
|
||||
msg += f'<tr><td>{stationid}</td><td>{stationname}</td><td>{genre}</td><td>{codec}/{bitrate}</td><td>{country}</td></tr>'
|
||||
msg += '</table>'
|
||||
# Shorten table if message too long
|
||||
if len(msg) < 5000:
|
||||
self.send_msg(msg, text)
|
||||
msg = var.config.get('strings', 'rbqueryresult') + " :" + ' (shortened L1)'
|
||||
msg += '\n<table><tr><th>!rbplay ID</th><th>Station Name</th></tr>'
|
||||
else:
|
||||
self.send_msg('Query result too long to post (> 5000 characters), please try another query.', text)
|
||||
for s in rb_stations:
|
||||
stationid = s['id']
|
||||
stationname = s['stationname']
|
||||
msg += f'<tr><td>{stationid}</td><td>{stationname}</td>'
|
||||
if len(msg) < 5000:
|
||||
self.send_msg(msg, text)
|
||||
else:
|
||||
msg = var.config.get('strings', 'rbqueryresult') + " :" + ' (shortened L2)'
|
||||
msg += '!rbplay ID - Station Name'
|
||||
for s in rb_stations:
|
||||
stationid = s['id']
|
||||
stationname = s['stationname']
|
||||
msg += f'{stationid} - {stationname}'
|
||||
if len(msg) < 5000:
|
||||
self.send_msg(msg, text)
|
||||
else:
|
||||
self.send_msg('Query result too long to post (> 5000 characters), please try another query.', text)
|
||||
# Play a secific station (by id) from http://www.radio-browser.info API
|
||||
elif command == var.config.get('command', 'rb_play'):
|
||||
logging.debug('Play a station by ID')
|
||||
|
Loading…
x
Reference in New Issue
Block a user