I re-did this whole script. If you want the old version you can find it here -->> http://pastebin.com/f132547f7
Re-did Again - Old Version -->> http://pastebin.com/Kcb20Tck
Remade this script to be much more tolerant of typos and CASE errors.
Added google site search to assure a decent result ratio.
Added simple setup so you can change logo, colors, language, etc.
Added bread,bwrite operations to prevent data loss.
Example Output:
20:23:49 @wiki aerosmith
20:23:49 Wikipedia Searching For: aerosmith
20:23:52 Wikipedia Aerosmith is an American hard rock band sometimes referred to as "The Bad Boys from Boston" and "America's Greatest Rock and Roll Band". Their style which is rooted in blues-based hard rock has come to also incorporate elements of pop heavy metal and rhythm and blues and has inspired many subsequent rock artists. The band was formed in Boston Massachusetts in 1970. Guitarist
20:23:53 Joe Perry and bassist Tom Hamilton originally in a band together called the Jam Band met up with singer Steven Tyler drummer Joey Kramer and guitarist Ray Tabano and formed Aerosmith. In 1971 Tabano was replaced by Brad Whitford and the band began developing a following in Boston. http://en.wikipedia.org/wiki/Aerosmith
This is a wikipedia bot script with @wiki(public trigger, for ops) and !wiki(private trigger for anyone) The @trigger messages the channel and the !trigger notices the user.
Syntax !wiki search words or @wiki search words.
Added a language variable
Change %langcode if you want to try another language.
Thanks to jaytea for the cool alias. I found it here -->> http://www.hawkee.com/snippet/4198/
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;Wikipedia Script by Ford_Lawnmower irc.mindforge.org #USA-Chat;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
alias -l GetGwikipedia {
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;Start of Simple Setup;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;Change %langcode(below) to the language you want this script to return results in (ie - de for german fr for french it for italian, etc)
var %langcode en
;;;Change %wikilogo(below) to change the logo.(This must be one continious string - NO SPACES)
var %wikilogo 14W04i14k04i14p04e14d04i14a04
;;;Change %textcolor(below) to change the color of the results text. (There must be at least a " " here.)
var %textcolor 04
;;;Change %linkcolor(below) to change the color of the returned link.(There must be at least a " " here.)
var %linkcolor
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;End Setup;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
$1-2 %wikilogo $+(%textcolor,Searching For:,%linkcolor) $3-
var %sockname $+(GWikipedia,$network,$2,$ticks)
sockopen %sockname www.google.com 80
sockmark %sockname $1-2 $+(/search?q=,$replace($3-,$chr(32),+),+site:,%langcode.,wikipedia.org&rls=,%langcode,&hl=,%langcode) %wikilogo %textcolor %linkcolor $3-
}
menu Channel,Status {
.$iif($group(#Wikipedia) == On,$style(1)) Wikipedia Trigger
..$iif($group(#Wikipedia) == On,$style(2)) On: .enable #Wikipedia
..$iif($group(#Wikipedia) == Off,$style(2)) Off: .disable #Wikipedia
}
alias Wiki { GetGWikipedia echo -a $1- }
#Wikipedia on
On $*:Text:/^(\+|-|!|@)Wiki.*/Si:#: {
var %action $regml(1)
if (%action isin +-) && ($regex($nick($chan,$nick).pnick,/(!|~|&|@)/)) {
if (%action == +) {
if ($istok(%WikipediaChanList,$+($network,$chan),32)) { .msg $chan $nick $chan is already running the Wikipedia script }
else {
.enable #Wikipedia
Set %WikipediaChanList $addtok(%WikipediaChanList,$+($network,$chan),32)
.msg $chan $nick has activated the Wikipedia script for $chan .
}
}
else {
if (!$istok(%WikipediaChanList,$+($network,$chan),32)) { .msg $chan $nick $chan is not running the Wikipedia script }
else {
Set %WikipediaChanList $remtok(%WikipediaChanList,$+($network,$chan),1,32)
.msg $chan $nick has deactivated the Wikipedia script for $chan .
}
}
}
elseif (!$timer($+(Wikipedia,$network,$nick))) && ($istok(%WikipediaChanList,$+($network,$chan),32)) {
.timer $+ $+(Wikipedia,$network,$nick) 1 6 noop
var %method $iif(%action == !,.notice $nick,$iif($regex($nick($chan,$nick).pnick,/(!|~|&|@|%)/),.msg $chan,.notice $nick))
GetGWikipedia %method $2-
}
}
#Wikipedia end
On *:sockopen:GWikipedia*: {
if (!$sockerr) {
sockwrite -nt $sockname GET $gettok($sock($sockname).mark,3,32) HTTP/1.0
sockwrite -n $sockname Host: www.google.com
sockwrite -n $sockname $crlf
}
else { echo -st Socket Error $nopath($script) | sockclose $sockname | return }
}
On *:sockread:GWikipedia*: {
if ($sockerr) { echo -st Socket Error $nopath($script) | sockclose $sockname | return }
else {
sockread &GWikipedia
var %GWikipedia $bintween(&GWikipedia,<cite>,</cite>,1)
if (wikipedia.org isin %GWikipedia) {
tokenize 32 $sock($sockname).mark
ResultsWiki $1-2 $gettok(%GWikipedia,1,47) $remove($replace($gettok(%GWikipedia,2-,47),&,&),<b>,</b>) $4-6
sockclose $sockname
return
}
}
}
On *:sockclose:GWikipedia*: {
tokenize 32 $sock($sockname).mark
$1-2 $+($4,$5) Sorry - Cannot find $7-
}
alias -l ResultsWiki {
var %sockname $+(ResultsWiki,$2,$ticks,$r(1,$ticks))
sockopen %sockname $3 80
sockmark %sockname $1-
}
On *:Sockopen:ResultsWiki*: {
.timer $+ $sockname 1 5 CloseWikiError $sockname
sockwrite -nt $sockname GET $+(/,$gettok($sock($sockname).mark,4,32)) HTTP/1.1
sockwrite -n $sockname User-Agent: Opera 9.6
sockwrite -n $sockname Host: $gettok($sock($sockname).mark,3,32) $+ $str($crlf,2)
}
on *:sockread:ResultsWiki*: {
if ($sockerr > 0) { echo -at >Sock Error< Wikipedia | sockclose $sockname }
else {
sockread -fn &wiki
if $bvar(&wiki, 0) {
bwrite $+($sockname,.dat) -1 -1 &wiki
bread $+($sockname,.dat) 1 $file($+($sockname,.dat)).size &wiki
if ($bintween(&wiki,<b>,</p>,1)) || ($bintween(&wiki,<p>,</p>,1)) {
.remove $+($sockname,.dat)
tokenize 32 $sock($sockname).mark
bset -t &result 1 $bintween(&wiki,<p>,</p>,1)
if (may refer to: isin $bvar($binstrip(&result),1,429).text) {
$1-2 $+($5,$6) Nothing Found! Please refine your search and check your spelling.
.timer $+ $sockname off
sockclose $sockname
return
}
put $1-2 $fix&#($bvar($binstrip(&result),1,$bvar(&result, 0)).text) $+($7,http://,$3,/,$4)
.timer $+ $sockname off
sockclose $sockname
return
}
elseif ($bvar(&wiki, 0)) && ($bfind(&wiki, 1, <h2>Contents</h2>)) { CloseWikiError $sockname }
}
}
}
alias -l CloseWikiError {
var %sockname $1
tokenize 32 $sock($1).mark
$1-2 $5-6 Sorry :(( Unable to Parse $+($7,http://,$3,/,$4)
sockclose %sockname
.remove $+(%sockname,.dat)
return
}
alias -l fix&# { return $replace($regsubex($1-,/\&\#([0-9]{1,});/g,$UTF8(\t)),",",&,&,>,>,<,<,',',|,,$chr(9),$chr(32)) }
alias -l UTF8 {
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)) }
}
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 1000, %prefix $gettok($sock($sockname).mark,5-6,32)
if ($timer($+(Put,$2,$network)).secs) { %Dtimer = $calc($v1 * 1000) }
while ($len($($+($,%Tstart,-,%tokens),2)) > $calc(420 - $len(%prefix))) {
dec %tokens
if ($len($($+($,%Tstart,-,%tokens),2)) <= $calc(420 - $len(%prefix))) {
.timer -m 1 %Dtimer $1-2 $+(%prefix,$($+($,%Tstart,-,%tokens),2)))
inc %Dtimer 1500
%Tstart = $calc(%tokens + 1)
%tokens = $0
}
}
.timer -m 1 %Dtimer $1-2 $+(%prefix,$($+($,%Tstart,-,%tokens),2)))
.timer $+ $+(Put,$2,$network) -m 1 $calc(%Dtimer + 1000) noop
}
alias -l fixurl return $regsubex($strip($1-),/([^a-z0-9])/ig,% $+ $base($asc(\t),10,16,2))
alias -l binstrip {
while ($bfind($1, 1 ,<)) && ($bfind($1, 1, >)) {
var %first = $bfind($1, 1, <), %last $calc($bfind($1, 1, >) - $bfind($1, 1, <) + 1)
noop = $bremove($1, $bvar($1, %first, %last).text)
}
while ($bfind($1, 1 ,$chr(91))) && ($bfind($1, 1, $chr(93))) {
%first = $bfind($1, 1, $chr(91))
%last = $calc($bfind($1, 1, $chr(93)) - $bfind($1, 1, $chr(91)) + 1)
noop = $bremove($1, $bvar($1, %first, %last).text)
}
return $1
}
;bremove by jaytea
alias bremove {
if (!$isid) || ($0 < 2) || (!$regex($1,/^&[^ ]+$/)) {
echo -ces i * Invalid parameters: $!bremove
return
}
if ($bvar($1,0)) {
var %x = 1
while (%x < $0) {
inc %x
var %i = 1, %t = $eval($ $+ %x,2) $chr(32)
while ($bfind($1,%i,$left(%t,-2)) [ $+ [ $iif($prop == text,.text) ] ]) {
var %i = $v1, %p = $iif($prop != text && $regex(bremove,%t,/^ *\d+(?: +\d+)* *$/i),$numtok(%t,32),$len($mid(%t,3))) + %i
if (%p <= $bvar($1,0)) bcopy -c $1 %i $1 %p -1
elseif ($calc(%i - 1)) bset -c $1 $v1 $bvar($1,$v1)
else bunset $1
}
inc %x 2
}
}
return $1
}
alias -l bintween {
var %count = 1, %mark = 0, %mark2 = 0
while (%count <= $4) {
if ($bfind($1, %mark2, $2).text) {
%mark = $calc($bfind($1, %mark2, $2).text + $len($2))
if ($bfind($1, %mark, $3).text) {
%mark2 = $bfind($1, %mark, $3).text
}
else { return 0 }
}
else { return 0 }
inc %count
}
return $bvar($1, $iif(%mark > 0,%mark,1), $iif($calc(%mark2 - %mark) < 4130,$calc(%mark2 - %mark),4130)).text
}
Doesn't return the results to me.
[11:15:04] +wiki
[11:15:06] Somsubhra1 has activated the Wikipedia script for #Coding .
[11:15:09] !wiki football
[11:15:10] -RadishBot- Wikipedia Searching For: football
[11:15:11] -RadishBot- Wikipedia Sorry - Cannot find football
I added this... http://pastebin.com/3r3zhbCC . Nothing should be wrong. I use mirc version 7.38
Thanks.
@cptpan I just tested and this script is still working.
Did you activate it for the channel (+wiki) ?
I can find no issues with this script:
[14:06:00] <@Ford_Lawnmower> +wiki
[14:06:00] Ford_Lawnmower has activated the Wikipedia script for #FordIRC .
[14:06:07] <@Ford_Lawnmower> @wiki fire
[14:06:07] Wikipedia Searching For: fire
[14:06:12] Wikipedia Fire is the rapid oxidation of a material in the exothermic chemical process of combustion, releasing heat, light, and various reaction products. Slower oxidative processes like rusting or digestion are not included by this definition. http://en.wikipedia.org/wiki/Fire
the code from the top of the page doesn't seem to want to work with neither version 6.2 nor version 6.35.You have to wait for Ford to take note of this issue. Why are you still using 6.20? Version 6.20 won't work correctly with the script anyway. Until Ford fixes it, you need to stick with the latest version, or else you'll get an error like the user SnoooP did.
Confirmed, the current version doesn't respond to trigger anymore for some reason under version 6.35.
Kingc44, use the original version. It works perfectly without an issue:
It still requires that you have at least the version 6.32 to work. I suggest that you upgrade to the latest one available today.
Remade this script to be much more tolerant of typos and CASE errors.
Added google site search to assure a decent result ratio.
Added simple setup so you can change logo, colors, language, etc.
Added bread,bwrite operations to prevent data loss.
Example Output:
20:23:49 @wiki aerosmith
20:23:49 Wikipedia Searching For: aerosmith
20:23:52 Wikipedia Aerosmith is an American hard rock band sometimes referred to as "The Bad Boys from Boston" and "America's Greatest Rock and Roll Band". Their style which is rooted in blues-based hard rock has come to also incorporate elements of pop heavy metal and rhythm and blues and has inspired many subsequent rock artists. The band was formed in Boston Massachusetts in 1970. Guitarist
20:23:53 Joe Perry and bassist Tom Hamilton originally in a band together called the Jam Band met up with singer Steven Tyler drummer Joey Kramer and guitarist Ray Tabano and formed Aerosmith. In 1971 Tabano was replaced by Brad Whitford and the band began developing a following in Boston. http://en.wikipedia.org/wiki/Aerosmith
Maybe url needs URL Encode, since ++ can be interpreted as a "Space" character in the url.