quote.disabled (4215B)
1 $::maintype sendUid $::sock($::cs(netname)) "Q" "quoteserv" "services." "services." 107 "Quote Storage Services" 2 foreach {chan is} [nda get "quoteserv/regchan"] { 3 if {1!=$is} {continue} 4 $::maintype putjoin $::sock($::cs(netname)) 107 [::base64::decode [string map {[ /} $chan]] [nda get "regchan/$chan/ts"] 5 tnda set "channels/$chan/ts" [nda get "regchan/$chan/$::netname($::sock($::cs(netname)))/ts"] 6 } 7 bind $::sock($::cs(netname)) request "q" "-" quoteservjoin 8 bind $::sock($::cs(netname)) request "quoteserv" "-" quoteservjoin 9 bind $::sock($::cs(netname)) pub "-" "!quote" quoteservdo 10 bind $::sock($::cs(netname)) pub "-" "!q" quoteservdo 11 12 proc quoteservjoin {chan msg} { 13 set ndacname [string map {/ [} [::base64::encode [string tolower $chan]]] 14 $::maintype putjoin $::sock($::cs(netname)) 107 $chan [nda get "regchan/$ndacname/ts"] 15 nda set "quoteserv/regchan/$ndacname" 1 16 } 17 18 proc quoteservenabled {chan} { 19 set ndacname [string map {/ [} [::base64::encode [string tolower $chan]]] 20 return [nda get "quoteserv/regchan/$ndacname"] 21 } 22 23 proc quoteservdo {chan msg} { 24 set ndacname [string map {/ [} [::base64::encode [string tolower $chan]]] 25 if {![quoteservenabled $chan]} {return} 26 # Q isn't in channel, no need to check quotes 27 set from [lindex $msg 0 0] 28 set subcmd [lindex $msg 1 0] 29 set para [lrange [lindex $msg 1] 1 end] 30 switch -nocase -glob -- $subcmd { 31 "sea*" { 32 set ptn "*[join $para " "]*" 33 set qts [quotesearch $chan $ptn] 34 if {[llength $qts]} {$::maintype privmsg $::sock($::cs(netname)) 107 $chan "\[\002Quotes\002\] Found quotes numbered #[join $qts ",#"]"} { 35 $::maintype privmsg $::sock($::cs(netname)) 107 $chan "\[\002Quotes\002\] No quotes found for pattern" 36 } 37 } 38 "vi*1st*ma*" { 39 set ptn "*[join $para " "]*" 40 set qts [quotesearch $chan $ptn] 41 if {[llength $qts]} {set qtn [lindex $qts 0];$::maintype privmsg $::sock($::cs(netname)) 107 $chan "\[\002Quotes\002\] Quote number #$qtn:";$::maintype privmsg $::sock($::cs(netname)) 107 $chan "\[\002Quotes\002\] [nda get "quoteserv/quotes/$ndacname/$qtn"]"} { 42 $::maintype privmsg $::sock($::cs(netname)) 107 $chan "\[\002Quotes\002\] No quotes found for pattern" 43 } 44 } 45 "ad*" { 46 set qt [join $para " "] 47 set qtn [expr {([llength [nda get "quoteserv/quotes/$ndacname"]]/2)+3}] 48 nda set "quoteserv/quotes/$ndacname/$qtn" $qt 49 $::maintype privmsg $::sock($::cs(netname)) 107 $chan "\[\002Quotes\002\] Added quote number #$qtn to database." 50 } 51 "de*" { 52 set qtn "[lindex $para 0]" 53 if {![string is integer $qtn]} {$::maintype privmsg $::sock($::cs(netname)) 107 $chan "\[\002Quotes\002\] Please use a valid integer (without the #)"} 54 if {150>[nda get "regchan/$ndacname/levels/[string tolower [tnda get "login/$::netname($::sock($::cs(netname)))/$from"]]"]} {$::maintype privmsg $::sock($::cs(netname)) 107 $chan "\[\002Quotes\002\] Check your privilege."} 55 nda set "quoteserv/quotes/$ndacname/$qtn" "" 56 $::maintype privmsg $::sock($::cs(netname)) 107 $chan "\[\002Quotes\002\] Blanked quote number #$qtn in database." 57 } 58 "vi*" { 59 set qtn "[lindex $para 0]" 60 if {![string is integer $qtn]} {$::maintype privmsg $::sock($::cs(netname)) 107 $chan "\[\002Quotes\002\] Please use a valid integer (without the #)"} 61 set qt [nda get "quoteserv/quotes/$ndacname/$qtn"] 62 if {$qt != ""} { 63 $::maintype privmsg $::sock($::cs(netname)) 107 $chan "\[\002Quotes\002\] Quote number #$qtn:" 64 $::maintype privmsg $::sock($::cs(netname)) 107 $chan "\[\002Quotes\002\] $qt" 65 } 66 } 67 "he*" { 68 set helpfile { ---- Quotes Help ---- 69 !quote search - Search for quotes matching 70 !quote view1stmatch - Search for quotes matching and view first matching quote. 71 !quote view - View quote 72 !quote add - Add quote. 73 !quote del - Delete quote. Requires halfops or above. 74 End of help for Q.} 75 foreach {helpline} [split $helpfile "\r\n"] { 76 $::maintype notice $::sock($::cs(netname)) 107 $from $helpline 77 } 78 } 79 } 80 } 81 82 proc quotesearch {chan pattern} { 83 set ndacname [string map {/ [} [::base64::encode [string tolower $chan]]] 84 set ret [list] 85 foreach {qnum qvalue} [nda get "quoteserv/quotes/$ndacname"] { 86 if {[string match -nocase $pattern $qvalue]} {lappend ret $qnum} 87 } 88 return $ret 89 } 90