chiron's Journal chiron's use Perl Journal en-us use Perl; is Copyright 1998-2006, Chris Nandor. Stories, comments, journals, and other submissions posted on use Perl; are Copyright their respective owners. 2012-01-25T02:49:31+00:00 pudge Technology hourly 1 1970-01-01T00:00+00:00 chiron's Journal Net::AIML I was messing around with the ALICE chatbot software, when i learnt about AIML, this is a way for users to easily create there own chatbot personalitys and ten have them interpreted through the ALICE Engine, i then wondered if this could be implemented in perl, turns out somemone has done this already <a href="">'program v'</a>. However i found it hard to pick out the ALICE Engine as it was heavily integrated with other stuff.<br> <br> Thats when i found out about Net::AIML a simple module that integrates into pandorabots, a server hosting ALICE bots, basically it was just sending POST requests to the webpage, nothing to fancy. Anyway for a laugh i built it into a ircbot, to see who would be fooled into believing it was a real person, several people got strung along for a while although the majority soon recognised the hidden AI. Here's the code for it: *Sorry about the single letter variables, i couldn't be bothered to name them*<blockquote><div><p> <tt>&nbsp; &nbsp; use Net::IRC;<br>&nbsp; &nbsp; use Net::AIML;<br>&nbsp; &nbsp; use strict;<br>&nbsp; &nbsp; use warnings;<br> <br>&nbsp; &nbsp; if (!@ARGV) {<br> <br>&nbsp; &nbsp; &nbsp; &nbsp; print "\nUSAGE: [SERVER] [NICK] [CHAN]\nTo talk to the bot simply<nobr> <wbr></nobr>/msg [NICK] [MESSAGE]\nOr in the channel [NICK], [MESSAGE]. Within your irc client\n";<br>&nbsp; &nbsp; &nbsp; &nbsp; exit(0);<br>&nbsp; &nbsp; }<br> <br>&nbsp; &nbsp; my $b = Net::AIML-&gt;new(botid =&gt; 'ba30d497ce360e23');<br>&nbsp; &nbsp; my $i = new Net::IRC;<br>&nbsp; &nbsp; my $c = $i-&gt;newconn("Server", $ARGV[0], "Nick", $ARGV[1]);<br>&nbsp; &nbsp; my $x;<br> <br>&nbsp; &nbsp; $c-&gt;add_handler(376, \&amp;o);<br>&nbsp; &nbsp; $c-&gt;add_handler('msg', \&amp;m);<br>&nbsp; &nbsp; $c-&gt;add_handler('public', \&amp;m);<br>&nbsp; &nbsp; $i-&gt;start;<br> <br>&nbsp; &nbsp; sub o {<br>&nbsp; &nbsp; &nbsp; &nbsp; (my $s = shift)-&gt;join($ARGV[2]);<br>&nbsp; &nbsp; &nbsp; &nbsp; $x = 1;<br>&nbsp; &nbsp; }<br> <br>&nbsp; &nbsp; sub m {<br>&nbsp; &nbsp; &nbsp; &nbsp; if ($x == 1) {<br> <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; my ($s, $e) = @_;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if ($e-&gt;{type} =~<nobr> <wbr></nobr>/public/ &amp;&amp; $e-&gt;{args}[0] =~<nobr> <wbr></nobr>/^($ARGV[1]),<nobr> <wbr></nobr>/i or $e-&gt;{type} =~<nobr> <wbr></nobr>/msg/) {<br> <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; my $d = ($e-&gt;{type} =~<nobr> <wbr></nobr>/public/) ? $e-&gt;{to}[0] : $e-&gt;{nick};<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; my $r = $e-&gt;{args}[0];<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $r =~ s/^($ARGV[1]),<nobr> <wbr></nobr>//i;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; my $t = $b-&gt;tell($r)."\n";<br> <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $t =~ s/^Alice<nobr> <wbr></nobr>://i;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $t =~ s/&lt;\/?.+?&gt;//g;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $s-&gt;privmsg($d, $t);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br>&nbsp; &nbsp; &nbsp; &nbsp; }<br>&nbsp; &nbsp; }</tt></p></div> </blockquote> chiron 2006-10-31T11:47:43+00:00 journal Perl Gui interface to Phillips GoGear About two years ago i bought a philips gogear mp3 player, it was ok, the main downside was lame software to load music on to it.<br> <br> About a year ago it broke, i found it two weeks ago and through the magic of fist i fixed it ( apparently the hd needle gets stuck easily ).<br> <br> I couldn't stand the software so i decided to write my own, not too hard i thought it uses sqlite, however i spent ages on working out the logic, in the end i ended up using a much better script from for the logic.<br> <br> I then added the gui front end, making it easier to add &amp; remove songs.<br> <br> I spent some time then making it cross-platform as apparently activestate perl is happy with storing querys into an array, for use in a foreach ie:<br> <br> <code> my @ret = $main-&gt;getOpenFile(-multiple =&gt; 9999999, -filetypes =&gt; $types);<br> foreach my $path (@ret) {</code> <br> <br> However perl on linux isn't and i had to use:<br> <br> <code> my $ret = $main-&gt;getOpenFile(-multiple =&gt; 9999999, -filetypes =&gt; $types);<br> foreach my $path (@$ret) {</code> <br> <br> Hopefully it works ok, <a href="">here it is</a>. Thanks to Domm at for the original logic in his script <a href="">here</a>. <br> <br>NOTE: God help me if someone actually opens more than 9999999 files chiron 2006-10-20T18:58:25+00:00 journal