|
| Author |
Message |
kookie Newbie

Joined: 14 May 2006 Posts: 18
 
|
Posted: Mon May 29, 2006 12:43 pm Post subject: Mirroring msn rev 84 . & what about Rev 100+? |
|
|
Hi!
I am looking for a way to do some kind of mirroring for my msn bots.
use msn rev 84 now for somehow the latest REV 100+ got something broken in the contactlist handling.
One already has 1000 in the contactlist and should respond with something like: please add ...... to your list, i am full
Or maybe even more automatic as i saw some examples in this forum categorie but i am not sure: do they still work???
http://bot-depot.com/viewtopic.php?t=4850
Maybe i do not get it right how to implement it.
Or maybe i can "switch" to another msn bot module that yet has mirroring available?
Thanks! |
|
| Back to top |
|
 |
darkmonkey The Merovingian

Joined: 18 Apr 2004 Posts: 2557 Location: London, England
     votes: 7
|
Posted: Mon May 29, 2006 3:24 pm Post subject: |
|
|
To mirror bots it's best to do your own code, although that module is very helpful and may get you started. It's not advisable to try unless you can see clearly in your head what you have to do. For instance, if I were to do it, I'd know I have to put all the bot's details in a hashref, and do a foreach on it each time I would do something like $msn->connect() or $msn->do_one_loop.
I've been looking around for some code Cer posted ages ago, but can't find it. If you want to have a go at doing it - post your attempt here and we'll tell you if/where you slip up  _________________ ~ Josh
[ Need bot hosting on a dedicated server? PM me. ] |
|
| Back to top |
|
 |
Cer Upgraded Agent

Joined: 03 Feb 2004 Posts: 3776 Location: Michigan
  votes: 4
|
Posted: Mon May 29, 2006 5:16 pm Post subject: |
|
|
Here's a (very simplified) version of how my bot programs handle mirrors...
| Code: | # create a hashref of emails and passwords
our $bots = {
'alpha@mydomain.com' => {
password => 'secret',
},
'bravo@mydomain.com' => {
password => 'secret',
},
'charlie@mydomain.com' => {
password => 'secret',
},
'delta@mydomain.com' => {
password => 'secret',
},
# etc for each mirror
};
# create and setup MSN conns. for each bot
foreach my $handle (keys %{$bots}) {
$bots->{$handle}->{msn} = new MSN (
Handle => $handle,
Password => $bots->{$handle}->{password},
);
# setup handlers....
$bots->{$handle}->{msn}->setHandler (Connected => \&on_connect);
$bots->{$handle}->{msn}->setHandler (Message => \&on_im);
# etc...
# sign-on this bot
$bots->{$handle}->{msn}->connect();
}
# loop all bots
while (1) {
foreach my $bot (keys %{$bots}) {
$bots->{$bot}->{msn}->do_one_loop();
}
}
# an example handler
sub on_im {
my ($self,$from,$name,$msg) = @_;
if ($from eq 'hello bot') {
$self->sendMessage ("Hello human!");
}
else {
$self->sendMessage ("I don't know how to reply to that");
}
} |
Inside the bots' individual handlers, all is still the same (they still get a $self and everything). If you need to command a specific bot you'd have to address it by its hashref, e.g.
| Code: | # command delta@mydomain.com to say hi to admin
$bots->{'delta@mydomain.com'}->{msn}->call ('admin@mydomain.com', 'hello there!'); |
But for the most part, the rest of your code should work just like you had a $msn object like in the example code. _________________ Current Site (2008) http://www.cuvou.com/ |
|
| Back to top |
|
 |
kookie Newbie

Joined: 14 May 2006 Posts: 18
 
|
Posted: Mon May 29, 2006 6:32 pm Post subject: |
|
|
Thanks.... will take that for next round if i get there... i have not really any experiene with perl. Coding in perl looks pretty clear but again..guess it is not easy to do the trick from 0
still the idea is that if someone wants to add bot X and it is full it respons is: sorry i am full take .... GET_THE_BOT_THAT IS _NOT_FULL. |
|
| Back to top |
|
 |
darkmonkey The Merovingian

Joined: 18 Apr 2004 Posts: 2557 Location: London, England
     votes: 7
|
Posted: Mon May 29, 2006 7:18 pm Post subject: |
|
|
Concept:
1. Check if there are too many users on the current email. If so,
2. Find the bot with the least users
3. Tell the user to add that bot
4. Delete and block the user on this bot
For #1, you just need to get the number of people on the RL list (or whatever list you're using). scalar $self->getContactList('RL') or something (find the exact subroutine - I don't have the docs in front of me!
2. Do the same for all the other bots ^...or just keep the number of users in a database
3. That's the easy bit
4. removeContact() and block() should do the trick  _________________ ~ Josh
[ Need bot hosting on a dedicated server? PM me. ] |
|
| Back to top |
|
 |
Cer Upgraded Agent

Joined: 03 Feb 2004 Posts: 3776 Location: Michigan
  votes: 4
|
Posted: Mon May 29, 2006 8:42 pm Post subject: |
|
|
Here's some bits and pieces from the code for one of my bots to help ya out...
| Code: | # contactAddingUs handler
sub on_add {
my ($self,$user) = @_;
# get our handle
my $handle = $self->{Msn}->{Handle};
# our allow list
my @users = $bots->{$handle}->{msn}->getContactList('AL');
# if the list is full...
if (scalar(@users) >= 400) {
# find a better mirror
my $lowest = 400;
my $mirror = undef;
# loop until we find the mirror with the lowest contacts
foreach my $bot (keys %{$bots}) {
my @list = $bots->{$bot}->{msn}->getContactList('AL');
if (scalar(@list) < $lowest) {
$lowest = scalar(@list);
$mirror = $bot;
}
}
# $mirror should now be the bot with
# the $lowest number of contacts
# have this mirror add them instead
$bots->{$mirror}->{msn}->addContact ($user);
# deny the addition of THIS mirror cuz it's too full
return 0;
}
else {
# this mirror isn't full yet, so allow the add.
return 1;
}
} |
_________________ Current Site (2008) http://www.cuvou.com/ |
|
| Back to top |
|
 |
kookie Newbie

Joined: 14 May 2006 Posts: 18
 
|
Posted: Thu Jun 08, 2006 3:55 pm Post subject: |
|
|
Thanks! I could not be busy with my bot for a while.. other priorities..
Will have a good look at the code !
Is there going to be a bug fix for msn rev 100+ ?
Somehow it has a problem with the contactlisthandling.
See http://www.bot-depot.com/viewtopic.php?t=6659&postdays=0&postorder=asc&start=15 below.
It has some nice features and potential like stats from the bot.. that seems to not work in rev 84 ( a friend of mine had been busy with that but did not succeed. Other commands are working well on the other hand )
Cheers and again! Thanks! |
|
| Back to top |
|
 |
|