User Control Panel
Advertisements

HELP US, HELP YOU!

What the hell is wrong with this code?!

 
Post new topic   Reply to topic    Bot Depot Forum Index -> Code Review
View unanswered posts
Author Message
Dazzy
Agent
Agent


Joined: 09 Jan 2004
Posts: 1731

Reputation: 72.3

PostPosted: Mon Jan 24, 2005 5:06 pm    Post subject: Reply with quote

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
Agent


Joined: 09 Jan 2004
Posts: 1731

Reputation: 72.3

PostPosted: Mon Jan 24, 2005 9:01 pm    Post subject: Reply with quote

Surprised Its driving me bonkers.....
Back to top
eric256
The Keymaker
The Keymaker


Joined: 03 May 2006
Posts: 2292
Location: Colorado
Reputation: 47Reputation: 47Reputation: 47Reputation: 47Reputation: 47

PostPosted: Tue Jan 25, 2005 1:08 am    Post subject: Reply with quote

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
Almost An Agent


Joined: 22 Mar 2004
Posts: 1436
Location: Mars
Reputation: 55.7

PostPosted: Tue Jan 25, 2005 1:53 am    Post subject: Reply with quote

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
Almost An Agent


Joined: 01 Nov 2003
Posts: 1434

Reputation: 66.4

PostPosted: Tue Jan 25, 2005 2:16 am    Post subject: Reply with quote

I think this is what he is looking for:

Code:
$self->{Handle}


That gets the current bot's handle.
Back to top
Cer
Upgraded Agent
Upgraded Agent


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

PostPosted: Tue Jan 25, 2005 1:15 pm    Post subject: Reply with quote

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. Razz

_________________
Current Site (2008) http://www.cuvou.com/
Back to top
Mojave
Almost An Agent
Almost An Agent


Joined: 01 Nov 2003
Posts: 1434

Reputation: 66.4

PostPosted: Tue Jan 25, 2005 5:41 pm    Post subject: Reply with quote

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
Display posts from previous:   
Post new topic   Reply to topic    Bot Depot Forum Index -> Code Review 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