This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revision | |||
user:mgough:wezlbot [2010/05/20 21:22] – mgough | user:mgough:wezlbot [2010/05/20 21:23] (current) – mgough | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== Kick Wezlbot out of the Nest ====== | ||
+ | |||
+ | ===== A Brief History of Wezlbot ===== | ||
+ | |||
+ | ==== Genesis ==== | ||
+ | I started Wezlbot in October 2009 to challenge my skills while in my Unix class. | ||
+ | \\ | ||
+ | At this point, Weaz did not do much of anything, the bot was your stock eggdrop IRC bot (learn more here: http:// | ||
+ | \\ | ||
+ | ==== It's Alive!!.. well, sorta.. ==== | ||
+ | |||
+ | An info-bot, while informative and with practical function is not hyper-interesting, | ||
+ | |||
+ | Alan Turing (http:// | ||
+ | |||
+ | Some researching later, I found a port of MegaHAL for eggdrop (Sources can be found here: http:// | ||
+ | |||
+ | Soon Wezlbot became quite the distraction on IRC people talking to it all day, as it learned the good bad and ugly of the conversations, | ||
+ | |||
+ | ==== Out of the Nest ==== | ||
+ | \\ | ||
+ | This semester my intention was to allow the bot to interact out of the confines of lab46. | ||
+ | \\ | ||
+ | I took a few approaches, but my main goals were the following: | ||
+ | * Create a way for the bot to send output outside of IRC via a script.\\ | ||
+ | * Create a way to log into a popular social networking site.\\ | ||
+ | * Allow chat external to lab46.\\ | ||
+ | |||
+ | ==== Scripts, scripts, and more scripts... ==== | ||
+ | |||
+ | To get the bot to speak outside of IRC, I found a perl port of MegaHAL written by Cory Spencer, the source can be found here: http:// | ||
+ | |||
+ | <file perl wezlbot.pl> | ||
+ | 1 ###################################################################### | ||
+ | 2 # | ||
+ | 3 # A Perl Interface for WezlBot' | ||
+ | 4 ###################################################################### | ||
+ | 5 | ||
+ | 6 | ||
+ | 7 use AI:: | ||
+ | 8 | ||
+ | 9 ######################### | ||
+ | 10 # Creating new AI::MegaHAL | ||
+ | 11 my $megahal = AI:: | ||
+ | 12 # Get the input.. | ||
+ | 13 my $query = $ARGV[$0]; | ||
+ | 14 # Send reply.. | ||
+ | 15 my $reply = $megahal-> | ||
+ | 16 print(" | ||
+ | 17 $megahal = undef; | ||
+ | </ | ||
+ | |||
+ | To execute the script, the following command is issued. | ||
+ | perl wezlbot.pl " | ||
+ | Which results in the output being displayed, in this case... | ||
+ | Hello to my interesting convo with wezlbot. | ||
+ | |||
+ | Interesting yes, but how useful?? | ||
+ | |||
+ | At this point, I created a profile account at "that popular social networking" | ||
+ | In file: / | ||
+ | In the function static char *generate_reply(MODEL *model, DICTIONARY *words) | ||
+ | Add the following just before the statement " | ||
+ | < | ||
+ | 1858 | ||
+ | 1859 // hack in an output ... | ||
+ | 1860 // Add random to this... | ||
+ | 1861 // | ||
+ | 1862 int random_number = rand() % 100 + 1; | ||
+ | 1863 | ||
+ | 1864 char o_buff[255]; | ||
+ | 1865 int o_ret; | ||
+ | 1866 | ||
+ | 1867 { | ||
+ | 1868 o_ret = sprintf(o_buff, | ||
+ | 1869 | ||
+ | 1870 } | ||
+ | </ | ||
+ | |||
+ | What happens is that the program creates a random number from 1-100, then if the number is less than 20, the output is sent to both IRC AND the " | ||
+ | |||
+ | And now the magic! I will not release the class file as it can be used for evil, but here's the php script that performs the update. | ||
+ | |||
+ | <file php wezlbot_update.php> | ||
+ | < | ||
+ | <html xmlns=" | ||
+ | < | ||
+ | < | ||
+ | <meta http-equiv=" | ||
+ | < | ||
+ | body {font-family: | ||
+ | div.resul { font-size: | ||
+ | a { color:# | ||
+ | </ | ||
+ | </ | ||
+ | < | ||
+ | <? | ||
+ | include(" | ||
+ | $mb = new wezlbot(); | ||
+ | |||
+ | echo print_r($mb-> | ||
+ | |||
+ | ?> | ||
+ | |||
+ | </ | ||
+ | </ | ||
+ | |||
+ | </ | ||
+ | |||
+ | So any input sent to this script will log into the site, update a status, log out etc.. This is all done using cURL and PHP. | ||
+ | |||
+ | Ok, so what about that perl script?? | ||
+ | |||
+ | The perl script is what I use to generate messages to respond to responses (fun wording eh?) to Wezlbot' | ||
+ | |||
+ | ==== The Future ==== | ||
+ | |||
+ | I plan on developing this more and more as time goes on, my ultimate goal would be to have a CGI head of Wezlbot on the lair wall with voice recognition, | ||