|
| Author |
Message |
Cer Upgraded Agent

Joined: 03 Feb 2004 Posts: 3776 Location: Michigan
  votes: 4
|
Posted: Fri May 19, 2006 11:43 am Post subject: |
|
|
The ContactAddingUs handler doesn't need you to do anything complicated or even manually add the users.
If your handler sub returns 1, the contact is added. 0 and the add is denied.
Example:
| Code: | sub ContactAddingUs {
my ($self,$email,$name) = @_;
# if this is a bad user...
if ($email eq 'baduser@hotmail.com') {
# don't allow him to contact us
return 0;
}
else {
# allow it
return 1;
}
} |
You should add a print statement in your handler (if you don't have one yet) to tell you when somebody's adding the bot, it'll help with debugging.  _________________ Current Site (2008) http://www.cuvou.com/ |
|
| Back to top |
|
 |
mattaustin Sentinel

Joined: 19 Jul 2004 Posts: 556 Location: Los Angeles, CA
  votes: 1
|
Posted: Fri May 19, 2006 5:37 pm Post subject: |
|
|
Just a quick programming note. You shouldn't have a sub return 0 for false. I try have it: return undef;. The reason is sometimes the result could be 0 but still be true. Lets say we want a function to return the result of a math function that could equal 0, or return the position of an array...or an index: return index('matt', 'm'); .
Just something to keep in mind. _________________ [ matt ] |
|
| Back to top |
|
 |
eric256 The Keymaker

Joined: 03 May 2006 Posts: 2292 Location: Colorado
     
|
Posted: Fri May 19, 2006 7:22 pm Post subject: |
|
|
Often times undef is saved for errors, 1= true, 0 = false, undef = error, but not always. Anyway the MSN module is calling that hook expecting it to say yes or no, and so the callback is responding with a yes or no.
| Code: | | print "YEA" if callback($x); |
| Code: | | print "YEA" if defined callback($x); |
Both are fairly readable but the first is very obvious. _________________ Eric256
Proud previous owner and current admin of Bot-depot.com |
|
| Back to top |
|
 |
Cer Upgraded Agent

Joined: 03 Feb 2004 Posts: 3776 Location: Michigan
  votes: 4
|
Posted: Fri May 19, 2006 8:03 pm Post subject: |
|
|
Yeah, if you're checking for defined versus not, then returning 0 would be defined anyway. if you're just checking, it would equate to "false"...
| Code: | sub function {
return 0;
}
my $result = function();
if ($result) { # false
# not called
}
if (defined $result) { # true
# this code is run
} |
So it depends on the code calling the sub for what it expects to see (of course undef would always be good if you're not sure about this), I'm just going on what Mojave's told us about these callbacks.  _________________ Current Site (2008) http://www.cuvou.com/ |
|
| Back to top |
|
 |
eric256 The Keymaker

Joined: 03 May 2006 Posts: 2292 Location: Colorado
     
|
Posted: Fri May 19, 2006 8:43 pm Post subject: |
|
|
"Yeah, if you're checking for defined versus not, then returning 0 would be defined anyway." Um no, if your checking for defined then 0 would be true instead of false. So while it would be defined ti wouldn't function correctly.
My two codes where meant to represent one expecting non 0 as true and the other expecting defined as true (or 0 as fasle, and undef as false respectivly if you prefer to think of it that way.). Since most code tends to check for truth to continue i figured that was the more basic example.
One of us missed the others point i'm sure....so just consider this a clarification of my previous post and on we go!  _________________ Eric256
Proud previous owner and current admin of Bot-depot.com |
|
| Back to top |
|
 |
Teario Member

Joined: 25 Jun 2004 Posts: 130 Location: Liverpool(home) or Derby(uni), UK
  votes: 3
|
Posted: Tue May 30, 2006 12:14 am Post subject: |
|
|
When I run the echobot, it manages to sign in, but then it closes displaying the following error:
| Quote: | | File does not exist: at lib/MSN/Notification.pm line 903 |
line 903 is: | Code: | | my $data = $xml->XMLin($msg, suppressempty => ''); |
It seems weird, but then I havent used perl for quite some time so I may be missing something obvious. Anyone else had this problem? or know the reason and/or solution?
I have XML::Simple and it is fully up to date, and looking at the code I cant really see any other reason for the error.
Edit: Oops never mind I just noticed the part on the original post saying it doesnt work properly  |
|
| Back to top |
|
 |
JTW God Like

Joined: 07 Mar 2004 Posts: 581 Location: Maidstone
  votes: 4
|
Posted: Tue Jun 06, 2006 5:07 pm Post subject: |
|
|
Hi
When i use this module it would appear that it is not reciving any pongs from the server. from what i can see the pings are being sent fine
| Code: | (3 NS) TX: PNG
(3 NS) TX: PNG
(3 NS) TX: PNG
Disconnected : No pong received from server
Disconnecting from Notification Server
(3 NS) TX: OUT
Disconnected | Which results in as you would expect the bot being disconected from the server.
Any ideas on what to do? ( I have no idea about the msn protocol so i really cant fix it myself)
Thanks very much in advance
JT
Edit: Oddly enough its working for me now  |
|
| Back to top |
|
 |
Sypher Senior Member

Joined: 01 Jan 2004 Posts: 233 Location: The Netherlands
    
|
Posted: Sun Nov 19, 2006 6:33 pm Post subject: |
|
|
Is the "contact list handling" problem fixed? _________________ Sypher
Developer of Codera |
|
| Back to top |
|
 |
|