!Uncyclopedia Search Script w/Random

By FordLawnmower on Sep 16, 2009

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.
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
    if (Location: isin %uncyclopediaS) {
      uncyclopediaR $gettok($sock($sockname).mark,1-2,32) $nopath(%uncyclopediaS) $gettok($sock($sockname).mark,5,32)
      sockclose $sockname
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
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,&amp;,&),&nbsp;,&mdash;) }
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 


Sign in to comment.
dma   -  Dec 10, 2015

I like it ,it doesn't flood the room just a notice which is fine by mine

dma  -  Feb 27, 2016

broken again

Sign in to comment

EMC   -  Apr 24, 2014

Broken again...please pull results from uncyclopedia.co

FordLawnmower   -  Sep 10, 2012

No problem EMC.

EMC   -  Sep 10, 2012

Thanks so much for the fix, FordLawnmower.

FordLawnmower   -  Sep 09, 2012

Updated and working again.
Sorry I didn't notice it was broken :(

MashhitDK   -  Jun 29, 2012

Any fix for this... doesn't work on search... still works on random / !uncyclopedia
But doing !uncyclopedia whatever wont give any results

MashhitDK   -  Sep 04, 2011

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.

FordLawnmower   -  Nov 20, 2010

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 :)

evvabuo   -  Nov 20, 2010

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)


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

FordLawnmower   -  Nov 19, 2010

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

FordLawnmower   -  Nov 19, 2010

@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.

evvabuo   -  Nov 19, 2010

Ok, sorry Jethro. My is a simple question, because with wikpedia is working...

Jethro   -  Nov 19, 2010

Just because the site layouts look alike to one another doesn't mean the source codes are exactly the same. Many people have misconception that by changing a socket script's host, url link and the sock name, it'll work like magic for a different site intended. It just doesn't work that way.

evvabuo   -  Nov 19, 2010

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).

}{exer   -  Sep 17, 2009

Once again a good Snippet :))
many Thanks

VinX   -  Sep 16, 2009

I'll try this one out Ford ,thx man :D

FordLawnmower   -  Sep 16, 2009

Updated Code
I added a few lines of code to make sure the random would always generate a result.

FordLawnmower   -  Sep 16, 2009

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 :)

Jonesy44   -  Sep 16, 2009

I love Uncyclopedia. Countless hours of laughing in class at this site! NIce script buddy:)

You've pasted the sockclose onwards twice btw.

Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.