User Control Panel
Advertisements

HELP US, HELP YOU!

(\$signon_done);

 
Post new topic   Reply to topic    Bot Depot Forum Index -> General Programming Questions
View unanswered posts
Author Message
Cheater
Senior Member
Senior Member


Joined: 10 Jun 2005
Posts: 236

Reputation: 15.8Reputation: 15.8

PostPosted: Tue Jul 19, 2005 9:07 pm    Post subject: (\$signon_done); Reply with quote

Just wondering, in my code, I have always been using this to set a callback:

Code:
$oscar->set_callback_signon_done(\&signon_done);


What does the (\&signon_done) part do? I couldn't find this in the documentation or on bot-depot.


And to avoid making another thread, how do I tell my perl script to run a sub? So if I were to have something like this:

Code:

if ($msg eq "!menu) {
********
}

sub menu {
print "Menu";
}


What would I use in place of the *'s to tell it to run the menu sub (and print Menu).
Back to top
darkmonkey
The Merovingian
The Merovingian


Joined: 18 Apr 2004
Posts: 2557
Location: London, England
Reputation: 39.3Reputation: 39.3Reputation: 39.3Reputation: 39.3
votes: 7

PostPosted: Tue Jul 19, 2005 9:32 pm    Post subject: Reply with quote

$oscar->set_callback_signon_done(\&signon_done);

That makes OSCAR call sub signon_done when it's signed on.
--

if ($msg eq "!menu") {
&menu();
}

--OR--

if ($msg =~ /^!(.*?)/)
{
my $sub = $1;
&{$sub};
}

sub menu {
print "Menu";
}


Learn how to pass variables with shifts, too.

_________________
~ Josh
[ Need bot hosting on a dedicated server? PM me. ]
Back to top
Cheater
Senior Member
Senior Member


Joined: 10 Jun 2005
Posts: 236

Reputation: 15.8Reputation: 15.8

PostPosted: Tue Jul 19, 2005 9:42 pm    Post subject: Reply with quote

About passing variables with shifts, would I do:

my($var1,$var2,$var3) = @_;

And what code would I use to have it terminate the perl program (exit)?
Back to top
Cer
Upgraded Agent
Upgraded Agent


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

PostPosted: Tue Jul 19, 2005 10:17 pm    Post subject: Reply with quote

To terminate the Perl program:

Code:
exit(0);


I don't think the 0 is required, but that's just what I always do.

To answer your first question about the \&signon_done, it's a coderef.

For example, when you do:
$ref = \@array
Then $ref becomes an arrayref (reference to an array).

Likewise, \%hash becomes a hashref.

As seen in darkmonkey's post, the symbol for a subroutine is &, so &signon_done is a subroutine (we'll just call it "code" for the sake of references), and when you do \&signon_done it becomes a coderef.

Basically what it does, the module keeps a copy of &signon_done within itself to call when it needs it. So in that sense, if you redefine your signon_done handler afterward, it won't change the copy the module has. So if your bot has a command to reload handlers, you'll have to define the handlers in your module object again with the \&signon_done thing.

_________________
Current Site (2008) http://www.cuvou.com/
Back to top
Cheater
Senior Member
Senior Member


Joined: 10 Jun 2005
Posts: 236

Reputation: 15.8Reputation: 15.8

PostPosted: Tue Jul 19, 2005 11:01 pm    Post subject: Reply with quote

Thanks a ton cer. That's what I needed to know.
Back to top
mattaustin
Sentinel
Sentinel


Joined: 19 Jul 2004
Posts: 556
Location: Los Angeles, CA
Reputation: 50.7
votes: 1

PostPosted: Tue Jul 19, 2005 11:09 pm    Post subject: Reply with quote

really basic perl stuff
Back to top
Cheater
Senior Member
Senior Member


Joined: 10 Jun 2005
Posts: 236

Reputation: 15.8Reputation: 15.8

PostPosted: Tue Jul 19, 2005 11:34 pm    Post subject: Reply with quote

well, most the tutorials I view don't mention that. I thought it was what it was used for, but I wanted to make sure.
Back to top
Addict
Not Yet a God
Not Yet a God


Joined: 21 Jan 2004
Posts: 473

Reputation: 34.4Reputation: 34.4Reputation: 34.4

PostPosted: Wed Jul 20, 2005 2:46 am    Post subject: Reply with quote

You should really read http://perldoc.perl.org before asking for help.. might be faster.. Smile

Last edited by Addict on Wed Jul 20, 2005 3:51 pm; edited 1 time in total
Back to top
darkmonkey
The Merovingian
The Merovingian


Joined: 18 Apr 2004
Posts: 2557
Location: London, England
Reputation: 39.3Reputation: 39.3Reputation: 39.3Reputation: 39.3
votes: 7

PostPosted: Wed Jul 20, 2005 8:50 am    Post subject: Reply with quote

TCS: IT'S PERLDOC, WITHOUT THE "S". ARRRRGH. And the same in your signature >_<
_________________
~ Josh
[ Need bot hosting on a dedicated server? PM me. ]
Back to top
Addict
Not Yet a God
Not Yet a God


Joined: 21 Jan 2004
Posts: 473

Reputation: 34.4Reputation: 34.4Reputation: 34.4

PostPosted: Wed Jul 20, 2005 3:53 pm    Post subject: Reply with quote

DM: Oh shhhhhhhhhut uppp it was a simple mistake. I edited it now it works.
Back to top
Display posts from previous:   
Post new topic   Reply to topic    Bot Depot Forum Index -> General Programming Questions 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