Changeset 21


Ignore:
Timestamp:
10/08/06 09:48:44 (5 years ago)
Author:
james
Message:

add new category creation toggle, and fix typo in output

File:
1 edited

Legend:

Unmodified
Added
Removed
  • TriviaEngine/TriviaEngine-sqlite.tcl

    r20 r21  
    1313# the time between rounds (sec) 
    1414set trivia_delay 30 
     15 
     16# allow new categories to be created? 
     17set trivia_allow_new_cats 0 
    1518 
    1619# hold the current question info <<< 
     
    7982        #<<< 
    8083        global trivia_db_handle trivia_last_qid 
    81         global trivia_q_cat trivia_c 
     84        global trivia_q_cat trivia_c trivia_allow_new_cats 
    8285 
    8386        regsub "(trivia )" $cmd "" cmd 
     
    106109                                return 
    107110                        } else { 
    108                                 puthelp "PRIVMSG $nick :Creating new category$trivia_c(purple) $category" 
    109                                 set sql "INSERT INTO categories VALUES (null, '$category', 1)" 
    110                                 putloglev d * $sql 
    111                                 trivia_db_handle eval $sql 
    112                                 set cat_id [trivia_db_handle last_insert_rowid] 
    113                                 puthelp "PRIVMSG $nick :Moving question $trivia_last_qid to category$trivia_c(purple) $category$trivia_c(off) ($cat_id)" 
    114                                 set sql "UPDATE questions SET cat_id='$cat_id' WHERE question_id='$trivia_last_qid'" 
    115                                 putloglev d * $sql 
    116                                 trivia_db_handle eval $sql 
    117                                 set trivia_q_cat $orig_cat 
     111                                if {$trivia_allow_new_cats == 1} { 
     112                                        puthelp "PRIVMSG $nick :Creating new category$trivia_c(purple) $category" 
     113                                                set sql "INSERT INTO categories VALUES (null, '$category', 1)" 
     114                                                putloglev d * $sql 
     115                                                trivia_db_handle eval $sql 
     116                                                set cat_id [trivia_db_handle last_insert_rowid] 
     117                                                puthelp "PRIVMSG $nick :Moving question $trivia_last_qid to category$trivia_c(purple) $category$trivia_c(off) ($cat_id)" 
     118                                                set sql "UPDATE questions SET cat_id='$cat_id' WHERE question_id='$trivia_last_qid'" 
     119                                                putloglev d * $sql 
     120                                                trivia_db_handle eval $sql 
     121                                                set trivia_q_cat $orig_cat 
     122                                } else { 
     123                                        puthelp "PRIVMSG $nick :Creating new categories is $trivia_c(purple)DISABLED$trivia_c(off). ('trivia newcat enable' to enable.)" 
     124                                } 
    118125                                return 
    119126                        } 
    120127                } 
     128#>>> 
     129 
     130        #<<< enable or disable new category creation 
     131        if [regexp -nocase "^newcat (enable|disable)" $cmd matches toggle] { 
     132                if {$toggle == "enable"} { 
     133                        puthelp "PRIVMSG $nick :$trivia_c(purple)ENABLING$trivia_c(off) new category creation" 
     134                        set trivia_allow_new_cats 1 
     135                        return 
     136                } 
     137 
     138                if {$toggle == "disable"} { 
     139                        puthelp "PRIVMSG $nick :$trivia_c(purple)DISABLING$trivia_c(off) new category creation" 
     140                        set trivia_allow_new_cats 0 
     141                        return 
     142                } 
     143 
     144                puthelp "PRIVMSG $nick :Use: trivia newcat enable|disable" 
     145                return 
     146        } 
    121147#>>> 
    122148 
     
    237263                        return 0 
    238264                } else { 
    239                         puthelp "PRIGMSG $trivia_channel :Perhaps you want $trivia_c(purple)!trivia start" 
     265                        puthelp "PRIVMSG $trivia_channel :Perhaps you want $trivia_c(purple)!trivia start" 
    240266                        return 0 
    241267                } 
     
    598624        if {$param == "merge"} { 
    599625                trivia_merge $nick $arg 
    600                 #puthelp "PRIGMSG $trivia_channel :Score merging is disabled" 
     626                #puthelp "PRIVMSG $trivia_channel :Score merging is disabled" 
    601627                return 0 
    602628        } 
Note: See TracChangeset for help on using the changeset viewer.