This script searches uncyclopedia.com for your search item. If no search word is given, it will give results from a random word.
This script was created @ the suggestion of ^Neptune.
Syntax for the script is !uncyclopedia search word(s) or just plain !uncyclopedia for random.
There is a ! trigger that will notice the user and a @ trigger that will message the channel if the user has halfops or higher.
Disclaimer
Just like the urban dictionary site, this site can render some very RUDE results. From my testing, I found some results to be racially insensitive. I also found some to be very anti-American.
It is up to the bot/channel owner to determine if this script is appropriate for their channel/network.
;Uncyclopedia Search Script by Ford_Lawnmower -- irc.Geekshed.net #Script-Help
menu Channel,Status {
.$iif($group(#uncyclopedia) == On,$style(1)) Uncyclopedia uncyclopedia Trigger
..$iif($group(#uncyclopedia) == On,$style(2)) On: .enable #uncyclopedia
..$iif($group(#uncyclopedia) == Off,$style(2)) Off: .disable #uncyclopedia
}
#uncyclopedia on
On $*:Text:/^(!|@)uncyclopedia.*/Si:#: {
if ($timer($+(uncyclopedia,$network,$nick))) { return }
.timer $+ $+(uncyclopedia,$network,$nick) 1 4 noop
var %method $iif($regml(1) == !,.notice $nick,$iif($regex($nick($chan,$nick).pnick,/(!|~|&|@|%)/),.msg $chan,.notice $nick))
uncyclopediaS %method $2-
}
#uncyclopedia end
alias uncyclopedia { uncyclopediaS echo -a $1- }
alias -l uncyclopediaS {
$1-2 Searching.......
var %sockname $+(uncyclopediaS,$network,$2,$ticks)
sockopen %sockname uncyclopedia.wikia.com 80
sockmark %sockname $1-2 $iif($3,$+(/wiki/Special:Search/?fulltext=Search&search=,$replace($3-,$chr(32),+)),/wiki/Special:Random) 0 $iif(!$3,1,0)
}
alias -l uncyclopediaR {
var %sockname $+(uncyclopediaR,$network,$2,$ticks)
sockopen %sockname uncyclopedia.wikia.com 80
sockmark %sockname $1-2 $+(/wiki/,$3) 0 $iif($4,1,0)
}
On *:sockopen:uncyclopedia*: {
if (!$sockerr) {
sockwrite -nt $sockname GET $gettok($sock($sockname).mark,3,32) HTTP/1.0
sockwrite -n $sockname Host: uncyclopedia.wikia.com
sockwrite -n $sockname Cookie: ContentWarningApproved=1
sockwrite -n $sockname $crlf
}
else { echo -st Socket Error $nopath($script) | sockclose $sockname | return }
}
On *:sockread:uncyclopediaS*: {
if ($sockerr) { echo -st Socket Error $nopath($script) | sockclose $sockname | return }
else {
var %uncyclopediaS | sockread %uncyclopediaS
if (Page title matches isincs %uncyclopediaS) { sockmark $sockname $puttok($sock($sockname).mark,1,4,32) }
if (Page text matches isincs %uncyclopediaS) { sockmark $sockname $puttok($sock($sockname).mark,1,4,32) }
if ($regex(%uncyclopediaS,/<a href="http:\/\/uncyclopedia.wikia.com\/wiki\/([^"]*)"\sclass="result-link"/i)) {
uncyclopediaR $gettok($sock($sockname).mark,1-2,32) $regml(1)
sockclose $sockname
return
}
if (Location: isin %uncyclopediaS) {
uncyclopediaR $gettok($sock($sockname).mark,1-2,32) $nopath(%uncyclopediaS) $gettok($sock($sockname).mark,5,32)
sockclose $sockname
return
}
}
}
On *:sockread:uncyclopediaR*: {
if ($sockerr) { echo -st socket error $nopath($script) }
else {
var %uncyclopediaR | sockread %uncyclopediaR
if (*<p>*<b>* iswm %uncyclopediaR) {
sockmark $sockname $puttok($sock($sockname).mark,$calc($gettok($sock($sockname).mark,4,32) + 1),4,32)
}
if ($gettok($sock($sockname).mark,4,32)) && ($httpstrip(%uncyclopediaR)) {
put $gettok($sock($sockname).mark,1-2,32) $v1 $+(,http://uncyclopedia.com,$gettok($sock($sockname).mark,3,32))
sockclose $sockname
return
}
}
}
On *:sockclose:uncyclopedia*: {
if ($gettok($sock($sockname).mark,5,32)) && (uncyclopediaR* iswm $sockname) { uncyclopediaS $gettok($sock($sockname).mark,1-2,32) }
else { $gettok($sock($sockname).mark,1-2,32) Sorry No results found for your Search }
}
alias -l httpstrip { var %x, %i = $regsub($1-,/(^[^<]*>|<[^>]*>|<[^>]*$)/g,$null,%x) | return $remove($replace(%x,&,&), ,—) }
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 }
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
}
Just wanted to say thanks... just added this to My little BOT. ooO( Nice work like always )
Was wondering if there is anyway of stripping it of colors ?
When it's more then one line the next lines comes out red...
I had the same "trouble" with your IMDB script yesterday.
After I finished editing that the plot came in red when it was more the one line.
Cool evvabuo :) I'm glad it's working for you. I actually made the search results real loose so it would always return something. The result of this is that it sometimes returns discussion page results, which are formatted different.
I'll edit this script. I never noticed the link change to wikia.com. Thanks :)
Working fine! Thank you very much FordLawnmover :D
Sometimes returned the "warning" windows text rather than input paragraph text (I think depends on the different formatting of individual pages), but this not essential.
I'm allowed to edit this line:
put $gettok($sock($sockname).mark,1-2,32) $fix&#($v1) $+(,http://nonciclopedia.com,$gettok($sock($sockname).mark,3,32)
to
put $gettok($sock($sockname).mark,1-2,32) $fix&#($v1) $+(,http://nonciclopedia.wikia.com,$gettok($sock($sockname).mark,3,32)
Also applicable to Uncyclopedia to return the correct link.
Thanks again :D
Try this edit evvabuo -->> http://pastebin.com/ccUrWLxL
I have it working but idk ;/
[20:35:47] <!Ford> !nonciclopedia nessuno
[20:35:48] -FoSho- Searching.......
[20:35:50] -FoSho- Proprio come la fatina dei denti, il cervello dei truzzi, Babbo Natale, Pikachu, Dio e il piccolo drago Grisù. Sappiamo che questa sarà un'informazione sconvolgente per molti poveri bambini che credevano fermamente nell'esistenza di una cosa chiamata "Nessuno", ma è così. http://nonciclopedia.com/wiki/Nessuno
I hope that doesn't say anything bad :PpPpPpP
@evvabuo You are very correct. Uncyclopedia uses the same wikimedia template as nonciclopedia. I don't know any Italian but I'll have a look at it and see if I can sort it out.
I'll post something back in a little bit and you will have to tell me how accurate the results are. Not sure if I can get it 100% right without being able to read Italian, but I'm sure I can get the script running for you.
Hi FordLawnmower, I want first congratulate for yours very helpful snippets (in particular wikipedia and youtube)
Now, my question ... it's possibile adjust this script to Nonciclopedia (Italian version of Uncyclopedia)?
I tried to change all terms "Uncyclopedia" on "Nonciclopedia" since the aspect of the pages and urls as apparently equal, but when i type:
!nonciclopedia nessuno (nessuno or another random italian term)
script returned:
Searching ......
Sorry No results found for your search.
Naturally in the original english work properly.
Nonciclopedia site is http://nonciclopedia.wikia.com
thanks in advance (and sorry for my imperfect english).
Thanks jonesy44 :)
I've been having a little trouble copying and pasting to the code box here. When I first pasted it, the scroll bar didn't appear and only half the script showed. Then I marked the whole thing and pasted again and it looked fine. The missing part of the first paste must have showed up later. Damn Vista ;/ I should pay closer attention.
Thanks for noticing :)
broken again