User Control Panel
Advertisements

HELP US, HELP YOU!

include in perl ?

 
Post new topic   Reply to topic    Bot Depot Forum Index -> Code Help
View unanswered posts
Author Message
svennson
Newbie
Newbie


Joined: 05 Jun 2006
Posts: 29

Reputation: 1.1

PostPosted: Tue Jun 06, 2006 3:45 pm    Post subject: include in perl ? Reply with quote

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 .. Wink thx

grt svenn
Back to top
mat007
Almost An Agent
Almost An Agent


Joined: 12 Jan 2004
Posts: 1375

Reputation: 15.8Reputation: 15.8
votes: 2

PostPosted: Tue Jun 06, 2006 3:50 pm    Post subject: Reply with quote

You can require perl files eg:

Code:
require("xx.pl");
Back to top
mattaustin
Sentinel
Sentinel


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

PostPosted: Tue Jun 06, 2006 7:01 pm    Post subject: Reply with quote

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
Newbie


Joined: 05 Jun 2006
Posts: 29

Reputation: 1.1

PostPosted: Wed Jun 07, 2006 10:41 am    Post subject: Reply with quote

: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 Sad


Last edited by svennson on Tue Feb 20, 2007 8:45 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 Jun 07, 2006 11:59 am    Post subject: Reply with quote

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 Wink (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
Newbie


Joined: 05 Jun 2006
Posts: 29

Reputation: 1.1

PostPosted: Wed Jun 07, 2006 3:51 pm    Post subject: Reply with quote

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
Upgraded Agent


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

PostPosted: Wed Jun 07, 2006 5:40 pm    Post subject: Reply with quote

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
Newbie


Joined: 05 Jun 2006
Posts: 29

Reputation: 1.1

PostPosted: Wed Jun 07, 2006 7:15 pm    Post subject: Reply with quote

but the connect sub he does.

so there isn't a option to include ?
Back to top
svennson
Newbie
Newbie


Joined: 05 Jun 2006
Posts: 29

Reputation: 1.1

PostPosted: Wed Jun 07, 2006 7:22 pm    Post subject: Reply with quote

hehe Smile found it changed the direction placed the while loop under it thanks Smile
Back to top
eric256
The Keymaker
The Keymaker


Joined: 03 May 2006
Posts: 2292
Location: Colorado
Reputation: 47Reputation: 47Reputation: 47Reputation: 47Reputation: 47

PostPosted: Wed Jun 07, 2006 9:54 pm    Post subject: Reply with quote

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
Newbie


Joined: 05 Jun 2006
Posts: 29

Reputation: 1.1

PostPosted: Thu Jun 08, 2006 3:47 pm    Post subject: Reply with quote

owkee Smile thx
Back to top
Display posts from previous:   
Post new topic   Reply to topic    Bot Depot Forum Index -> Code Help 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