]> git.0d.be Git - botaradio.git/commitdiff
fix: no admin check for dropdatabase
authorTerry Geng <gengyanda@gmail.com>
Sun, 8 Mar 2020 05:55:41 +0000 (13:55 +0800)
committerTerry Geng <gengyanda@gmail.com>
Sun, 8 Mar 2020 05:55:41 +0000 (13:55 +0800)
command.py
configuration.default.ini

index 581c6e579779a0dac4c008f77fde1d8a361d0d52..d9e0e67fe8f31aff5c04dac7ba86fce6de9da453 100644 (file)
@@ -894,18 +894,24 @@ def cmd_find_tagged(bot, user, text, command, parameter):
 def cmd_drop_database(bot, user, text, command, parameter):
     global log
 
-    var.db.drop_table()
-    var.db = SettingsDatabase(var.dbfile)
-    var.music_db.drop_table()
-    var.music_db = MusicDatabase(var.dbfile)
-    log.info("command: database dropped.")
-    bot.send_msg(constants.strings('database_dropped'), text)
+    if bot.is_admin(user):
+        var.db.drop_table()
+        var.db = SettingsDatabase(var.dbfile)
+        var.music_db.drop_table()
+        var.music_db = MusicDatabase(var.dbfile)
+        log.info("command: database dropped.")
+        bot.send_msg(constants.strings('database_dropped'), text)
+    else:
+        bot.mumble.users[text.actor].send_text_message(constants.strings('not_admin'))
 
 def cmd_refresh_cache(bot, user, text, command, parameter):
     global log
-    var.library.build_dir_cache(bot)
-    log.info("command: Local file cache refreshed.")
-    bot.send_msg(constants.strings('cache_refreshed'), text)
+    if bot.is_admin(user):
+        var.library.build_dir_cache(bot)
+        log.info("command: Local file cache refreshed.")
+        bot.send_msg(constants.strings('cache_refreshed'), text)
+    else:
+        bot.mumble.users[text.actor].send_text_message(constants.strings('not_admin'))
 
 # Just for debug use
 def cmd_real_time_rms(bot, user, text, command, parameter):
index ff2ffa3d970e3d7419218bf62fee65a3df39d183..598945b8c7cb3709d98c8b4d40231c686d65d12c 100644 (file)
@@ -276,11 +276,13 @@ help = <h3>Commands</h3>
        first search result of {keywords} into the playlist.</li>
        </ul>
        <b>Tag</b>
+       <ul>
        <li> <b>!<u>addt</u>ag </b> {index} {tags} - add {tags} to {index}-th item on the playlist, tags separated by ",". </li>
        <li> <b>!<u>addt</u>ag </b> * {tags} - add {tags} to all items on the playlist. </li>
        <li> <b>!<u>un</u>tag </b> {index/*} {tags} - remove {tags} from {index}-th item on the playlist. </li>
        <li> <b>!<u>un</u>tag </b> {index/*} * - remove all tags from {index}-th item on the playlist. </li>
        <li> <b>!<u>fin</u>dtagged </b> (or <b>!ft</b>) {tags} - find item with {tags} in the music library. </li>
+       </ul>
        <b>Other</b>
        <ul>
        <li> <b>!<u>j</u>oinme {token} </b> - join your own channel with {token}.</li>