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:
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:
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!)