User Control Panel
Advertisements

HELP US, HELP YOU!

Sub contact adding us - Please help me if you can.

 
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 Mar 07, 2005 11:35 pm    Post subject: Reply with quote

I have this as a sub:

Code:
sub ContactAddingUs{<br />   my ($self,$user)= @_;<br /> <br />   my @bots =  keys %{$bot->{msn}};<br />   my @counts = sort { <br />  scalar($bot->{msn}->{$a}->getContactList('AL'))<br />  <=><br />  scalar($bot->{msn}->{$b}->getContactList('AL')) }<br />   @bots;<br />   my $least = shift @counts; <br /><br />   foreach my $handler (keys %{$bot->{msn}}) {<br />  my @AL = $bot->{msn}->{$handler}->getContactList ('AL');<br />  print"$handler contains:\n";   <br />  print join(", ", @AL);<br /><br /><br />  #foreach my $key (keys %{$AL}) {<br />       #   print "\$AL->{$key} = $AL->{$key}\n";<br />  #}<br /><br /><br />  #if (exists $AL->{$user}){<br />  #   if($self->{Handle} ne $handler){<br />  #  $bot->{msn}->{$handler}->call($user,"Thanks for adding us but this mirror ($handler) has already been allocated to this account, Please now add this account");<br />  #  return 0;<br />  #   }<br />  #   else{<br />  #  $bot->{msn}->{$handler}->call($user,"Thanks for adding me! You've chosen the correct mirror! Enjoy!");<br />  #  return 1;<br />  #   }<br />  #}<br />   }<br /><br />   if(defined $bot->{store}->{users}->{$user}->{powers} && $bot->{store}->{users}->{$user}->{powers} > 4){<br />  $bot->{msn}->{$self->{Handle}}->call($user,"Well, as you have high powers i'll let you add all/any of my mirrors!");<br />  return 1;<br />   }<br />   if($least eq $self->{Handle}){<br />           $bot->{msn}->{$least}->call($user,"Thank you for adding me, you have chosen the correct mirror");<br />          return 1;<br />       }<br />       else{<br />           $bot->{msn}->{$least}->call($user,"Thanks for adding me but please could you add $least (me!) instead as i am using a mirror service and that is the one allocated to you...\nYou will not be accepted by the mirror you added so please delete that account and add this one");<br />        return 0;<br />    }<br />}



Half is commented out but i want that working,
I am trying to:

Check if a user has already added a mirror, if so tell them to add that one by calling them from the one that they should add.

Me and cer were working together and we though it was a hash ref i think but it turned out it was an array.
From the printing bit i get:
Code:
evozbot@gmail.com contains:<br />gordy12gg@msn.com, mojave@botwork.com, spazzy_mcgee_simon@hotmail.com, matthew@e<br />xtrabot.net, ted@royalbot.co.uk, bigtrev.net@gmail.com, sporto@blueyonder.co.uk,<br /> tbrw@msn.com, dazzy2004@hotmail.com, travis@bot2k3.net, mouthalmighty2@hotmail.<br />com, crim@fsmail.net, me@dazzy2004.com, special_simon@hotmail.co.uk, botlist@bot<br />work.com, farwajaffrey@hotmail.com, theoneandonlydazzeh@hotmail.co.uk, martinore<br />d@hotmail.com<br />bot@hotmail.co.uk contains:<br />


As you can see its showing that the second mirror has no contacts on its allow list, which is wrong because i have it added and my stats command state that:

Code:
>>evozbot@gmail.com Has:<br />Forward : 1<br />Blocked : 2<br />Reverse : 14<br />Allow : 18<br /><br />>>bot@hotmail.co.uk Has:<br />Forward : 0<br />Blocked : 2<br />Reverse : 6<br />Allow : 6



So i dont get whats wrong, The basics to my mirroring is:

$bot->{msn} = {
'bot@hotmail.co.uk' => new MSN (
Handle => 'bot@hotmail.co.uk',
Password => 'fsdgdfgsdfgt',
),
'evozbot@gmail.com' => new MSN (
Handle => 'evozbot@gmail.com',
Password => 'sfsgdfgsdfg',
),
};
#passwords are wrong so dont try....
Back to top
Dazzy
Agent
Agent


Joined: 09 Jan 2004
Posts: 1731

Reputation: 72.3

PostPosted: Tue Mar 08, 2005 11:31 am    Post subject: Reply with quote

Well i've sorted it although it might not be the most efficent way its doesnt seem to cause any lag and its the easiest for users to understand which is my aim.

I've made it update a hash in my file regularly, printing out the allow list of each handle in a nice organised form, I can then simply check against the hash and wala!

It'll be in next version of evolution (Yes there is going to be one, its coming along very nicely!)
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