Searches Beachcreeps.com for funny images/stories.
This script was requested by bourneident.
Credit for the idea goes to bourneident.
Using the script::
channel)
;BeachCreeps search script by Ford_Lawnmower irc.geekshed.net #Script-Help
;Script Idea and Request by bourneident.
;;;;;Edit the 3 alias's below to adjust the logo, text color and link color ;;;;;;;
alias -l w.logo return 04B07e06a09c13h04C07r07e06e09p13s06
alias -l w.textcolor return 04
alias -l w.linkcolor return
;;;;;End of edit area;;;;;;;;
menu Channel,Status {
.$iif($group(#BeachCreep) == On,$style(1)) BeachCreep Trigger
..$iif($group(#BeachCreep) == On,$style(2)) On: .enable #BeachCreep
..$iif($group(#BeachCreep) == Off,$style(2)) Off: .disable #BeachCreep
}
#BeachCreep on
On $*:Text:/^(\+|-|!|@)BeachCreep[s]?.*/Si:#: {
var %action $regml(1)
if (%action isin +-) && ($regex($nick($chan,$nick).pnick,/(!|~|&|@)/)) {
if (%action == +) {
if ($istok(%BeachCreepChanList,$+($network,$chan),32)) { .msg $chan $nick $chan is already running the BeachCreep script }
else {
.enable #BeachCreep
Set %BeachCreepChanList $addtok(%BeachCreepChanList,$+($network,$chan),32)
.msg $chan $nick has activated the BeachCreep script for $chan .
}
}
else {
if (!$istok(%BeachCreepChanList,$+($network,$chan),32)) { .msg $chan $nick $chan is not running the BeachCreep script }
else {
Set %BeachCreepChanList $remtok(%BeachCreepChanList,$+($network,$chan),1,32)
.msg $chan $nick has deactivated the BeachCreep script for $chan .
}
}
}
elseif (!$timer($+(BeachCreep,$network,$nick))) && ($istok(%BeachCreepChanList,$+($network,$chan),32)) {
.timer $+ $+(BeachCreep,$network,$nick) 1 6 noop
var %method $iif(%action == !,.notice $nick,$iif($regex($nick($chan,$nick).pnick,/(!|~|&|@|%|\+)/),.msg $chan,.notice $nick))
GetBeachCreep %method $2-
}
}
#BeachCreep end
alias BeachCreep { GetBeachCreep echo -a $1- }
alias -l GetBeachCreep {
$1-2 Searching........
var %sockname $+(BeachCreep,$network,$2,$ticks)
sockopen %sockname www.beachcreeps.com 80
sockmark %sockname $1-2 $+(/?s=,$replace($strip($3-),$chr(32),+)) 0
}
On *:sockopen:BeachCreep*: {
if (!$sockerr) {
sockwrite -nt $sockname GET $gettok($sock($sockname).mark,3,32) HTTP/1.0
sockwrite -n $sockname Host: www.beachcreeps.com
sockwrite -n $sockname $crlf
}
else { sockclose $sockname | return }
}
On *:sockread:BeachCreep*: {
if ($sockerr) { echo -st Socket Error $nopath($script) | sockclose $sockname | return }
else {
var %BeachCreep | sockread %BeachCreep
if ($regex(found,%BeachCreep,/<h2><a href="([^"]*)" rel="bookmark" title="Permanent Link to ([^"<]*)">/i)) {
put $gettok($sock($sockname).mark,1-2,32) $w.logo $w.textcolor $utf8fix($regml(found,2)) $w.linkcolor $regml(found,1)
}
elseif (<p>No posts found.</p> isin %BeachCreep) {
put $gettok($sock($sockname).mark,1-2,32) $w.logo $w.textcolor Nothing found! Please refine your search and try again!
sockclose $sockname
}
elseif (</html> isin %BeachCreep) sockclose $sockname
}
}
alias -l Put {
if (!$regex($1,/(\.|^)(msg|notice|echo)$/Si)) || (!$3) { echo -st **Put error** Syntax /Put msg #channel text - or - /Put notice nickname text | return }
tokenize 32 $regsubex($1-,/([$\|%\[\]\}\{][^\s]*)/g,$+($chr(2),$chr(2),\t))
var %tokens $0, %Tstart 3, %Dtimer 1500
if ($timer($+(Put,$2,$network)).secs) { %Dtimer = $calc($v1 * 1000) }
while ($len($($+($,%Tstart,-,%tokens),2)) > 430) {
dec %tokens
if ($len($($+($,%Tstart,-,%tokens),2)) <= 430) {
.timer -m 1 %Dtimer $1-2 $($+($,%Tstart,-,%tokens),2))
inc %Dtimer 1500
%Tstart = $calc(%tokens + 1)
%tokens = $0
}
}
.timer -m 1 %Dtimer $1-2 $($+($,%Tstart,-,%tokens),2))
.timer $+ $+(Put,$2,$network) -m 1 $calc(%Dtimer + 1500) noop
}
alias -l utf8fix return $replace($regsubex($1-,/&#([\d]{2,4});/g,$utf8(\t)),&,&)
alias -l UTF8 {
if ($version >= 7) return $chr($1)
else {
var %x $base($1,10,2),%y $len(%x)
if ($1 < 161) { return $chr($1) }
elseif (%y < 12) { return $+($shift(11000000,$left(%x,-6)),$shift(10000000,$right(%x,6))) }
elseif (%y < 17) { return $+($shift(11100000,$left(%x,-12)),$shift(10000000,$mid(%x,-12,6)),$shift(10000000,$right(%x,6))) }
elseif (%y < 22) {
return $+($shift(11110000,$left(%x,-18)),$shift(10000000,$mid(%x,$iif(%y < 18,$+(-,%y),-18),6)),$shift(10000000,$mid(%x,-12,6)),$shift(10000000,$right(%x,6)))
}
}
}
alias -l shift {
if ($2) { return $chr($base($+($left($1,$+(-,$len($2))),$2),2,10)) }
else { return $chr($base($1,2,10)) }
}
I can find no issues with this script:
[14:08:13] <@Ford_Lawnmower> +beachcreeps
[14:08:13] Ford_Lawnmower has activated the BeachCreep script for #FordIRC .
[14:08:24] <@Ford_Lawnmower> @beachcreeps dog
[14:08:24] Searching........
[14:08:26] BeachCreeps Give a Dog a Bone http://www.beachcreeps.com/give-a-dog-a-bone-2/
[14:08:27] BeachCreeps The Night Shift http://www.beachcreeps.com/the-night-shift/
[14:08:28] BeachCreeps Babes of the Day: ButtherFace http://www.beachcreeps.com/buttherface/
[14:08:29] BeachCreeps The Batman http://www.beachcreeps.com/the-batman/