User Control Panel
Advertisements

HELP US, HELP YOU!

Multiple bots handled by one program

 
Post new topic   Reply to topic    Bot Depot Forum Index -> Code Help
View unanswered posts
Author Message
Seymore
Newbie
Newbie


Joined: 05 Jun 2007
Posts: 2


PostPosted: Wed Jun 06, 2007 12:11 am    Post subject: Multiple bots handled by one program Reply with quote

I'm making a bot-service which should be able to care for many users at once. As the limit of the MSN protocol seems to be 600, I had to divide the workload on several different bots. This now seems to work, however I have one problem.

When assigning handlers for the different events, eg. Message, the $self referred to in the sub's header is not the actual MSN object, but rather SwitchBoard, whatever that is. The problem is that when I can't access the MSN object who owns the SwitchBoard object, I cannot send any replies, or do anything else for that matter. The echobot.pl which I got with the MSN package, just accessed $msn directly, but I have many $msn's, and as of now can't know which ones to use

(Why) is there no way to retrieve the MSN object? Why is it SwitchBoard who calls the event-handler, and not the MSN object?


If anyone has any clever solutions to this, I'd be grateful.
Back to top
Cer
Upgraded Agent
Upgraded Agent


Joined: 03 Feb 2004
Posts: 3776
Location: Michigan
Reputation: 146.9
votes: 4

PostPosted: Wed Jun 06, 2007 5:23 pm    Post subject: Reply with quote

A quick solution:

Code:
$self->{Msn}->setDisplayName ("testing a \$msn object function");


A longer solution:

Don't use actual $msn type variables for your individual bots, put them inside of a hash, by name:

Code:
my $bot = {}; # this is an anonymous hash reference
my @bots = (
   'mirror1@msn.com',
   'mirror2@msn.com',
   'mirror3@msn.com',
);
foreach my $handle (@bots) {
   $bot->{$handle} = new MSN (
      Handle => $handle,
      Password => "you figure this part out on your own",
   );
   $bot->{$handle}->setHandler (Message => \&on_message);
   $bot->{$handle}->signon();
}

# Treat $bot->{$handle} as you would a $msn object, e.g.
# $bot->{'mirror1@msn.com'}->setDisplayPicture, to command a
# specific mirror

sub on_message {
   my ($self,@otherinfo) = @_;

   # Get this bot's own handle.
   my $handle = $self->{Msn}->{Handle};

   # now we know this bot's handle, so we can command its
   # MSN object directly.
   $bot->{$handle}->sendMessage (To => 'master@msn.com', Message => 'hello world!');
}

_________________
Current Site (2008) http://www.cuvou.com/
Back to top
Seymore
Newbie
Newbie


Joined: 05 Jun 2007
Posts: 2


PostPosted: Thu Jun 07, 2007 1:34 pm    Post subject: Reply with quote

Thank you so much for your reply. And now I feel stupid Embarassed

The first solution will do just fine, I just didnt even consider that SwitchBoard had a pointer to the $msn object. Thanks to you, the problem is now trivial Very Happy
Back to top
Display posts from previous:   
Post new topic   Reply to topic    Bot Depot Forum Index -> Code Help All times are GMT
Page 1 of 1

 



Protected by phpBB Security phpBB-TweakS
phpBB Security Has Blocked 9 Exploit Attempts.
Antispam Captcha Mod by phpbb-security.com
Powered by phpBB © 2001, 2005 phpBB Group