Decide.info.dawg0100644000076400010010000000103507472276326014342 0ustar AdministratorNoneInformation: This script will randomly choose a word or words from a list of words specified via a pub or dcc command. Changes log for Decide.tcl: Version 1.2 * Released to the public from the |DAWG| Tcl web site. * Argument checking is now handled properly. * The random selection process has been made much more efficient. * Removed die lines. * Removed un-needed globals. * Code cleanups. Version 1.1 * Released to the public from the |DAWG| Tcl web site. * You can now chose how many choices to return, instead of just 2. Decide1.2.tcl0100644000076400010010000001047107503765664013500 0ustar AdministratorNone################################## ### Decide.tcl ### ### Version 1.2 ### ### By Wcc ### ### wcc@techmonkeys.org ### ### http://www.dawgtcl.com:81/ ### ### EFnet #|DAWG|Tcl ### ################################## ############################################################################ ### Copyright © 2000 - 2002 |DAWG| Scripting Group. All rights reserved. ### ############################################################################ ######################################################################### # This script will randomly choose a word or words from a list of words # # specified via a pub or dcc command. # ######################################################################### ############## ## COMMANDS ## ######################################################## ## DCC ## .decide (Can be changed) ## ######### Randomly chooses words from a list ## ######### of words ## ######################################################## ## PUB ## !decide (Can be changed) ## ######### Randomly chooses words from a list ## ######### of words ## ######################################################## ########################################################## ## Just load the script, edit the settings, and rehash. ## ########################################################## ######################################################### # Set the flag required to use the decide command here. # ######################################################### set decide_setting(flag) "-|-" ############################# # Set the pub command here. # ############################# set decide_setting(cmd_pub) "!decide" ############################# # Set the dcc command here. # ############################# set decide_setting(cmd_dcc) "decide" ################################### # Enable use of bold in DCC chat? # ################################### set decide_setting(bold) 1 ########################################## # Prefix "DECIDE:" in DCC chat messages? # ########################################## set decide_setting(DECIDE:) 1 #################### # Code begins here # #################### if {![string match 1.6.* $version]} { putlog "\002DECIDE:\002 \002WARNING:\002 This script is intended to run on eggdrop 1.6.x or later." } if {[info tclversion] < 8.2} { putlog "\002DECIDE:\002 \002WARNING:\002 This script is intended to run on Tcl Version 8.2 or later." } bind pub $decide_setting(flag) $decide_setting(cmd_pub) decide_pub bind dcc $decide_setting(flag) $decide_setting(cmd_dcc) decide_dcc proc decide_dopre {} { if {!$::decide_setting(DECIDE:)} { return "" } if {!$::decide_setting(bold)} { return "DECIDE: " } return "\002DECIDE:\002 " } proc decide_pub {nick uhost hand chan text} { set number [join [lindex [split $text] 0]] set text [join [lrange [split $text] 1 end]] if {[string compare $text ""] == 0} { puthelp "PRIVMSG $chan :Usage: .$::decide_setting(cmd_pub) " ; return } if {[regexp {[^0-9]} $number]} { puthelp "PRIVMSG $chan :$number is not a number." ; return } if {$number > [llength [split $text]]} { puthelp "PRIVMSG $chan :The number of choices to return must not be greater than the total number of choices." ; return } puthelp "PRIVMSG $chan :[decide_choose $text $number]" } proc decide_choose {text number} { foreach {a b} [list i 0 text [split $text] return ""] { set $a $b } while {$i < $number} { lappend return [lindex $text [set r [rand [llength $text]]]] set text [lreplace $text $r $r] incr i } return $return } proc decide_dcc {hand idx text} { set number [join [lindex [split $text] 0]] set text [join [lrange [split $text] 1 end]] if {[string compare $text ""] == 0} { putdcc $idx "[decide_dopre]Usage: .$::decide_setting(cmd_dcc) " ; return } if {[regexp {[^0-9]} $number]} { putdcc $idx "[decide_dopre]$number is not a number." ; return } if {$number > [llength [split $text]]} { putdcc $idx "[decide_dopre]The number of choices to return must not be greater than the total number of choices." ; return } putdcc $idx "[decide_dopre][decide_choose $text $number]" } putlog "\002DECIDE:\002 Decide.tcl Version 1.2 by Wcc is loaded."