Anagram generator

By Kiddo96 on Sep 25, 2011

Well this is my 2nd snippet I thought I could post.
The syntax is !anagram (words here) or /anagram (words here), for example !anagram Odd I Know | /anagram (words here)

A total of 13 anagrams can be made out of "Odd I Know":
1 wink do do 2 know id do 3 know i odd 4 kind wood 5 wok din do 6 wok did no 7 wok did on 8 wok id don 9 wok id nod 10 wok in odd 11 kid now do 12 kid own do 13 kid won do

Also, !anagram pm's the user but /anagram echo's to your active window.
Constructive criticism is ofcourse welcome.
Updated to combine the text event with the alias. Once again thanks Jethro ;)

on *:text:!anagram *:#,?:{
  anagram $2-
}
alias anagram {
  if $sock(anagram) || $sock($+(anagram,$nick)) {
    sockclose $v1
  }
  sockopen $iif($event == text,$+(anagram,$nick),anagram) www.wordplays.com 80
  sockmark $iif($event == text,$+(anagram,$nick) msg $nick,anagram echo -a) $1-
}
on *:sockopen:anagram*:{
  tokenize 32 $sock($sockname).mark
  var %data $+(phrase=,$3-,&generate=Generate+Anagrams)
  sockwrite -nt $sockname POST /fcgi-bin/anagrams.pl HTTP/1.1
  sockwrite -nt $sockname Host: www.wordplays.com
  sockwrite -nt $sockname Connection: close
  sockwrite -nt $sockname Content-Type: application/x-www-form-urlencoded
  sockwrite -nt $sockname Content-Length: $len(%data)
  sockwrite -nt $sockname $crlf $+ %data
}
on *:sockread:anagram*:{
  tokenize 32 $sock($sockname).mark
  var %anagramreader
  sockread %anagramreader
  if (*no words in*can be made* iswm %anagramreader) {
    $1-2 No anagrams can be made out of $qt($3-) $+ .
    sockclose $sockname
  }
  if $regex(anagramresultsfound,%anagramreader,/<TD bgcolor=".+" colspan=.+><font color=".+" face=".+"><strong>(\d+) anagrams for <u>.+<\/u><strong><\/font>/) { 
    set %anagramresultsfound $regml(anagramresultsfound,1)
  }
  if $regex(anagram,%anagramreader,/TD align=left width=.+&nbsp;(.+)<\/font><\/TD/) {
    inc %anagramcount 1   
    set %anagramresults $addtok(%anagramresults,$+($chr(2),%anagramcount,) $regml(anagram,1),32)
  }
}
on *:sockclose:anagram*:{
  if %anagramresults {
    tokenize 32 $sock($sockname).mark
    $1-2 A total of %anagramresultsfound anagrams can be made out of $qt($3-) $+ :
    $1-2 %anagramresults
  }
  unset %anagram*
}

Comments

Sign in to comment.
jaydawg   -  Dec 11, 2011

awe its cool, i know the feeling~

 Respond  
Kiddo96   -  Nov 02, 2011

jaydawg, I'm terribly sorry, homework has killed all my free time. :-( I will try to find some time this week.

 Respond  
Kiddo96   -  Oct 21, 2011

Hello jaydawg!
Thanks for your nice words, I'll make an update this weekend :)

 Respond  
jaydawg   -  Oct 20, 2011

This is great , would be better if you could limit the results as if there are 200 possibility's it will flood you with all of the them!

love it tho!

 Respond  
Kiddo96   -  Sep 26, 2011

Unfortunately not. Though I can make the "Words generator" (http://www.hawkee.com/snippet/9017/) with either English/Italian/Swedish/German/French/Brazil Portugese or Spanish. If that would help or if you could find me a site that can make the same thing in your language I'll see what I can do :)

 Respond  
D4ng3r0u5   -  Sep 25, 2011

There anyway to change the language?

 Respond  
Kiddo96   -  Sep 25, 2011

Thanks, I finally found use for it :)

 Respond  
FelicianoX   -  Sep 25, 2011

Nice use of $event.

 Respond  
Kiddo96   -  Sep 25, 2011

Haha. I'll update it as you showed me. I've been learning for about two months now.
Updated it now, thanks once again :P

 Respond  
Jethro   -  Sep 25, 2011

Here we go again. You still open the socket for the alias on its own. :P I understand this is the one you may have made prior. Nice leap from GET to POST. lol :P

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