ClanAvail.info.dawg0100644000076400010010000000152707502006624015007 0ustar AdministratorNoneInformation: This script stores availability details for clan wars. Users must be authorized to use the commands. The bot will also automatically change your channel's topic to the availability details of the next war. Changes log for ClanAvail.tcl: Version 1.4 * Released to the public from the |DAWG| Scripting Team web site. * Removed die lines. * Code cleanups. Version 1.3 * Released to the public from the |DAWG| Scripting Team web site. * Bug fixes. Version 1.2 * Released to the public from the |DAWG| Scripting Team web site. * Availability is now cleared when !wardetails is typed. Version 1.1 * Released to the public from the |DAWG| Scripting Team web site. * !wardetails works now. * An extra space is no longer added to the topic. * You can now choose to append or prefix the existing topic.ClanAvail1.4.tcl0100644000076400010010000002772607503765304014161 0ustar AdministratorNone################################## ### ClanAvail.tcl ### ### Version 1.4 ### ### By Wcc ### ### wcc@techmonkeys.org ### ### http://www.dawgtcl.com:81/ ### ### EFnet #|DAWG|Tcl ### ################################## ############################################################################ ### Copyright © 2000 - 2002 |DAWG| Scripting Group. All rights reserved. ### ############################################################################ ######################################################################### ## This script stores availability details for clan wars. Users must ## ## be authorized to use the commands. The bot will also automatically ## ## change your channel's topic to the availability details of the next ## ## war. ## ######################################################################### ############## ## COMMANDS ## ########################################################## ## PUB ## !avail (Can be changed) ## ######### Sets you as available for the next war. ## ######### --------------------------------------------- ## ######### !navail (Can be changed) ## ######### Sets you as not available for the next war. ## ######### --------------------------------------------- ## ######### !maybe (Can be changed) ## ######### Sets you as maybe available for the next war. ## ######### -------------------------------------------- ## ######### !wardetails [details] ## ######### Shows the details for the next war. ## ######### Availability is also shown, than cleared. If ## ######### details are given, the war details will be ## ######### set to the specified information. ## ########################################################## ## MSG ## /msg auth ## ######### Authorizes you to use commands. ## ######### --------------------------------------------- ## ######### /msg deauth ## ######### De-authorizes you from using commands. ## ########################################################## ## DCC ## .chanset +clantopic ## ######### Makes the bot set the topic of the specified ## ######### channel to the details of the next war when ## ######### information changes. ## ########################################################## ########################################################## ## Just load the script, edit the settings, and rehash. ## ########################################################## ################################################# # Set the flag required to use the script here. # ################################################# set clanavail_setting(flag) "o|o" ################################################################# # Set the command for setting yourself as maybe available here. # ################################################################# set clanavail_setting(maybe) "!maybe" ########################################################### # Set the command for setting yourself as available here. # ########################################################### set clanavail_setting(avail) "!avail" ############################################################### # Set the command for setting yourself as not available here. # ############################################################### set clanavail_setting(navail) "!navail" #################################################################### # When adding to the topic, should the war details be added to the # # end of the topic or the beginning? (0 for beginning, 1 for end) # #################################################################### set clanavail_setting(end) 1 ################################### # Set the database filename here. # ################################### set clanavail_setting(database) "./scripts/clanavail.db" ################################################################### # Enable bold in topic and !wardetails? (Makes it easier to read) # ################################################################### set clanavail_setting(bold) 1 #################### # Code begins here # #################### if {$numversion < 1060800} { putlog "\002CLANAVAIL:\002 \002WARNING:\002 This script is intended to run on eggdrop 1.6.8 or later." } if {[info tclversion] < 8.2} { putlog "\002CLANAVAIL:\002 \002WARNING:\002 This script is intended to run on Tcl Version 8.2 or later." } bind pub $clanavail_setting(flag) !wardetails clanavail_showwar bind pub $clanavail_setting(flag) $clanavail_setting(maybe) clanavail_maybe bind pub $clanavail_setting(flag) $clanavail_setting(avail) clanavail_avail bind pub $clanavail_setting(flag) $clanavail_setting(navail) clanavail_navail bind msg - auth clanavail_auth bind msg - deauth clanavail_deauth bind part - * clanavail_deauth_part bind sign - * clanavail_deauth_sign bind splt - * clanavail_deauth_splt setudef flag clantopic proc clanavail_auth {nick uhost hand text} { if {![validuser $hand]} { putserv "NOTICE $nick :You are not a bot user." ; return } if {[string compare [lindex [set text [split $text]] 0] ""] == 0} { putserv "NOTICE $nick :Usage: /msg $::botnick auth " ; return } if {![passwdok $hand [lindex $text 0]]} { putserv "NOTICE $nick :Invalid password." ; return } if {[matchattr $hand +Q]} { putserv "NOTICE $nick :You are already authorized." ; return } chattr $hand +Q putserv "NOTICE $nick :You are now authorized." } proc clanavail_deauth {nick uhost hand text} { if {![validuser $hand]} { putserv "NOTICE $nick :You are not a bot user." ; return } if {![matchattr $hand +Q]} { putserv "NOTICE $nick :You are not authorized." ; return } chattr $hand -Q putserv "NOTICE $nick :You are no longer authorized." } proc clanavail_deauth_sign {nick uhost hand chan text} { if {[validuser $hand] && [matchattr $hand +Q]} { chattr $hand -Q } } proc clanavail_deauth_part {nick uhost hand chan text} { if {![onchan $nick] && [validuser $hand] && [matchattr $hand +Q]} { chattr $hand -Q } } proc clanavail_deauth_splt {nick uhost hand chan} { if {[validuser $hand] && [matchattr $hand +Q]} { chattr $hand -Q } } proc clanavail_readarray {array file} { upvar $array ours if {[catch {open $file r} fd]} { return } if {[array exists ours]} { unset ours } foreach line [split [read $fd] \n] { if {[string range $line 0 2] != "%!%" || [scan [string range $line 3 end] "%\[^!!!\]!!!%s" name data] <= 0} { continue } if {![info exists data]} { set data "" } set ours($name) $data } close $fd } proc clanavail_savearray {array file} { upvar $array ours if {![array exists ours] || [catch {open $file w} fd]} { return } foreach entry [array names ours] { puts $fd "%!%$entry!!!$ours($entry)" } close $fd } if {![array exists clanavail_users] && [file exists $clanavail_setting(database)]} { clanavail_readarray clanavail_users $clanavail_setting(database) } proc clanavail_showwar {nick uhost hand chan text} { if {![matchattr $hand +Q]} { putserv "NOTICE $nick :You are not authorized. Please type \"/msg $::botnick auth \" to authorize yourself." ; return } if {$text == ""} { if {![info exists ::clanavail_users(/warinfo)]} { set ::clanavail_users(/warinfo) "None" } foreach {a b} [list users [clanavail_getavail] avail [lindex $users 0] navail [lindex $users 1] maybe [lindex $users 2]] { set $a $b } putserv "PRIVMSG $chan :[clanavail_bold "Next War: $::clanavail_users(/warinfo) Available: $avail Not Available: $navail Maybe Available: $maybe."]" catch { unset ::clanavail_users(/warinfo) } return } set ::clanavail_users(/warinfo) $text clanavail_do_topic putserv "NOTICE $nick :[clanavail_bold "Next War: $::clanavail_users(/warinfo)"]" } proc clanavail_avail {nick uhost hand chan text} { global clanavail_users if {![matchattr $hand +Q]} { putserv "NOTICE $nick :You are not authorized. Please type \"/msg $::botnick auth \" to authorize yourself." ; return } if {[info exists clanavail_users($nick)] && [string match avail $clanavail_users($nick)]} { putserv "NOTICE $nick :You are already marked as available." ; return } set clanavail_users($nick) avail clanavail_savearray clanavail_users $::clanavail_setting(database) clanavail_do_topic putserv "NOTICE $nick :You are now marked as available." } proc clanavail_navail {nick uhost hand chan text} { global clanavail_users if {![matchattr $hand +Q]} { putserv "NOTICE $nick :You are not authorized. Please type \"/msg $::botnick auth \" to authorize yourself." ; return } if {[info exists clanavail_users($nick)] && [string match navail $clanavail_users($nick)]} { putserv "NOTICE $nick :You are already marked as not available." ; return } set clanavail_users($nick) navail clanavail_savearray clanavail_users $::clanavail_setting(database) clanavail_do_topic putserv "NOTICE $nick :You are now marked as not available." } proc clanavail_maybe {nick uhost hand chan text} { global clanavail_users if {![matchattr $hand +Q]} { putserv "NOTICE $nick :You are not authorized. Please type \"/msg $::botnick auth \" to authorize yourself." ; return } if {[info exists clanavail_users($nick)] && [string match maybe $clanavail_users($nick)]} { putserv "NOTICE $nick :You are already marked as maybe available." ; return } set clanavail_users($nick) maybe clanavail_savearray clanavail_users $::clanavail_setting(database) clanavail_do_topic putserv "NOTICE $nick :You are now marked as maybe available." } proc clanavail_do_topic {} { global clanavail_users foreach {a b} [list users [clanavail_getavail] avail [lindex $users 0] navail [lindex $users 1] maybe [lindex $users 2]] { set $a $b } if {![info exists clanavail_users(/warinfo)]} { set clanavail_users(/warinfo) "None" } foreach c [channels] { if {![botisop $chan] || [lsearch -exact [channel info $chan] +chantopic] == -1} { continue } if {!$::clanavail_setting(end)} { if {[string match "*Next War:*Available:*Not Available:*Maybe Available:*. |*" [topic $chan]]} { set topic [string range [topic $chan] [expr [string first ". |" [topic $chan]] + 4] end] } { set topic [topic $chan] } set topic "[clanavail_bold "Next War: $clanavail_users(/warinfo) Available: $avail Not Available: $navail Maybe Available: $maybe."] | $topic" } { if {[string match "*| *Next War:*Available:*Not Available:*Maybe Available:*" [topic $chan]]} { if {$::clanavail_setting(bold)} { set topic [string range [topic $chan] 0 [expr [string first "| \002Next War:" [topic $chan]] - 2]] } { set topic [string range [topic $chan] 0 [expr [string first "| Next War:" [topic $chan]] - 2]] } } { set topic [topic $chan] } set topic "$topic | [clanavail_bold "Next War: $clanavail_users(/warinfo) Available: $avail Not Available: $navail Maybe Available: $maybe."]" } if {[string compare [topic $chan] $topic] != 0} { putserv "TOPIC $chan :$topic" } } } proc clanavail_bold {text} { if {$::clanavail_setting(bold)} { regsub -all -- " Not Available: " $text " \002Not Available:\002 " text regsub -all -- " Maybe Available: " $text " \002Maybe Available:\002 " text regsub -all -- " Available: " $text " \002Available:\002 " text regsub -all -- "Next War: " $text "\002Next War:\002 " text } return $text } proc clanavail_getavail {} { global clanavail_users foreach a [array names clanavail_users] { if {[string match $a /warinfo]} { continue } switch -- $clanavail_users($a) { "avail" { lappend avail $a, } "navail" { lappend navail $a, } "maybe" { lappend maybe $a, } } } foreach v {avail navail maybe} { if {![info exists $v]} { set $v None } } regsub -all -- "," [lindex $avail end] "" end regsub -all -- "," [lindex $navail end] "" end2 regsub -all -- "," [lindex $maybe end] "" end3 return "[list [lreplace $avail end end $end] [lreplace $navail end end $end2] [lreplace $maybe end end $end3]]" } putlog "\002CLANAVAIL:\002 ClanAvail.tcl Version 1.4 by Wcc is loaded."