commit 6113145b61d8497597336b7d52f9912dae605e56
parent 2c5a0a044402e3fc6b9025ef271c0fa446942e83
Author: Jaffa Cake <j4jackj@template.hostname>
Date: Fri, 8 Aug 2014 19:47:51 -0400
Added loads of functions... don't ask
Diffstat:
6 files changed, 514 insertions(+), 18 deletions(-)
diff --git a/core/0001-p10.tcl b/core/0001-p10.tcl
@@ -3,7 +3,7 @@ proc sendUid {sck nick ident host dhost uid {realname "* Unknown *"}} {
set sendid [b64e $uid]
set sendnn [string repeat "A" [expr {3-[string length $sendid]}]]
append sendnn $sendid
- set sl [format "%s N %s 1 %s %s %s +oikd AAAAAA %s%s :%s" $sid $nick [clock format [clock seconds] -format %s] $ident $host $sid $sendnn $realname]
+ set sl [format "%s N %s 1 %s %s %s +oik AAAAAA %s%s :%s" $sid $nick [clock format [clock seconds] -format %s] $ident $host $sid $sendnn $realname]
tnda set "intclient/${sid}${sendnn}" $uid
puts $sck $sl
puts stdout $sl
@@ -17,6 +17,14 @@ proc privmsg {sck uid targ msg} {
puts $sck [format "%s%s P %s :%s" $sid $sendnn $targ $msg]
}
+proc kick {sck uid targ tn msg} {
+ global sid
+ set sendid [b64e $uid]
+ set sendnn [string repeat "A" [expr {3-[string length $sendid]}]]
+ append sendnn $sendid
+ puts $sck [format "%s%s K %s %s :%s" $sid $sendnn $targ $tn $msg]
+}
+
proc notice {sck uid targ msg} {
global sid
set sendid [b64e $uid]
@@ -53,12 +61,12 @@ proc putjoin {sck uid targ ts} {
set sendnn [string repeat "A" [expr {3-[string length $sendid]}]]
append sendnn $sendid
puts $sck [format "%s B %s %s %s%s:o" $sid $targ $ts $sid $sendnn]
+ puts stdout [format "%s B %s %s %s%s:o" $sid $targ $ts $sid $sendnn]
+
}
proc callbind {type client comd args} {
- if {""!=[tnda get "binds/$type/$client/$comd"]} {[tnda get "binds/$type/$client/$comd"] [lindex $args 0] [lrange $args 1 end]} {
- puts stdout "bind called $type $client $comd but no one to send it to!"
- }
+ if {""!=[tnda get "binds/$type/$client/$comd"]} {[tnda get "binds/$type/$client/$comd"] [lindex $args 0] [lrange $args 1 end]}
}
proc p10-main {sck} {
@@ -69,16 +77,28 @@ proc p10-main {sck} {
set gotsplitwhere [string first " :" $line]
if {$gotsplitwhere==-1} {set comd [split $line " "]} {set comd [split [string range $line 0 [expr {$gotsplitwhere - 1}]] " "]}
set payload [split [string range $line [expr {$gotsplitwhere + 2}] end] " "]
- puts stdout [join $comd "<->"]
+ puts stdout [join $comd " "]
switch -nocase -- [lindex $comd 1] {
"P" {
if {[string index [lindex $comd 2] 0] == "#"} {
set client chan
+ callbind pub "-" [string tolower [lindex $payload 0]] [lindex $comd 2] [lindex $comd 0] [lrange $payload 1 end]
+ callbind evnt "-" "chanmsg" [lindex $comd 0] [lindex $comd 2] [lrange $payload 0 end]
} {
set client [tnda get "intclient/[lindex $comd 2]"]
+ callbind msg $client [string tolower [lindex $payload 0]] [lindex $comd 0] [lrange $payload 1 end]
}
+ }
- callbind msg $client [string tolower [lindex $payload 0]] [lindex $comd 0] [lrange $payload 1 end]
+ "O" {
+ if {[string index [lindex $comd 2] 0] == "#"} {
+ set client chan
+ callbind pubnotc "-" [string tolower [lindex $payload 0]] [lindex $comd 2] [lindex $comd 0] [lrange $payload 1 end]
+ callbind pubnotc-m "-" [string tolower [lindex $payload 0]] [lindex $comd 2] [lindex $comd 0] [lrange $payload 1 end]
+ } {
+ set client [tnda get "intclient/[lindex $comd 2]"]
+ callbind notc $client [string tolower [lindex $payload 0]] [lindex $comd 0] [lrange $payload 1 end]
+ }
}
"M" {
@@ -105,6 +125,8 @@ proc p10-main {sck} {
"C" {
callbind create "-" "-" [lindex $comd 2] [lindex $comd 0]
+ set chan [string map {/ [} [::base64::encode [string tolower [lindex $comd 2]]]]
+ tnda set "channels/$chan/ts" [lindex $comd 3]
}
"OM" {
@@ -130,10 +152,14 @@ proc p10-main {sck} {
}
"B" {
+ puts $sck "$sid EB"
set chan [string map {/ [} [::base64::encode [string tolower [lindex $comd 2]]]]
puts stdout "$chan"
if {[string index [lindex $comd 4] 0] == "+"} {
set four 5
+ if {[string match "*l*" [lindex $comd 4]]} {incr four}
+ if {[string match "*L*" [lindex $comd 4]]} {incr four}
+ if {[string match "*k*" [lindex $comd 4]]} {incr four}
} {
set four 4
}
@@ -143,13 +169,21 @@ proc p10-main {sck} {
set un [lindex $n 0]
set uo [lindex $n 1]
if {""!=$uo} {tnda set "channels/$chan/modes/$un" $uo}
+ callbind join "-" "-" [lindex $comd 2] $un
}
}
+ "J" {
+ callbind join "-" "-" [lindex $comd 2] [lindex $comd 0]
+ }
+
+ "L" {
+ callbind part "-" "-" [lindex $comd 2] [lindex $comd 0]
+ }
+
"EB" {
puts $sck "$sid EA"
- puts $sck "$sid EB"
}
"N" {
@@ -224,9 +258,9 @@ proc p10-burst {sck} {
set sid [string repeat "A" [expr {2-[b64e $::numeric]}]]
append sid [b64e $::numeric]
puts $sck "PASS :$password"
- puts $sck "SERVER $servername 0 [clock format [clock seconds] -format %s] [clock format [clock seconds] -format %s] J10 $sid\]\]\] +s :Services for IRC Networks"
+ puts $sck "SERVER $servername 0 [clock format [clock seconds] -format %s] [clock format [clock seconds] -format %s] J10 $sid\]\]\] 0 :Services for IRC Networks"
puts stdout "PASS :$password"
- puts stdout "SERVER $servername 0 [clock format [clock seconds] -format %s] [clock format [clock seconds] -format %s] J10 $sid\]\]\] +s :Services for IRC Networks"
+ puts stdout "SERVER $servername 0 [clock format [clock seconds] -format %s] [clock format [clock seconds] -format %s] J10 $sid\]\]\] 0 :Services for IRC Networks"
}
diff --git a/modules/0001-chanserv.tcl b/modules/0001-chanserv.tcl
@@ -2,8 +2,13 @@ source chanserv.conf
sendUid $sock $cs(nick) $cs(ident) $cs(host) $cs(host) 77 "Channels Server"
bind msg 77 "register" regchan
bind msg 77 "adduser" adduserchan
+bind msg 77 "users" lsuchan
+bind msg 77 "lsu" lsuchan
#bind msg 77 "deluser" deluserchan
bind msg 77 "up" upchan
+bind pub "-" "@up" upchanfant
+bind pub "-" "@rand" randfant
+bind pub "-" "@request" requestbot
bind msg 77 "down" downchan
bind msg 77 "hello" regnick
bind msg 77 "chpass" chpassnick
@@ -13,9 +18,71 @@ bind mode "-" "+" checkop
bind mode "-" "-" checkdeop
bind create "-" "-" checkcreate
+proc randfant {cname msg} {
+ set from [lindex $msg 0 0]
+ set froni [tnda get "nick/$from"]
+ if {![string is integer [lindex $msg 1 0]] ||![string is integer [lindex $msg 1 1]]} {return}
+ if {(""==[lindex $msg 1 0]) || (""==[lindex $msg 1 1])} {return}
+ if {[lindex $msg 1 0] == [lindex $msg 1 1]} {privmsg $::sock 77 $cname "\002$froni:\002 Your request would have caused a divide by zero and was not processed.";return}
+ privmsg $::sock 77 $cname "\002$froni:\002 Your die rolled [rand [lindex $msg 1 0] [lindex $msg 1 1]]"
+}
+
+proc lsuchan {from msg} {
+ set cname [lindex $msg 0 0]
+ set ndacname [string map {/ [} [::base64::encode [string tolower $cname]]]
+ if {[string length [nda get "regchan/$ndacname"]] == 0} {
+ notice $::sock 77 $from "You fail at life."
+ notice $::sock 77 $from "Channel does not exist."
+ return
+ }
+ set xses [nda get "regchan/$ndacname/levels"]
+ notice $::sock 77 $from "Access | Username"
+ notice $::sock 77 $from "-------+------------"
+ foreach {nick lev} $xses {
+ if {$lev == 0} {continue}
+ # Case above? User not actually on access list
+ set nl [format "%3d" $lev]
+ notice $::sock 77 $from " $nl | $nick"
+ }
+ notice $::sock 77 $from "-------+------------"
+ notice $::sock 77 $from " | End of access list"
+}
+
+proc upchanfant {cname msg} {
+ set from [lindex $msg 0 0]
+ if {""==[tnda get "login/$from"]} {notice $::sock 77 $from "You fail at life.";return}
+ set ndacname [string map {/ [} [::base64::encode [string tolower $cname]]]
+ if {1>[nda get "regchan/$ndacname/levels/[string tolower [tnda get "login/$from"]]"]} {
+ privmsg $::sock 77 $cname "You fail at life."
+ privmsg $::sock 77 $cname "Channel not registered to you."
+ return
+ }
+ set lev [nda get "regchan/$ndacname/levels/[string tolower [tnda get "login/$from"]]"]
+ set sm "+"
+ set st ""
+ if {$lev >= 1} {set sm "v"}
+ if {$lev >= 150} {set sm "h"}
+ if {$lev >= 200} {set sm "o"}
+ putmode $::sock 77 $cname $sm $from [tnda get "channels/$ndacname/ts"]
+}
+
+proc requestbot {cname msg} {
+ set from [lindex $msg 0 0]
+ set bot [lindex $msg 1 0]
+ if {""==[tnda get "login/$from"]} {notice $::sock 77 $from "You fail at life.";return}
+ set ndacname [string map {/ [} [::base64::encode [string tolower $cname]]]
+ if {150>[nda get "regchan/$ndacname/levels/[string tolower [tnda get "login/$from"]]"]} {
+ privmsg $::sock 77 $cname "You fail at life."
+ privmsg $::sock 77 $cname "You must be at least halfop to request $bot."
+ return
+ }
+ callbind request [string tolower $bot] "-" $cname
+}
+
foreach {chan _} [nda get "regchan"] {
putjoin $::sock 77 [::base64::decode [string map {[ /} $chan]] [nda get "regchan/$chan/ts"]
- tnda set "channels/$chan/ts" [tnda get "channels/$chan/ts"]
+ tnda set "channels/$chan/ts" [nda get "regchan/$chan/ts"]
+ putmode $::sock 77 [::base64::decode [string map {[ /} $chan]] "+nt" "" [nda get "regchan/$chan/ts"]
}
proc checkop {mc ftp} {
@@ -48,7 +115,8 @@ proc chanhelp {from msg} {
notice $::sock 77 $from "to registered channels."
notice $::sock 77 $from " -!- Commands available -!-"
notice $::sock 77 $from "register <channel> - Register a channel to your username. "
- notice $::sock 77 $from "up <channel> - Ops you if you have level on the channel for this username."
+ notice $::sock 77 $from "adduser <channel> <user name> <add level> - Add a username to the channel access list."
+ notice $::sock 77 $from "up <channel> - (@up) Ops you if you have level on the channel for this username."
notice $::sock 77 $from "down <channel> - Removes all channel user modes affecting your nick."
notice $::sock 77 $from "hello <username> <password> - Register a username."
notice $::sock 77 $from "login <username> <password> - Log in to a username."
@@ -72,6 +140,7 @@ proc regchan {from msg} {
nda set "regchan/$ndacname/levels/[tnda get "login/$from"]" 500
nda set "regchan/$ndacname/ts" [tnda get "channels/$ndacname/ts"]
putjoin $::sock 77 $cname [tnda get "channels/$ndacname/ts"]
+ callbind "reg" "-" "-" $cname [tnda get "channels/$ndacname/ts"]
}
proc adduserchan {from msg} {
@@ -80,12 +149,12 @@ proc adduserchan {from msg} {
set adduser [lindex $msg 0 1]
set addlevel [lindex $msg 0 2]
set ndacname [string map {/ [} [::base64::encode [string tolower $cname]]]
- if {![string is -integer $addlevel]} {return}
+ if {![string is integer $addlevel]} {return}
if {$addlevel > [nda get "regchan/$ndacname/levels/[tnda get "login/$from"]"]} {notice $::sock 77 $from "You can't do that; you're not the channel's Dave";return}
if {[nda get "regchan/$ndacname/levels/$adduser"] > [nda get "regchan/$ndacname/levels/[tnda get "login/$from"]"]} {notice $::sock 77 $from "You can't do that; the person you're changing the level of is more like Dave than you.";return}
if {$adduser == [tnda get "login/$from"]} {notice $::sock 77 $from "You can't change your own level, even if you're downgrading. Sorreh :/";return}
notice $::sock 77 $from "Guess what? :) User added."
- nda set "regchan/$ndacname/levels/$adduser" $addlevel
+ nda set "regchan/$ndacname/levels/[string tolower $adduser]" $addlevel
}
proc upchan {from msg} {
@@ -93,17 +162,17 @@ proc upchan {from msg} {
if {""==[tnda get "login/$from"]} {notice $::sock 77 $from "You fail at life.";return}
set cname [lindex $msg 0 0]
set ndacname [string map {/ [} [::base64::encode [string tolower $cname]]]
- if {1>[nda get "regchan/$ndacname/levels/[tnda get "login/$from"]"]} {
+ if {1>[nda get "regchan/$ndacname/levels/[string tolower [tnda get "login/$from"]]"]} {
notice $::sock 77 $from "You fail at life."
notice $::sock 77 $from "Channel not registered to you."
return
}
- set lev [nda get "regchan/$ndacname/levels/[tnda get "login/$from"]"]
+ set lev [nda get "regchan/$ndacname/levels/[string tolower [tnda get "login/$from"]]"]
set sm "+"
set st ""
- if {$lev > 1} {set sm "v"}
- if {$lev > 150} {set sm "h"}
- if {$lev > 200} {set sm "o"}
+ if {$lev >= 1} {set sm "v"}
+ if {$lev >= 150} {set sm "h"}
+ if {$lev >= 200} {set sm "o"}
putmode $::sock 77 $cname $sm $from [tnda get "channels/$ndacname/ts"]
}
@@ -118,6 +187,7 @@ proc regnick {from msg} {
}
nda set "usernames/[string tolower $uname]/password" [pwhash $pw]
setacct $::sock $from $uname
+ callbind evnt "-" "login" $from $uname
}
proc chpassnick {from msg} {
@@ -146,6 +216,7 @@ proc idnick {from msg} {
if {$ispw == [nda get "usernames/[string tolower $uname]/password"]} {
notice $::sock 77 $from "You have successfully logged in as $uname."
setacct $::sock $from $uname
+ callbind evnt "-" "login" $from $uname
} {
notice $::sock 77 $from "You cannot log in as $uname. You have the wrong password."
}
diff --git a/modules/0002-chanserv-thcserv.tcl b/modules/0002-chanserv-thcserv.tcl
@@ -0,0 +1,43 @@
+bind pub "-" "!lag" publag
+bind pub "-" "!weed" pubweed
+bind pub "-" "!coffee" pubcoffee
+bind notc 77 "ping" lagresp
+
+proc publag {cname msg} {
+ set from [lindex $msg 0 0]
+ privmsg $::sock 77 $from "\001PING [clock clicks -milliseconds] $cname \001"
+}
+
+proc pubcoffee {cname msg} {
+ switch [expr {int(rand()*4)}] {
+ 0 {privmsg $::sock 77 $cname "\001ACTION hands [lindex $msg 1 0] a cup of espresso\001"}
+ 1 {privmsg $::sock 77 $cname "\001ACTION hands [lindex $msg 1 0] a cup of Latte\001"}
+ 2 {privmsg $::sock 77 $cname "\001ACTION hands [lindex $msg 1 0] a cup of instant coffee\001"}
+ 3 {privmsg $::sock 77 $cname "\001ACTION hands [lindex $msg 1 0] a cup of cappucino\001"}
+ }
+}
+
+proc pubweed {cname msg} {
+ set payload [lindex $msg 1 0]
+ switch [expr {int(rand()*4)}] {
+ 0 {
+ privmsg $::sock 77 $cname "\001ACTION packs a bowl of nugs and hands a bong to $payload\001"
+ }
+ 1 {
+ privmsg $::sock 77 $cname "\001ACTION rolls a joint and hands to $payload\001"
+ }
+ 2 {
+ privmsg $::sock 77 $cname "\001ACTION fills the hookah with dried nugs and hands to $payload\001"
+ }
+ 3 {
+ privmsg $::sock 77 $cname "\001ACTION passes $payload the vape pen\001"
+ }
+ }
+}
+
+proc lagresp {from msg} {
+ set ms [lindex $msg 0 0]
+ set chan [lindex $msg 0 1]
+ set ni [tnda get "nick/$from"]
+ privmsg $::sock 77 $chan "$ni, your lag is [expr {[clock clicks -milliseconds] - $ms}] milliseconds according to your client and our measurements."
+}
diff --git a/modules/0003-weather.tcl b/modules/0003-weather.tcl
@@ -0,0 +1,215 @@
+sendUid $::sock "W" "weather" "services." "services." 57 "Weather Services"
+foreach {chan is} [nda get "weather/regchan"] {
+ if {1!=$is} {continue}
+ putjoin $::sock 57 [::base64::decode [string map {[ /} $chan]] [nda get "regchan/$chan/ts"]
+ tnda set "channels/$chan/ts" [nda get "regchan/$chan/ts"]
+}
+bind request "w" "-" weatherjoin
+bind request "weather" "-" weatherjoin
+
+proc weatherjoin {chan msg} {
+ set ndacname [string map {/ [} [::base64::encode [string tolower $chan]]]
+ putjoin $::sock 57 $chan [nda get "regchan/$ndacname/ts"]
+ nda set "weather/regchan/$ndacname" 1
+}
+
+##############################################################################################
+## ## wunderground.tcl for eggdrop by Ford_Lawnmower irc.geekshed.net #Script-Help ## ##
+##############################################################################################
+## To use this script you must set channel flag +weather (ie .chanset #chan +weather) ##
+##############################################################################################
+##############################################################################################
+## ## Start Setup. ## ##
+##############################################################################################
+namespace eval wunderground {
+## Edit logo to change the logo displayed at the start of the line ## ##
+ variable logo "\017\00304\002W\00304u\00307n\00308d\00311e\00312r\00304g\00307r\00308o\00311u\00312n\00304d\017"
+## Edit textf to change the color/state of the text shown ## ##
+ variable textf "\017"
+## Edit tagf to change the color/state of the Tags: ## ##
+ variable tagf "\017\002"
+## Edit weatherline, line1, line2, line3, line4 to change what is displayed ## ##
+## weatherline is for the !weather trigger and line1-4 are for !forecast ## ##
+## Valid items are: location weatherstation conditions tempf tempc tempfc feelsf ## ##
+## feelsc feelsfc windgust windspeed winddirection sunset sunrise moon ## ##
+## day1 day2 day3 day4 day5 day6 day7 day8 day9 day10 ## ##
+## Do not remove any variables here! Just change them to "" to suppress display ## ##
+ variable line1 "location weatherstation conditions tempfc feelsfc windspeed winddirection windgust sunset sunrise moon"
+ variable line3 ""
+ variable line2 "day1 day2 day3 day4 day5 day6 day7 day8 day9 day10"
+ variable line4 ""
+ variable weatherline "location weatherstation conditions tempfc feelsfc windspeed winddirection windgust sunset sunrise moon day1 day2 day3"
+## Edit cmdchar to change the !trigger used to for this script ## ##
+ variable cmdchar "!"
+##############################################################################################
+## ## End Setup. ## ##
+##############################################################################################
+ bind pub "-" [string trimleft $wunderground::cmdchar]weather wunderground::tclservwe
+ bind pub "-" [string trimleft $wunderground::cmdchar]wz wunderground::tclservwe
+ bind pub "-" [string trimleft $wunderground::cmdchar]forecast wunderground::tclservfc
+}
+
+proc wunderground::tclservwe {cname msg} {
+ set nick [tnda get "nick/[lindex $msg 0 0]"]
+ set host "[tnda get "ident/[lindex $msg 0 0]"]@[tnda get "vhost/[lindex $msg 0 0]"]"
+ set comd "weather"
+ set hand ""
+ set text [join [lindex $msg 1] " "]
+ wunderground::main $comd $nick $host $hand $cname $text
+}
+
+proc wunderground::tclservfc {cname msg} {
+ set nick [tnda get "nick/[lindex $msg 0 0]"]
+ set host "[tnda get "ident/[lindex $msg 0 0]"]@[tnda get "vhost/[lindex $msg 0 0]"]"
+ set comd "forecast"
+ set hand ""
+ set text [join [lindex $msg 1] " "]
+ wunderground::main $comd $nick $host $hand $cname $text
+}
+
+proc wunderground::main {command nick host hand chan text} {
+ set search [strip $text]
+ set div ""; set moon ""; set sunset ""; set sunrise ""; set windspeed ""; set div ""
+ set winddirection ""; set location ""; set weatherstation ""; set temperature ""; set tempfc ""
+ set conditions ""; set feelslike ""; set feelsf ""; set feelsc ""; set city ""; set day ""
+ set details ""; set forc ""; set count 1; set tempf ""; set state_name ""; set tempc ""
+ set day1 ""; set day2 ""; set day3 ""; set day4 ""; set day5 ""; set state_name ""
+ set day6 ""; set day7 ""; set day8 ""; set day9 ""; set day10 ""; set windgust ""; set feelsfc ""
+ set wundergroundurl "/cgi-bin/findweather/hdfForecast?query=[urlencode $search]"
+ set wundergroundsite "www.wunderground.com"
+ if {"wz" == $command} {set command weather}
+ if {[catch {set wundergroundsock [socket -async $wundergroundsite 80]} sockerr]} {
+ return 0
+ } else {
+ puts $wundergroundsock "GET $wundergroundurl HTTP/1.0"
+ puts $wundergroundsock "Host: $wundergroundsite"
+ puts $wundergroundsock "User-Agent: Opera 9.6"
+ puts $wundergroundsock ""
+ flush $wundergroundsock
+ while {![eof $wundergroundsock]} {
+ set wundergroundvar " [gets $wundergroundsock] "
+ regexp -nocase {"(current)_observation":} $wundergroundvar match div
+ regexp -nocase {"(forecast)":} $wundergroundvar match div
+ regexp -nocase {"(astronomy)":} $wundergroundvar match div
+ if {[regexp -nocase {"city":"([^"]*)} $wundergroundvar match city]} {
+ if {$city == "null"} {
+ set city ""
+ }
+ } elseif {[regexp -nocase {"state_name":"([^"]*)} $wundergroundvar match state_name]} {
+ if {$state_name == "null"} {
+ set state_name ""
+ }
+ set location "${wunderground::tagf}Location: ${wunderground::textf}${city}, $state_name"
+ } elseif {[regexp -nocase {"name":"([^"]*)} $wundergroundvar match weatherstation]} {
+ set weatherstation "${wunderground::tagf}Station: ${wunderground::textf}${weatherstation}"
+ } elseif {$forc == "" && [regexp -nocase {class="wx-unit"> °(.*?)<\/span>} $wundergroundvar match forc]} {
+ } elseif {[regexp -nocase {"condition":"([^"]*)} $wundergroundvar match conditions]} {
+ set conditions "${wunderground::tagf}Conditions: ${wunderground::textf}${conditions}"
+ } elseif {$div == "current" && [regexp -nocase {"temperature":\s([^\,]*)} $wundergroundvar match temperature]} {
+ set tempf "${wunderground::tagf}Temperature: ${wunderground::textf}[forc ${temperature} $forc F] deg F"
+ set tempc "${wunderground::tagf}Temperature: ${wunderground::textf}[forc ${temperature} $forc C] deg C"
+ set tempfc "${wunderground::tagf}Temperature: ${wunderground::textf}[forc ${temperature} $forc F] deg F/[forc ${temperature} $forc C] deg C"
+ } elseif {$div == "current" && [regexp -nocase {"feelslike":\s([^\,]*)} $wundergroundvar match feelslike]} {
+ set feelsf "${wunderground::tagf}Feels Like: ${wunderground::textf}[forc ${feelslike} $forc F] deg F"
+ set feelsc "${wunderground::tagf}Feels Like: ${wunderground::textf}[forc ${feelslike} $forc C] deg C"
+ set feelsfc "${wunderground::tagf}Feels Like: ${wunderground::textf}[forc ${feelslike} $forc F] deg F/[forc ${feelslike} $forc C] deg C"
+ } elseif {$div == "current" && [regexp -nocase {"wind_speed":\s?([^\,]*)} $wundergroundvar match windspeed]} {
+ set windspeed "${wunderground::tagf}Wind speed: ${wunderground::textf}${windspeed}"
+ } elseif {$div == "current" && [regexp -nocase {"wind_gust_speed":\s?([^\,]*)} $wundergroundvar match windgust]} {
+ set windgust "${wunderground::tagf}Wind gust: ${wunderground::textf}${windgust}"
+ } elseif {[regexp -nocase {"wind_dir":"([^"]*)} $wundergroundvar match winddirection]} {
+ set winddirection "${wunderground::tagf}Wind Direction: ${wunderground::textf}${winddirection}"
+ } elseif {[regexp -nocase {id="cc-sun-rise">(.*?)</span>\s?<span class="ampm">(.*?)</span>} $wundergroundvar match sunrise ampm]} {
+ set sunrise "${wunderground::tagf}Sunrise: ${wunderground::textf}${sunrise}${ampm}"
+ } elseif {[regexp -nocase {id="cc-sun-set">(.*?)</span> <span class="ampm">(.*?)</span>} $wundergroundvar match sunset ampm]} {
+ set sunset "${wunderground::tagf}Sunset: ${wunderground::textf}${sunset}${ampm}"
+ } elseif {[regexp -nocase {id="cc-moon-phase".*">(.+?)<\/span>} $wundergroundvar match moon]} {
+ set moon "${wunderground::tagf}Moon: ${wunderground::textf}${moon}"
+ } elseif {$div == "forecast" && $command == "weather"} {
+ msg $chan $wunderground::logo ${wunderground::textf} [subst [regsub -all -nocase {(\S+)} $wunderground::weatherline {$\1}]]
+ close $wundergroundsock
+ return 0
+ } elseif {[regexp -nocase {<div\sclass="fctDayDate">(.+)\,} $wundergroundvar match day]} {
+ set day "${wunderground::tagf}${day}"
+ } elseif {[string match "forecast" $div]} {
+ if {[regexp -nocase {"weekday_short":\s?"([^"]*)} $wundergroundvar match day]} {
+ set day "${wunderground::tagf}${day}:->"
+ } elseif {[regexp -nocase {"high":\s([^\,]*)} $wundergroundvar match high]} {
+ set high "${wunderground::tagf}High:${wunderground::textf}[forc $high $forc F] deg F/[forc $high $forc C] deg C"
+ } elseif {[regexp -nocase {"low":\s([^\,]*)} $wundergroundvar match low]} {
+ set low "${wunderground::tagf}low:${wunderground::textf}[forc $low $forc F] deg F/[forc $low $forc C] deg C"
+ } elseif {[regexp -nocase {"condition":\s?"([^"]*)} $wundergroundvar match condition]} {
+ set condition "${wunderground::tagf}Cond:${wunderground::textf}${condition}"
+ } elseif {[regexp -nocase {"day":\s?\{} $wundergroundvar]} {
+ set day${count} "$day $high $low $condition"
+ incr count
+ }
+ } elseif {$div == "astronomy"} {
+ if {$wunderground::line1 != ""} {
+ msg $chan $wunderground::logo $wunderground::textf [subst [regsub -all -nocase {(\S+)} $wunderground::line1 {$\1}]]
+ }
+ if {$wunderground::line2 != ""} {
+ msg $chan $wunderground::logo $wunderground::textf [subst [regsub -all -nocase {(\S+)} $wunderground::line2 {$\1}]]
+ }
+ if {$wunderground::line3 != ""} {
+ msg $chan $wunderground::logo $wunderground::textf [subst [regsub -all -nocase {(\S+)} $wunderground::line3 {$\1}]]
+ }
+ if {$wunderground::line4 != ""} {
+ msg $chan $wunderground::logo $wunderground::textf [subst [regsub -all -nocase {(\S+)} $wunderground::line4 {$\1}]]
+ }
+ close $wundergroundsock
+ return 0
+ }
+ }
+ }
+}
+proc wunderground::forc {value fc forc} {
+ if {[string equal -nocase $fc $forc]} {
+ return $value
+ } elseif {[string equal -nocase "f" $fc]} {
+ if {[expr {(($value - 32) * 5)} == 0]} { return 0 }
+ return [format "%.1f" [expr {(($value - 32) * 5) / 9}]]
+ } elseif {[string equal -nocase "c" $fc]} {
+ if {$value == 0} { return 32 }
+ return [format "%.1f" [expr {(($value * 9) / 5) + 32}]]
+ }
+}
+proc wunderground::striphtml {string} {
+ return [string map {" \" < < &rt; >} [regsub -all {(<[^<^>]*>)} $string ""]]
+}
+proc wunderground::urlencode {string} {
+ regsub -all {^\{|\}$} $string "" string
+ return [subst [regsub -nocase -all {([^a-z0-9\+])} $string {%[format %x [scan "\\&" %c]]}]]
+}
+proc wunderground::strip {text} {
+ regsub -all {\002|\031|\015|\037|\017|\003(\d{1,2})?(,\d{1,2})?} $text "" text
+ return $text
+}
+proc wunderground::msg {chan logo textf text} {
+ set text [textsplit $text 50]
+ set counter 0
+ while {$counter <= [llength $text]} {
+ if {[lindex $text $counter] != ""} {
+ privmsg $::sock 57 $chan "${logo} ${textf}[string map {\\\" \"} [lindex $text $counter]]"
+ }
+ incr counter
+ }
+}
+proc wunderground::textsplit {text limit} {
+ set text [split $text " "]
+ set tokens [llength $text]
+ set start 0
+ set return ""
+ while {[llength [lrange $text $start $tokens]] > $limit} {
+ incr tokens -1
+ if {[llength [lrange $text $start $tokens]] <= $limit} {
+ lappend return [join [lrange $text $start $tokens]]
+ set start [expr $tokens + 1]
+ set tokens [llength $text]
+ }
+ }
+ lappend return [join [lrange $text $start $tokens]]
+ return $return
+}
+puts stdout "\002*Loaded* \00304\002W\00304u\00307n\00308d\00311e\00312r\00304g\00307r\00308o\00311u\00312n\00304d\017 \002by \
+Ford_Lawnmower irc.GeekShed.net #Script-Help"
diff --git a/modules/0004-limitserv.tcl b/modules/0004-limitserv.tcl
@@ -0,0 +1,49 @@
+sendUid $::sock "L" "limitserv" "services." "services." 47 "Channel Limit Adjustment Services"
+foreach {chan is} [nda get "limitserv/regchan"] {
+ if {1!=$is} {continue}
+ putjoin $::sock 47 [::base64::decode [string map {[ /} $chan]] [nda get "regchan/$chan/ts"]
+ tnda set "channels/$chan/ts" [nda get "regchan/$chan/ts"]
+}
+bind request "l" "-" limitservjoin
+bind request "limitserv" "-" limitservjoin
+bind join "-" "-" limitservup
+bind part "-" "-" limitservdown
+bind pub "-" "!dolimit" limitservdochan
+
+after 60000 {limitservdo}
+
+proc limitservup {chan msg} {
+ set ndacname [string map {/ [} [::base64::encode [string tolower $chan]]]
+ if {""==[tnda get "limitserv/$ndacname"]} {set i 1} {set i [expr {[tnda get "limitserv/$ndacname"] + 1}]}
+ tnda set "limitserv/$ndacname" $i
+}
+
+proc limitservdown {chan msg} {
+ set ndacname [string map {/ [} [::base64::encode [string tolower $chan]]]
+ if {""==[tnda get "limitserv/$ndacname"]} {set i 0} {set i [expr {[tnda get "limitserv/$ndacname"] - 1}]}
+ tnda set "limitserv/$ndacname" $i
+}
+
+proc limitservjoin {chan msg} {
+ set ndacname [string map {/ [} [::base64::encode [string tolower $chan]]]
+ putjoin $::sock 47 $chan [nda get "regchan/$ndacname/ts"]
+ nda set "limitserv/regchan/$ndacname" 1
+}
+
+proc limitservdo {} {
+ foreach {chan is} [nda get "limitserv/regchan"] {
+ if {1!=$is} {continue}
+ putmode $::sock 47 [::base64::decode [string map {[ /} $chan]] "+l" [expr {[tnda get "limitserv/$chan"] + 10}] [nda get "regchan/$chan/ts"]
+ }
+ after 60000 {limitservdo}
+}
+
+proc limitservdochan {cname msg} {
+ set chan [string map {/ [} [::base64::encode [string tolower $cname]]]
+ set from [lindex $msg 0 0]
+ if {150>[nda get "regchan/$chan/levels/[string tolower [tnda get "login/$from"]]"]} {
+ privmsg $::sock 47 $cname "You must be at least halfop to manually trigger autolimit on the channel."
+ return
+ }
+ putmode $::sock 47 $cname "+l" [expr {[tnda get "limitserv/$chan"] + 10}] [nda get "regchan/$chan/ts"]
+}
diff --git a/modules/trigserv.disabled b/modules/trigserv.disabled
@@ -0,0 +1,84 @@
+sendUid $::sock "T" "trigserv" "services." "services." 37 "Channel Spam Reduction and Trigger Services"
+#putmode $::sock 37 "T" "-d" "" ""
+foreach {chan is} [nda get "trigserv/regchan"] {
+ if {1!=$is} {continue}
+ putjoin $::sock 37 [::base64::decode [string map {[ /} $chan]] [nda get "regchan/$chan/ts"]
+ tnda set "channels/$chan/ts" [nda get "regchan/$chan/ts"]
+}
+bind request "t" "-" trigservjoin
+bind request "trigserv" "-" trigservjoin
+#bind join "-" "-" trigservup
+#bind part "-" "-" trigservdown
+bind pub "-" "!addtrig" trigservdochan
+bind evnt "-" "chanmsg" trigservtest
+
+proc ndaenc {n} {
+ return [string map {/ [} [::base64::encode [string tolower $n]]]
+}
+
+proc ndadec {n} {
+ return [::base64::decode [string map {[ /} $n]]
+}
+
+proc trigservjoin {chan msg} {
+ set ndacname [string map {/ [} [::base64::encode [string tolower $chan]]]
+ putjoin $::sock 37 $chan [nda get "regchan/$ndacname/ts"]
+ nda set "trigserv/regchan/$ndacname" 1
+}
+
+proc trigservdochan {cname msg} {
+ set chan [string map {/ [} [::base64::encode [string tolower $cname]]]
+ set from [lindex $msg 0 0]
+ set trigname [lindex $msg 1 0]
+ set trigtype [lindex $msg 1 1]
+ set trigcriteria [lindex $msg 1 2]
+ set trigaction [lrange [lindex $msg 1] 3 end]
+ if {200>[nda get "regchan/$chan/levels/[string tolower [tnda get "login/$from"]]"]} {
+ privmsg $::sock 37 $cname "You must be at least op to set a trigger on the channel."
+ return
+ }
+ nda set "trigserv/trig/$chan/[ndaenc $trigtype]/[ndaenc $trigname]/[ndaenc $trigcriteria]" $trigaction
+}
+
+proc trigservdecay {target} {
+ tnda set "trigserv/flood/$target" [expr {[tnda get "trigserv/flood/$target"] - 1}]
+}
+
+proc trigservincr {target} {
+ tnda set "trigserv/flood/$target" [expr {[tnda get "trigserv/flood/$target"] + 1}]
+}
+
+proc trigservtest {cname msg} {
+ set chan [string map {/ [} [::base64::encode [string tolower $cname]]]
+ set from [lindex $msg 0 0]
+ set trigcmd [lindex $msg 1 0]
+ set trigline [join [lrange [lindex $msg 1] 0 end] " "]
+ foreach {type _} [nda get "trigserv/trig/$chan"] {
+ foreach {tname _} [nda get "trigserv/trig/$chan/$type"] {
+ foreach {criterion action} [nda get "trigserv/trig/$chan/$type/$tname"] {
+ set crit [split [ndadec $criterion] ":"]
+ trigservcriterion $chan $type $tname $crit $action $trigcmd $trigline $from
+ }
+ }
+ }
+}
+
+proc trigservcriterion {chan type tname criterion action trigcmd trigline from} {
+ switch -nocase -- [lindex $criterion 0] {
+ "flood" {
+ trigservincr $chan
+ puts stdout [tnda get "trigserv/flood/$chan"]
+ after [expr {[lindex $criterion 2] * 1000}] trigservdecay $chan
+ if {[tnda get "trigserv/flood/$chan"] >= [lindex $criterion 1]} {
+ privmsg $::sock 37 [ndadec $chan] "Message flood detected; setting +mi for 60 seconds"
+ putmode $::sock 37 [ndadec $chan] "+mi" "" [tnda get "channels/$chan/ts"]
+ after 60000 {putmode $::sock 37 [ndadec $chan] "-mi" "" [tnda get "channels/$chan/ts"]}
+ }
+ }
+ "cmd" {
+ if {$trigcmd == [lindex $criterion 1]} {
+ privmsg $::sock 37 [ndadec $chan] [join [list "\002[tnda get "nick/$from"]\002:" $action] " "]
+ }
+ }
+ }
+}