|
| Author |
Message |
svennson Newbie

Joined: 05 Jun 2006 Posts: 29
 
|
Posted: Tue Jun 06, 2006 3:45 pm Post subject: include in perl ? |
|
|
hey ,
my bots running nicely , now i need te know how i include in perl ? beacus i wanne get the commands code out of the start perl.
in php :
| Code: | <?php
include "test.php";
?> |
but in perl ? test are the bot commands .. thx
grt svenn |
|
| Back to top |
|
 |
mat007 Almost An Agent

Joined: 12 Jan 2004 Posts: 1375
   votes: 2
|
Posted: Tue Jun 06, 2006 3:50 pm Post subject: |
|
|
You can require perl files eg:
|
|
| Back to top |
|
 |
mattaustin Sentinel

Joined: 19 Jul 2004 Posts: 556 Location: Los Angeles, CA
  votes: 1
|
Posted: Tue Jun 06, 2006 7:01 pm Post subject: |
|
|
you could also use:
do('xx.pl');
require() reads a file containing Perl code and compiles it. Before attempting to load the file it looks up the argument in %INC to see whether it has already been loaded. If it has, require() just returns without doing a thing. Otherwise an attempt will be made to load and compile the file.
While do() behaves almost identically to require(), it reloads the file unconditionally. It doesn't check %INC to see whether the file was already loaded. _________________ [ matt ] |
|
| Back to top |
|
 |
svennson Newbie

Joined: 05 Jun 2006 Posts: 29
 
|
Posted: Wed Jun 07, 2006 10:41 am Post subject: |
|
|
:s dam , i used both codes. but i received errors :s there gone the second i need them :s
| Code: | use lib "./lib";
use MSN;
use CGI::Carp qw(fatalsToBrowser);
use SOAP::Lite;
use LWP::Simple;
use Data::Dumper;
use File::Basename;
use Digest::MD5 qw(md5);
use LWP::UserAgent;
my $handle = 'phpbbhelper@hotmail.com';
my $password = 'xxxxx';
my $admin = '@hotmail.com';
# create an MSN object showing all server errors and other errors
my $msn = new MSN( 'Handle' => $handle, 'Password' => $password );
# OR create an MSN object with all error messages turned off
#my $msn = new MSN( 'Handle' => $handle, 'Password' => $password, 'ServerError' => 0, 'Error' => 0 );
# OR create an MSN object with full debugging info
#my $msn = new MSN( 'Handle' => $handle, 'Password' => $password, 'AutoloadError' => 1, 'Debug' => 1, 'ShowTX' => 1, 'ShowRX' => 1 );
# example of setting client info
$msn->setClientInfo( 'Client' => 'MSNC2' );
# example of setting client capabilites (caps)
$msn->setClientCaps( 'Client-Name' => 'MSN Bot/1.0', 'Chat-Logging' => 'Y', 'Client-Template' => 'None' );
# example of setting the default message style and P4 name
$msn->setMessageStyle( 'Effect' => 'B', 'Color' => 'FFFFFF', 'Name' => 'phpBBhelp' );
# set handlers
$msn->setHandler( 'Connected' => \&Connected );
$msn->setHandler( 'Disconnected' => \&Disconnected );
$msn->setHandler( 'Message' => \&Message );
# connect to the server
$msn->connect();
# run the bot
my $run = 1;
while( $run )
{
$msn->do_one_loop();
}
################### WERKING
sub Connected
{
my $self = shift;
print( "Connected\n" );
$msn->setDisplayPicture("phpBB.png");
$msn->call( $admin, "I am connected!", 'Effect' => 'BI', 'Color' => '00FF00', 'Name' => 'test' );
}
do("com.pl"); |
it gois over com.pl
Last edited by svennson on Tue Feb 20, 2007 8:45 pm; edited 1 time in total |
|
| Back to top |
|
 |
darkmonkey The Merovingian

Joined: 18 Apr 2004 Posts: 2557 Location: London, England
     votes: 7
|
Posted: Wed Jun 07, 2006 11:59 am Post subject: |
|
|
If that's where you're loading your commands, it's better to put the sub Message in your bot.pl and then do/require them:
| Code: |
sub Message
{
my ($self, $username, $message) = @_;
do ('com.pl');
}
|
That kind of thing (using the args that you already have in your Message sub). At the moment, it would be executing before any messages are sent - as soon as the script starts. You need to put it in the subroutine that's handled by the MSN module. _________________ ~ Josh
[ Need bot hosting on a dedicated server? PM me. ] |
|
| Back to top |
|
 |
svennson Newbie

Joined: 05 Jun 2006 Posts: 29
 
|
Posted: Wed Jun 07, 2006 3:51 pm Post subject: |
|
|
| Code: | sub Message
{
my( $self, $username, $name, $message, %style ) = @_;
print( "commandos loaden\n" );
do ('com.pl');
} |
but he doesn't antswer (like he should) in the cmd is see every time i type somthing commandos loaden... but no reply |
|
| Back to top |
|
 |
Cer Upgraded Agent

Joined: 03 Feb 2004 Posts: 3776 Location: Michigan
  votes: 4
|
Posted: Wed Jun 07, 2006 5:40 pm Post subject: |
|
|
| Quote: | # run the bot
my $run = 1;
while( $run )
{
$msn->do_one_loop();
}
################### WERKING
sub Connected
{
my $self = shift;
print( "Connected\n" );
$msn->setDisplayPicture("phpBB.png");
$msn->call( $admin, "I am connected!", 'Effect' => 'BI', 'Color' => '00FF00', 'Name' => 'test' );
}
do("com.pl"); |
Because of your while() loop, your Perl script never continues far enough to get to your do() command. It gets hung up on the while() loop as long as the bot is running, so your com.pl is never being included. _________________ Current Site (2008) http://www.cuvou.com/ |
|
| Back to top |
|
 |
svennson Newbie

Joined: 05 Jun 2006 Posts: 29
 
|
Posted: Wed Jun 07, 2006 7:15 pm Post subject: |
|
|
but the connect sub he does.
so there isn't a option to include ? |
|
| Back to top |
|
 |
svennson Newbie

Joined: 05 Jun 2006 Posts: 29
 
|
Posted: Wed Jun 07, 2006 7:22 pm Post subject: |
|
|
hehe found it changed the direction placed the while loop under it thanks  |
|
| Back to top |
|
 |
eric256 The Keymaker

Joined: 03 May 2006 Posts: 2292 Location: Colorado
     
|
Posted: Wed Jun 07, 2006 9:54 pm Post subject: |
|
|
| svennson wrote: | but the connect sub he does.
so there isn't a option to include ? |
The connect sub isn't getting executed its getting loaded, and realy thats not a good place to put the connect sub either. Anything you want run should be above while loop. _________________ Eric256
Proud previous owner and current admin of Bot-depot.com |
|
| Back to top |
|
 |
svennson Newbie

Joined: 05 Jun 2006 Posts: 29
 
|
Posted: Thu Jun 08, 2006 3:47 pm Post subject: |
|
|
owkee thx |
|
| Back to top |
|
 |
|