forked from azlux/botamusique
-
Notifications
You must be signed in to change notification settings - Fork 1
/
command.py
629 lines (534 loc) · 25 KB
/
command.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
import logging
import os.path
import pymumble.pymumble_py3 as pymumble
import re
import time
import configparser
import interface
import media.file
import media.playlist
import media.radio
import media.system
import media.url
import util
import variables as var
from librb import radiobrowser
from media.playlist import PlayList
from database import Database
def register_all_commands(bot):
bot.register_command(var.config.get('command', 'joinme'), cmd_joinme)
bot.register_command(var.config.get('command', 'user_ban'), cmd_user_ban)
bot.register_command(var.config.get('command', 'user_unban'), cmd_user_unban)
bot.register_command(var.config.get('command', 'url_ban'), cmd_url_ban)
bot.register_command(var.config.get('command', 'url_unban'), cmd_url_unban)
bot.register_command(var.config.get('command', 'play'), cmd_play)
bot.register_command(var.config.get('command', 'pause'), cmd_pause)
bot.register_command(var.config.get('command', 'play_file'), cmd_play_file)
bot.register_command(var.config.get('command', 'play_file_match'), cmd_play_file_match)
bot.register_command(var.config.get('command', 'play_url'), cmd_play_url)
bot.register_command(var.config.get('command', 'play_playlist'), cmd_play_playlist)
bot.register_command(var.config.get('command', 'play_radio'), cmd_play_radio)
bot.register_command(var.config.get('command', 'rb_query'), cmd_rb_query)
bot.register_command(var.config.get('command', 'rb_play'), cmd_rb_play)
bot.register_command(var.config.get('command', 'help'), cmd_help)
bot.register_command(var.config.get('command', 'stop'), cmd_stop)
bot.register_command(var.config.get('command', 'clear'), cmd_clear)
bot.register_command(var.config.get('command', 'kill'), cmd_kill)
bot.register_command(var.config.get('command', 'update'), cmd_update)
bot.register_command(var.config.get('command', 'stop_and_getout'), cmd_stop_and_getout)
bot.register_command(var.config.get('command', 'volume'), cmd_volume)
bot.register_command(var.config.get('command', 'ducking'), cmd_ducking)
bot.register_command(var.config.get('command', 'ducking_threshold'), cmd_ducking_threshold)
bot.register_command(var.config.get('command', 'ducking_volume'), cmd_ducking_volume)
bot.register_command(var.config.get('command', 'current_music'), cmd_current_music)
bot.register_command(var.config.get('command', 'skip'), cmd_skip)
bot.register_command(var.config.get('command', 'remove'), cmd_remove)
bot.register_command(var.config.get('command', 'list_file'), cmd_list_file)
bot.register_command(var.config.get('command', 'queue'), cmd_queue)
bot.register_command(var.config.get('command', 'random'), cmd_random)
bot.register_command(var.config.get('command', 'drop_database'), cmd_drop_database)
def send_multi_lines(bot, lines, text):
msg = ""
br = ""
for newline in lines:
msg += br
br = "<br>"
if len(msg) + len(newline) > 5000:
bot.send_msg(msg, text)
msg = ""
msg += newline
bot.send_msg(msg, text)
# Parse the html from the message to get the URL
def get_url_from_input(string):
if string.startswith('http'):
return string
p = re.compile('href="(.+?)"', re.IGNORECASE)
res = re.search(p, string)
if res:
return res.group(1)
else:
return False
# ---------------- Commands ------------------
def cmd_joinme(bot, user, text, command, parameter):
channel_id = bot.mumble.users[text.actor]['channel_id']
bot.mumble.channels[channel_id].move_in()
def cmd_user_ban(bot, user, text, command, parameter):
if bot.is_admin(user):
if parameter:
bot.mumble.users[text.actor].send_text_message(util.user_ban(parameter))
else:
bot.mumble.users[text.actor].send_text_message(util.get_user_ban())
else:
bot.mumble.users[text.actor].send_text_message(var.config.get('strings', 'not_admin'))
return
def cmd_user_unban(bot, user, text, command, parameter):
if bot.is_admin(user):
if parameter:
bot.mumble.users[text.actor].send_text_message(util.user_unban(parameter))
else:
bot.mumble.users[text.actor].send_text_message(var.config.get('strings', 'not_admin'))
return
def cmd_url_ban(bot, user, text, command, parameter):
if bot.is_admin(user):
if parameter:
bot.mumble.users[text.actor].send_text_message(util.url_ban(bot.get_url_from_input(parameter)))
else:
bot.mumble.users[text.actor].send_text_message(util.get_url_ban())
else:
bot.mumble.users[text.actor].send_text_message(var.config.get('strings', 'not_admin'))
return
def cmd_url_unban(bot, user, text, command, parameter):
if bot.is_admin(user):
if parameter:
bot.mumble.users[text.actor].send_text_message(util.url_unban(bot.get_url_from_input(parameter)))
else:
bot.mumble.users[text.actor].send_text_message(var.config.get('strings', 'not_admin'))
return
def cmd_play(bot, user, text, command, parameter):
if var.playlist.length() > 0:
if parameter is not None and parameter.isdigit() and int(parameter) > 0 \
and int(parameter) <= len(var.playlist.playlist):
bot.stop()
bot.launch_music(int(parameter) - 1)
elif bot.is_pause:
bot.resume()
else:
bot.send_msg(util.format_current_playing(), text)
else:
bot.send_msg(var.config.get('strings', 'queue_empty'), text)
def cmd_pause(bot, user, text, command, parameter):
bot.pause()
bot.send_msg(var.config.get('strings', 'paused'))
def cmd_play_file(bot, user, text, command, parameter):
music_folder = var.config.get('bot', 'music_folder')
# if parameter is {index}
if parameter.isdigit():
files = util.get_recursive_filelist_sorted(music_folder)
if int(parameter) < len(files):
filename = files[int(parameter)].replace(music_folder, '')
music = {'type': 'file',
'path': filename,
'user': user}
logging.info("cmd: add to playlist: " + filename)
var.playlist.append(music)
bot.send_msg(var.config.get('strings', 'file_added') + music['title'], text)
# if parameter is {path}
else:
# sanitize "../" and so on
path = os.path.abspath(os.path.join(music_folder, parameter))
if not path.startswith(os.path.abspath(music_folder)):
bot.send_msg(var.config.get('strings', 'no_file'), text)
return
if os.path.isfile(path):
music = {'type': 'file',
'path': parameter,
'user': user}
logging.info("cmd: add to playlist: " + parameter)
music = var.playlist.append(music)
bot.send_msg(var.config.get('strings', 'file_added') + music['title'], text)
return
# if parameter is {folder}
elif os.path.isdir(path):
if parameter != '.' and parameter != './':
if not parameter.endswith("/"):
parameter += "/"
else:
parameter = ""
files = util.get_recursive_filelist_sorted(music_folder)
music_library = util.Dir(music_folder)
for file in files:
music_library.add_file(file)
files = music_library.get_files(parameter)
msgs = [var.config.get('strings', 'file_added')]
count = 0
for file in files:
count += 1
music = {'type': 'file',
'path': file,
'user': user}
logging.info("cmd: add to playlist: " + file)
music = var.playlist.append(music)
msgs.append("{} ({})".format(music['title'], music['path']))
if count != 0:
send_multi_lines(bot, msgs, text)
else:
bot.send_msg(var.config.get('strings', 'no_file'), text)
else:
# try to do a partial match
files = util.get_recursive_filelist_sorted(music_folder)
matches = [(index, file) for index, file in enumerate(files) if parameter.lower() in file.lower()]
if len(matches) == 0:
bot.send_msg(var.config.get(
'strings', 'no_file'), text)
elif len(matches) == 1:
music = {'type': 'file',
'path': matches[0][1],
'user': user}
logging.info("cmd: add to playlist: " + matches[0][1])
music = var.playlist.append(music)
bot.send_msg(var.config.get( 'strings', 'file_added')
+ "{} ({})".format(music['title'], music['path']), text)
else:
msgs = [ var.config.get('strings', 'multiple_matches') ]
for match in matches:
msgs.append("<b>{:0>3d}</b> - {:s}".format(match[0], match[1]))
send_multi_lines(bot, msgs, text)
def cmd_play_file_match(bot, user, text, command, parameter):
music_folder = var.config.get('bot', 'music_folder')
if parameter is not None:
files = util.get_recursive_filelist_sorted(music_folder)
msgs = [ var.config.get('strings', 'file_added') ]
count = 0
try:
for file in files:
match = re.search(parameter, file)
if match:
count += 1
music = {'type': 'file',
'path': file,
'user': user}
logging.info("cmd: add to playlist: " + file)
music = var.playlist.append(music)
msgs.append("{} ({})".format(music['title'], music['path']))
if count != 0:
send_multi_lines(bot, msgs, text)
else:
bot.send_msg(var.config.get('strings', 'no_file'), text)
except re.error as e:
msg = var.config.get('strings', 'wrong_pattern') % str(e)
bot.send_msg(msg, text)
else:
bot.send_msg(var.config.get('strings', 'bad_parameter') % command)
def cmd_play_url(bot, user, text, command, parameter):
music = {'type': 'url',
# grab the real URL
'url': bot.get_url_from_input(parameter),
'user': user,
'ready': 'validation'}
if media.url.get_url_info(music):
if music['duration'] > var.config.getint('bot', 'max_track_duration'):
bot.send_msg(var.config.get(
'strings', 'too_long'), text)
else:
music['ready'] = "no"
var.playlist.append(music)
logging.info("cmd: add to playlist: " + music['url'])
bot.async_download_next()
else:
bot.send_msg(var.config.get(
'strings', 'unable_download'), text)
def cmd_play_playlist(bot, user, text, command, parameter):
offset = 0 # if you want to start the playlist at a specific index
try:
offset = int(parameter.split(" ")[-1])
except ValueError:
pass
url = get_url_from_input(parameter)
logging.debug("cmd: fetching media info from playlist url %s" % url)
items = media.playlist.get_playlist_info(url=url, start_index=offset, user=user)
if len(items) > 0:
var.playlist.extend(items)
for music in items:
logging.info("cmd: add to playlist: %s (%s)" % (music['title'], music['url']))
def cmd_play_radio(bot, user, text, command, parameter):
if not parameter:
all_radio = var.config.items('radio')
msg = var.config.get(
'strings', 'preconfigurated_radio') + " :"
for i in all_radio:
comment = ""
if len(i[1].split(maxsplit=1)) == 2:
comment = " - " + i[1].split(maxsplit=1)[1]
msg += "<br />" + i[0] + comment
bot.send_msg(msg, text)
else:
if var.config.has_option('radio', command, parameter):
parameter = var.config.get('radio', parameter)
parameter = parameter.split()[0]
url = bot.get_url_from_input(parameter)
if url:
music = {'type': 'radio',
'url': url,
'user': user}
var.playlist.append(music)
logging.info("cmd: add to playlist: " + music['url'])
bot.async_download_next()
else:
bot.send_msg(var.config.get('strings', 'bad_url'))
def cmd_rb_query(bot, user, text, command, parameter):
logging.info('cmd: Querying radio stations')
if not parameter:
logging.debug('rbquery without parameter')
msg = var.config.get('strings', 'rb_query_empty')
bot.send_msg(msg, text)
else:
logging.debug('cmd: Found query parameter: ' + parameter)
# bot.send_msg('Searching for stations - this may take some seconds...', text)
rb_stations = radiobrowser.getstations_byname(parameter)
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>'
if not rb_stations:
logging.debug('cmd: No matches found for rbquery ' + parameter)
bot.send_msg('Radio-Browser found no matches for ' + parameter, text)
else:
for s in rb_stations:
stationid = s['id']
stationname = s['stationname']
country = s['country']
codec = s['codec']
bitrate = s['bitrate']
genre = s['genre']
# msg += f'<tr><td>{stationid}</td><td>{stationname}</td><td>{genre}</td><td>{codec}/{bitrate}</td><td>{country}</td></tr>'
msg += '<tr><td>%s</td><td>%s</td><td>%s</td><td>%s/%s</td><td>%s</td></tr>' % (
stationid, stationname, genre, codec, bitrate, country)
msg += '</table>'
# Full message as html table
if len(msg) <= 5000:
bot.send_msg(msg, text)
# Shorten message if message too long (stage I)
else:
logging.debug('Result too long stage I')
msg = var.config.get('strings', 'rb_query_result') + " :" + ' (shortened L1)'
msg += '\n<table><tr><th>!rbplay ID</th><th>Station Name</th></tr>'
for s in rb_stations:
stationid = s['id']
stationname = s['stationname']
# msg += f'<tr><td>{stationid}</td><td>{stationname}</td>'
msg += '<tr><td>%s</td><td>%s</td>' % (stationid, stationname)
msg += '</table>'
if len(msg) <= 5000:
bot.send_msg(msg, text)
# Shorten message if message too long (stage II)
else:
logging.debug('Result too long stage II')
msg = var.config.get('strings', 'rb_query_result') + " :" + ' (shortened L2)'
msg += '!rbplay ID - Station Name'
for s in rb_stations:
stationid = s['id']
stationname = s['stationname'][:12]
# msg += f'{stationid} - {stationname}'
msg += '%s - %s' % (stationid, stationname)
if len(msg) <= 5000:
bot.send_msg(msg, text)
# Message still too long
else:
bot.send_msg('Query result too long to post (> 5000 characters), please try another query.',
text)
def cmd_rb_play(bot, user, text, command, parameter):
logging.debug('cmd: Play a station by ID')
if not parameter:
logging.debug('rbplay without parameter')
msg = var.config.get('strings', 'rb_play_empty')
bot.send_msg(msg, text)
else:
logging.debug('cmd: Retreiving url for station ID ' + parameter)
rstation = radiobrowser.getstationname_byid(parameter)
stationname = rstation[0]['name']
country = rstation[0]['country']
codec = rstation[0]['codec']
bitrate = rstation[0]['bitrate']
genre = rstation[0]['tags']
homepage = rstation[0]['homepage']
msg = 'Radio station added to playlist:'
# msg += '<table><tr><th>ID</th><th>Station Name</th><th>Genre</th><th>Codec/Bitrate</th><th>Country</th><th>Homepage</th></tr>' + \
# f'<tr><td>{parameter}</td><td>{stationname}</td><td>{genre}</td><td>{codec}/{bitrate}</td><td>{country}</td><td>{homepage}</td></tr></table>'
msg += '<table><tr><th>ID</th><th>Station Name</th><th>Genre</th><th>Codec/Bitrate</th><th>Country</th><th>Homepage</th></tr>' + \
'<tr><td>%s</td><td>%s</td><td>%s</td><td>%s/%s</td><td>%s</td><td>%s</td></tr></table>' \
% (parameter, stationname, genre, codec, bitrate, country, homepage)
logging.debug('cmd: Added station to playlist %s' % stationname)
bot.send_msg(msg, text)
url = radiobrowser.geturl_byid(parameter)
if url != "-1":
logging.info('cmd: Found url: ' + url)
music = {'type': 'radio',
'title': stationname,
'artist': homepage,
'url': url,
'user': user}
var.playlist.append(music)
logging.info("cmd: add to playlist: " + music['url'])
bot.async_download_next()
else:
logging.info('cmd: No playable url found.')
msg += "No playable url found for this station, please try another station."
bot.send_msg(msg, text)
def cmd_help(bot, user, text, command, parameter):
bot.send_msg(var.config.get('strings', 'help'), text)
if bot.is_admin(user):
bot.send_msg(var.config.get(
'strings', 'admin_help'), text)
def cmd_stop(bot, user, text, command, parameter):
bot.stop()
bot.send_msg(var.config.get( 'strings', 'stopped'), text)
def cmd_clear(bot, user, text, command, parameter):
bot.clear()
bot.send_msg(var.config.get(
'strings', 'cleared'), text)
def cmd_kill(bot, user, text, command, parameter):
if bot.is_admin(user):
bot.pause()
bot.exit = True
else:
bot.mumble.users[text.actor].send_text_message(
var.config.get('strings', 'not_admin'))
def cmd_update(bot, user, text, command, parameter):
if bot.is_admin(user):
bot.mumble.users[text.actor].send_text_message(
"Starting the update")
# Need to be improved
msg = util.update(version)
bot.mumble.users[text.actor].send_text_message(msg)
else:
bot.mumble.users[text.actor].send_text_message(
var.config.get('strings', 'not_admin'))
def cmd_stop_and_getout(bot, user, text, command, parameter):
bot.stop()
if bot.channel:
bot.mumble.channels.find_by_name(bot.channel).move_in()
def cmd_volume(bot, user, text, command, parameter):
# The volume is a percentage
if parameter is not None and parameter.isdigit() and 0 <= int(parameter) <= 100:
bot.volume_set = float(float(parameter) / 100)
bot.send_msg(var.config.get('strings', 'change_volume') % (
int(bot.volume_set * 100), bot.mumble.users[text.actor]['name']), text)
var.db.set('bot', 'volume', str(bot.volume_set))
logging.info('cmd: volume set to %d' % (bot.volume_set * 100))
else:
bot.send_msg(var.config.get(
'strings', 'current_volume') % int(bot.volume_set * 100), text)
def cmd_ducking(bot, user, text, command, parameter):
if parameter == "" or parameter == "on":
bot.is_ducking = True
var.db.set('bot', 'ducking', True)
bot.ducking_volume = var.config.getfloat("bot", "ducking_volume", fallback=0.05)
bot.ducking_threshold = var.config.getint("bot", "ducking_threshold", fallback=5000)
bot.mumble.callbacks.set_callback(pymumble.constants.PYMUMBLE_CLBK_SOUNDRECEIVED,
bot.ducking_sound_received)
bot.mumble.set_receive_sound(True)
logging.info('cmd: ducking is on')
msg = "Ducking on."
bot.send_msg(msg, text)
elif parameter == "off":
bot.is_ducking = False
bot.mumble.set_receive_sound(False)
var.db.set('bot', 'ducking', False)
msg = "Ducking off."
logging.info('cmd: ducking is off')
bot.send_msg(msg, text)
def cmd_ducking_threshold(bot, user, text, command, parameter):
if parameter is not None and parameter.isdigit():
bot.ducking_threshold = int(parameter)
var.db.set('bot', 'ducking_threshold', str(bot.ducking_threshold))
msg = "Ducking threshold set to %d." % bot.ducking_threshold
bot.send_msg(msg, text)
else:
msg = "Current ducking threshold is %d." % bot.ducking_threshold
bot.send_msg(msg, text)
def cmd_ducking_volume(bot, user, text, command, parameter):
# The volume is a percentage
if parameter is not None and parameter.isdigit() and 0 <= int(parameter) <= 100:
bot.ducking_volume = float(float(parameter) / 100)
bot.send_msg(var.config.get('strings', 'change_ducking_volume') % (
int(bot.ducking_volume * 100), bot.mumble.users[text.actor]['name']), text)
# var.db.set('bot', 'volume', str(bot.volume_set))
var.db.set('bot', 'ducking_volume', str(bot.ducking_volume))
logging.info('cmd: volume on ducking set to %d' % (bot.ducking_volume * 100))
else:
bot.send_msg(var.config.get(
'strings', 'current_ducking_volume') % int(bot.ducking_volume * 100), text)
def cmd_current_music(bot, user, text, command, parameter):
reply = ""
if len(var.playlist.playlist) > 0:
reply = util.format_current_playing()
else:
reply = var.config.get('strings', 'not_playing')
bot.send_msg(reply, text)
def cmd_skip(bot, user, text, command, parameter):
if bot.next(): # Is no number send, just skip the current music
bot.launch_music()
bot.async_download_next()
else:
bot.send_msg(var.config.get(
'strings', 'queue_empty'), text)
def cmd_remove(bot, user, text, command, parameter):
# Allow to remove specific music into the queue with a number
if parameter is not None and parameter.isdigit() and int(parameter) > 0 \
and int(parameter) <= var.playlist.length():
index = int(parameter) - 1
removed = None
if index == var.playlist.current_index:
removed = var.playlist.remove(index)
var.botamusique.stop()
var.botamusique.launch_music(index)
else:
removed = var.playlist.remove(index)
# the Title isn't here if the music wasn't downloaded
bot.send_msg(var.config.get('strings', 'removing_item') % (
removed['title'] if 'title' in removed else removed['url']), text)
logging.info("cmd: delete from playlist: " + str(removed['path'] if 'path' in removed else removed['url']))
else:
bot.send_msg(var.config.get('strings', 'bad_parameter') % command)
def cmd_list_file(bot, user, text, command, parameter):
folder_path = var.config.get('bot', 'music_folder')
files = util.get_recursive_filelist_sorted(folder_path)
msgs = [ "<br> <b>Files available:</b>" if not parameter else "<br> <b>Matched files:</b>" ]
try:
count = 0
for index, file in enumerate(files):
if parameter:
match = re.search(parameter, file)
if not match:
continue
count += 1
msgs.append("<b>{:0>3d}</b> - {:s}".format(index, file))
if count != 0:
send_multi_lines(bot, msgs, text)
else:
bot.send_msg(var.config.get('strings', 'no_file'), text)
except re.error as e:
msg = var.config.get('strings', 'wrong_pattern') % str(e)
bot.send_msg(msg, text)
def cmd_queue(bot, user, text, command, parameter):
if len(var.playlist.playlist) == 0:
msg = var.config.get('strings', 'queue_empty')
bot.send_msg(msg, text)
else:
msgs = [ var.config.get('strings', 'queue_contents') ]
for i, value in enumerate(var.playlist.playlist):
newline = ''
if i == var.playlist.current_index:
newline = '<b>{} ({}) {}</b>'.format(i + 1, value['type'],
value['title'] if 'title' in value else value['url'])
else:
newline = '<b>{}</b> ({}) {}'.format(i + 1, value['type'],
value['title'] if 'title' in value else value['url'])
msgs.append(newline)
send_multi_lines(bot, msgs, text)
def cmd_random(bot, user, text, command, parameter):
bot.stop()
var.playlist.randomize()
bot.launch_music(0)
def cmd_drop_database(bot, user, text, command, parameter):
var.db.drop_table()
var.db = Database(var.dbfile)
bot.send_msg(var.config.get('strings', 'database_dropped'), text)