Alrighty now I am really a bit confused... I am having a little trouble with the Net::AIM module, but I do not think it is the module itself just my code. Of couse why would a module be the problem?

Well anyway I am writing a little bot for AIM just for some basic information retrieval... and it can be expanded because commands be created easily like plugins.

This is my code, which takes an input from a user, and processes the input. For example if they type in "time" it will process it and load the plugin for time.

Here is the main code: bot.pl

#!C:\perl\bin\perl.exe -w #Need to load these for bot use use strict; use Net::AIM; #Especially if you want to reach out and talk to someone my %CONFIG = ( 'cgi_dir' => 'C:/windows/desktop/scripts/bot', #Exact dir +ectory of script (w/o trailing slash) 'bot_master' => '', #The owner of the bot 'bot_username' => '', #The bot's username to AIM 'bot_password' => '', #The bot's password to AIM ); #Alright here we go my $AIM = Net::AIM->new(); $AIM->newconn(Screenname => $CONFIG{'bot_username'}, Password => $CONF +IG{'bot_password'}); my $connection = $AIM->getconn(); #Now log on to server #Now we need to load the parser sub on_im{ my ($self, $evt, $from, $to) = @_; my $args = $evt->args(); my ($nick, $friend, $msg) = @$args; #Get rid of any HTML in the message, so we can read it as plain te +xt... chomp($msg); my $stripped = $msg; $stripped =~ s/<[^>]+>//g; $stripped =~ s/^\s+//g; #Now we load up the correct plugin for the command specified my($plugin, @lines) = split(/ /, $stripped); my $lines = join(' ',@lines); if(!defined($plugin)) { &send_response('nothing_todo',$nick); } else{ $plugin=lc($plugin); print "$nick requested $plugin - $CONFIG{'cgi_dir'}\n"; if(-e "$CONFIG{'cgi_dir'}/attach/$plugin.lib") { eval { require "$CONFIG{'cgi_dir'}/attach/$plugin.lib"; &main_program($self,$nick,$lines); }; if($@) {$self->send_im($nick,"Fatal Error Occured - $plugi +n - <B>$@<\/B>");} #FATAL ERROR } else{ $self->send_im($nick,"Hey! I can't do that because I do no +t know what $plugin is."); } } } sub on_error { my ($self, $evt) = @_; my ($error, @stuff) = @{$evt->args()}; my $errstr = $evt->trans($error); $errstr =~ s/\$(\d+)/$stuff[$1]/ge; print STDERR "ERROR: $errstr\n"; } #This sets the AIM to the subroutines to handle the EVENT $connection->set_handler('error',\&on_error); $connection->set_handler('im_in',\&on_im); print "Starting the BOT\n"; #Start the connection $AIM->start;

So, if they type in time then this is the plugin that it will load...

The code: time.lib

sub main_program{ my($self,$nick,$args) = $_[0]; my $time = localtime(time); $self->send_im($nick,"The current time is: $time."); } 1;

Now my problem is the $self->send_im in the time code does not work... It loads the function and eveything, but it returns an error, so it never sends the message. This is my error message... I do not know what the hell the problem is. I try to retrace the Net::AIM::Connection module all the way back and they only thing I can figure out is that I should be passing $self somewhere, but where?

Use of uninitialized value in substitution (s///) at C:/Perl/site/lib/ +Net/AIM/Co nnection.pm line 247. Use of uninitialized value in transliteration (tr///) at C:/Perl/site/ +lib/Net/AI M/Connection.pm line 248. Use of uninitialized value in concatenation (.) or string at C:/Perl/s +ite/lib/Ne t/AIM/Connection.pm line 267.

If anyone can help me out... It would be greatly appreciated.


In reply to Net::AIM trouble by thealienz1

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.