|
| Author |
Message |
Dazzy Agent

Joined: 09 Jan 2004 Posts: 1731
 
|
Posted: Mon Jan 24, 2005 5:06 pm Post subject: |
|
|
| Code: | | sub ContactAddingUs{<br /> my ($self,$user)= @_;<br /> <br /> my ($least, $leastcount) = ("", 10000); # set to something ridiculous high so the < works <br /> print "\n\nstarting...Least = $least and Least count = $leastcount ";<br /> foreach my $handle (keys %{$bot->{msn}}) { <br /> print "\nlooking at $handle";<br /> my $count = scalar $bot->{msn}->{$handle}->getContactList( 'AL' ); <br /> print "\ncontacts for $handle is $count";<br /> if($count < $leastcount) { <br /> print "\nIf statement passed!\n-----------------";<br /> $leastcount = $count; <br /> $least = $handle; <br /> print "\nLeast count is now $leastcount and Least = $least\n---------------------------\n\n";<br /> } <br /> } <br /> print "\nall done...$least if the bot we should add";<br /> if(defined $least && $least eq $self->{msn}->{Handle}){<br /> <br /> $self->sendMessage("Thank you for adding me, you have chosen the correct mirror") if(defined $least && defined $self);<br /> return 1;<br /> }<br /> else{<br /> $self->sendMessage("Thanks for adding me but please could you add $least instead as i am using a mirror service and that is the one allocated to you...");<br /> return 0;<br /> }<br />} |
It doesn't work and... It is driving me damm mad!
Heres what the prints do: I havent got a clue whats wrong with it? Must im susupecting its from outside this ecause i cant find anything wrong with this, it says the second ifstatement, comparing $least and the current handle has a unitialized value!??!
| Code: | | starting...Least = and Least count = 10000<br />looking at evozbot@gmail.com<br />contacts for evozbot@gmail.com is 15<br />If statement passed!<br />-----------------<br />Least count is now 15 and Least = evozbot@gmail.com<br />---------------------------<br /><br /><br />looking at bot@hotmail.co.uk<br />contacts for bot@hotmail.co.uk is 3<br />If statement passed!<br />-----------------<br />Least count is now 3 and Least = bot@hotmail.co.uk<br />---------------------------<br /><br /><br />Use of uninitialized value in string eq at Evolution_Bot_Template.pl line 585.<br />all done...bot@hotmail.co.uk if the bot we should add |
|
|
| Back to top |
|
 |
Dazzy Agent

Joined: 09 Jan 2004 Posts: 1731
 
|
Posted: Mon Jan 24, 2005 9:01 pm Post subject: |
|
|
Its driving me bonkers..... |
|
| Back to top |
|
 |
eric256 The Keymaker

Joined: 03 May 2006 Posts: 2292 Location: Colorado
     
|
Posted: Tue Jan 25, 2005 1:08 am Post subject: |
|
|
| Code: | | if(defined $least && $least eq $self->{msn}->{Handle}){ |
I'm guessing that Handle should be a variable instead. Also before you where checking $bot->{msn}->{$handle} i'm not sure what your trying to do but that looks like it could be the problem. _________________ Eric256
Proud previous owner and current admin of Bot-depot.com |
|
| Back to top |
|
 |
alienz Almost An Agent

Joined: 22 Mar 2004 Posts: 1436 Location: Mars
 
|
Posted: Tue Jan 25, 2005 1:53 am Post subject: |
|
|
The error message points there for sure..but what I dont see is why at one point you call the contact list with :
| Code: | | <br />$bot->{msn}->{$handle}->getContactList( 'AL' )<br /> |
then later you use
| Code: | | <br />$self->{msn}->{Handle}<br /> |
As Eric pointed out, these are different, and correct me if I'm wrong but wouldn't MSN 2 have to use $self? _________________ Check out Botworld! A dev resource for things bot.
Downloads, articles, news, fourm and more.
http://botworld.marzopolis.com |
|
| Back to top |
|
 |
Mojave Almost An Agent

Joined: 01 Nov 2003 Posts: 1434
 
|
Posted: Tue Jan 25, 2005 2:16 am Post subject: |
|
|
I think this is what he is looking for:
That gets the current bot's handle. |
|
| Back to top |
|
 |
Cer Upgraded Agent

Joined: 03 Feb 2004 Posts: 3776 Location: Michigan
  votes: 4
|
Posted: Tue Jan 25, 2005 1:15 pm Post subject: |
|
|
| Code: | | $self->{msn}->{Handle} |
On MSN I told him to use $self->{Msn}->{Handle} to get the current bot's handle (that's what my bots do... I don't think $self->{Handle} worked when I coded it into my bot)... but he keeps mixing the caps up, first he had them all lowercase and now has just "msn" lowercase.  _________________ Current Site (2008) http://www.cuvou.com/ |
|
| Back to top |
|
 |
Mojave Almost An Agent

Joined: 01 Nov 2003 Posts: 1434
 
|
Posted: Tue Jan 25, 2005 5:41 pm Post subject: |
|
|
| The $self object passed to ContactAddingUs is a Notification object, which stores the Handle of the bot in $self->{Handle}. It also contains a reference to the MSN object, which itself stores the Handle, so you can do $self->{Msn}->{Handle}. |
|
| Back to top |
|
 |
|