using Bot::BasicBot with private channels

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

[This message was posted to comp.lang.perl.modules yesterday but I've
received no responses so I'm posting here]

The attached Bot::BasicBot script, modified to protect some string
literals, works fine when connecting to servers using public channels,
including logging the first call to "say" sent to itself. Private
channels require an invitation request sent to an invite bot. In a
normal irc client I would type this to get the invitation:

/msg <botname> invite <username> <password>

To do this with BasicBot I called the "say" function on lines 30-34,
which are commented out in the attached script:

  body=>"invite username password"

The script appears to hang (I don't know for sure because I don't see
a way to report errors) with those lines un-commented and never logs
any messages as it does when connected to public channels and lines
30-34 commented out.

Does anyone have suggestions on how to obtain the invite properly?
Perhaps this functionality is not supported.
use warnings;
use strict;

package MyBot;
use base qw( Bot::BasicBot );

open FILE,">/path/to/log";

  server => 'uri',
  channels => [ '#channel'],
  port => '6667',
  nick => 'username'

sub connected {
  my $self = shift;
  #just to make sure this function was entered
    run => [print FILE "connecting\n"]
  #test by sending message to myself: works
    body=>"invite username password"
#invite required prior to connecting to #tv channel: does not work
#   $self->say(
#     channel=>"msg",
#     who=>"welcomebot",
#     body=>"invite username password"
#   );


sub said {
  my ($self,$message) = @_;
  my $who = $message->;
  my $raw_nick = $message->;
  my $channel = $message->;
  my $body = $message->;
  my $address = $message->;
  #for now just record a transcript of messages
  my $str = "who: $who nick: $raw_nick channel: $channel body: $body
address: $address\n";
    run => [print FILE $str]

Re: using Bot::BasicBot with private channels

Quoted text here. Click to load it

You should always, yes always, check the return value from open.

Nowadays, you should also use the 3-arg form of open() along
with a lexical filehandle:

   open my $FILE, '>', '/path/to/log' or die "could not open: $!";

Tad McClellan
email: perl -le "print scalar reverse qq/moc.liamg0cm.j.dat/"
The above message is a Usenet post.
I don't recall having given anyone permission to use it on a Web site.

Re: using Bot::BasicBot with private channels

Quoted text here. Click to load it

Tad - No disagreement.

Site Timeline