Website Advisor for Eggdrop
Platform: TCL
Published Jun 05, 2012
Updated Jun 05, 2012
This is a tcl script for eggdrop. Not for mIRC!
This Script uses McAfee SiteAdvisor to check posted links for problems.
Links will Return:
- Safe = No Problems found.
- Warning = Security risks have been reported by trusted users.
- Danger = Suspicious behavior has been reported by trusted users.
- No Result = Site unresponsive or not yet indexed by McAfee.
Loading:
- Save this code to a file called advisor.tcl
- Place the file in your eggdrop scripts directory
- Add this line to eggdrop.conf -->> source scripts/advisor.tcl
- Rehash or restart your eggdrop
- (In the console) type .chanset #channelname +advisor "where #channelname is the channel you want the script on in"
See the setup at the top of the script.
All of the output can be changed, including turning off "safe" links.
Screen:
##############################################################################################
## ## advisor.tcl for eggdrop by Ford_Lawnmower irc.geekshed.net #Script-Help ## ##
##############################################################################################
## To use this script you must set channel flag +advisor (ie .chanset #chan +advisor) ##
##############################################################################################
##############################################################################################
## ## Start Setup. ## ##
##############################################################################################
namespace eval advisor {
## Edit safelogo to change the logo for sites that return a value of safe ## ##
variable safelogo "\017\00300,03\002Safe\017"
## Edit safetext to change the text shown when a site returns a value of safe ## ##
variable safetext "No problems found with\017"
## Edit warninglogo to change the logo for sites that return a warning ## ##
variable warninglogo "\017\00301,08\002Caution\017"
## Edit warningtext to change the text shown when a site returns a warning ## ##
variable warningtext "Found potential suspicious behavior on\017"
## Edit dangerlogo to change the logo shown when a site returns danger ## ##
variable dangerlogo "\017\00300,04\002Danger\017"
## Edit dangertext to change the text shown when a site returns danger ## ##
variable dangertext "Found potential security risks with\017"
## showsafe, showwarning & showdanger can be turned on or off by changing the value. ## ##
## Use lowercase letters only for this setting. ## ##
variable showsafe "on"
variable showwarning "on"
variable showdanger "on"
## Edit sitecolor to change the color that the sitename will be displayed in ## ##
variable sitecolor "\017\002"
##############################################################################################
## ## End Setup. ## ##
##############################################################################################
setudef flag advisor
bind pubm -|- "*" advisor::main
}
proc advisor::main {nick host hand chan text} {
if {[lsearch -exact [channel info $chan] +advisor] != -1} {
set text [strip $text]
if {[regexp {(www\.|http\x3A\x2F\x2F)([^\s]+)} $text]} {
set counter 1
set text [regexp -all -inline {(www\.|http\x3A\x2F\x2F)([^\s]+)} $text]
foreach i $text {
if {$counter == 3} {
resolve $nick $host $hand $chan $i
set counter 0
}
incr counter
}
}
}
}
proc advisor::check {nick host hand chan site} {
set advisorsite "www.siteadvisor.com"
set advisorurl "/sites/${site}"
if {[catch {set advisorsock [socket -async $advisorsite 80]} sockerr]} {
putserv "PRIVMSG $chan :$advisorsite $advisorurl $sockerr error"
return 0
} else {
puts $advisorsock "GET $advisorurl HTTP/1.0"
puts $advisorsock "Host: $advisorsite"
puts $advisorsock "User-Agent: Opera 9.6"
puts $advisorsock ""
flush $advisorsock
while {![eof $advisorsock]} {
set advisorvar " [gets $advisorsock] "
if {[string match "*class=\"siteGreen\"*" $advisorvar] && $advisor::showsafe == "on"} {
putserv "PRIVMSG $chan : $advisor::safelogo $advisor::safetext ${advisor::sitecolor}${site} $advisor::safelogo"
} elseif {[string match "*class=\"siteYellow\"*" $advisorvar] && $advisor::showwarning == "on"} {
putserv "PRIVMSG $chan : $advisor::warninglogo $advisor::warningtext ${advisor::sitecolor}${site} $advisor::warninglogo"
} elseif {[string match "*class=\"siteRed\"*" $advisorvar] && $advisor::showdanger == "on"} {
putserv "PRIVMSG $chan : $advisor::dangerlogo $advisor::dangertext ${advisor::sitecolor}${site} $advisor::dangerlogo"
}
}
}
}
proc advisor::resolve {nick host hand chan site} {
set resolveurl "/"
regexp {([^\/]*)} [string map {\xf ""} $site] match resolvesite
regexp {(\/.*)} [string map {\xf ""} $site] match resolveurl
if {[catch {set resolvesock [socket -async $resolvesite 80]} sockerr]} {
return 0
} else {
puts $resolvesock "GET $resolveurl HTTP/1.0"
puts $resolvesock "Host: $resolvesite"
puts $resolvesock "User-Agent: Opera 9.6"
puts $resolvesock ""
flush $resolvesock
while {![eof $resolvesock]} {
set resolvevar " [gets $resolvesock] "
if {[regexp -nocase {http\/1\.[0-9]\s([0-9]{3})} $resolvevar match code]} {
if {$code != "301"} {
check $nick $host $hand $chan $resolvesite
break
return 0
}
} elseif {[regexp -nocase {Location:\s(.*)} $resolvevar match redirect]} {
regexp {:\/\/([^\/]*)} $redirect match resolvesite
check $nick $host $hand $chan $resolvesite
break
return 0
} elseif {[regexp {<html} $resolvevar]} {
check $nick $host $hand $chan $resolvesite
break
return 0
}
}
}
}
proc advisor::strip {text} {
regsub -all -- {\017|\015|\031|\002|\037|\026|\003(\d{1,2})?(,\d{1,2})?} $text "" text
return $text
}
putlog "\002*Loaded* \002\00300,02Web Site Advisor\002\003 \002by Ford_Lawnmower irc.GeekShed.net #Script-Help"