Agent-TCLI

 view release on metacpan or  search on metacpan

bin/agent_tail.pl  view on Meta::CPAN

# Optional Packages, without some, a bot is useless
use Agent::TCLI::Package::XMPP;		# Not required, but very useful to manage Transport::XMPP
									# especially if you want a graceful shutdown. :)
use Agent::TCLI::Package::Tail;

# An alias is mostly useful when debugging, and must be unique within
# active POE::Sessions
my $alias = 'agent.tail';

# Create new package objects to load for each package.
# Some packages may require extra parameters.

my @packages = (
	Agent::TCLI::Package::XMPP->new(
	     'verbose'    => \$verbose ,	# Optionally set verbosity for the package
	     								# by using a reference, we can later
	     								# change globally while running
	),
	Agent::TCLI::Package::Tail->new(
	     'verbose'    => \$verbose ,
	),
);

# Define the authorized users of the Agent.

my @users = (
	# If the Tail agent is to be controlled by a test script, then the user the
	# test script will be run as has to be a user here.
	# It is OK to use the same XMPP user as long as the resource is different.
	Agent::TCLI::User->new(
		'id'		=> $username.'@'.$domain,
		'protocol'	=> 'xmpp',
		'auth'		=> 'master',
	),
#	Agent::TCLI::User->new(
#		'id'		=> 'user1@'.$domain,
#		'protocol'	=> 'xmpp',
#		'auth'		=> 'master',
#	),
#	Agent::TCLI::User->new(
#		'id'		=> 'user2@'.$domain,
#		'protocol'	=> 'xmpp',
#		'auth'		=> 'master',
#	),

# xmpp_groupchat users will cause an Agent to join the groupchat MUC

#	Agent::TCLI::User->new(
#		'id'		=> 'conference_room@conference'.$domain,
#		'protocol'	=> 'xmpp_groupchat',
#		'auth'		=> 'master',
#	),
);

Agent::TCLI::Transport::XMPP->new(
     'jid'		=> Net::XMPP::JID->new($username.'@'.$domain.'/'.$resource),
     'jserver'	=> $host,
	 'jpassword'=> $password,
	 'peers'	=> \@users,

	 'xmpp_process_time'=> 1,

     'verbose'    => \$verbose,        # Verbose sets level or warnings

     'control_options'	=> {
	     'packages' 		=> \@packages,
     },
);

print "Starting ".$alias unless $verbose;

# Required to start the Agent
POE::Kernel->run();

print" FINISHED";

exit;



( run in 1.835 second using v1.01-cache-2.11-cpan-6aa56a78535 )