ikd |
Отметившийся |
|
|
Joined: 18 May 2007 |
Posts: 16 |
|
|
|
|
|
|
|
проще некуда:
Code: | :#! /usr/bin/perl
use strict;
use warnings;
use Net::XMPP;
my $hostName = '';
my $portNumber = 5222;
my $componentName = '';
my $userName = '';
my $passWord = '';
my $resource = 'bot';
my $tls = 0;
my $connectionType = 'tcpip';
my $debugLevel = 0;
my $bot = new Net::XMPP::Client(debuglevel => $debugLevel);
$bot->SetCallBacks(
onconnect => \&connectedCB,
onauth => \&authedCB,
ondisconnect => \&disconnectedCB,
);
$bot->SetMessageCallBacks(
chat => \&messageCB,
);
$bot->Execute(
hostname => $hostName,
port => $portNumber,
tls => $tls,
username => $userName,
password => $passWord,
resource => $resource,
register => 0,
connectiontype => $connectionType,
);
sub messageCB {
my $sid = shift;
my $msg = shift;
my $from = $msg->GetFrom;
my $to = $msg->GetTo;
my $name;
my $data;
print "From : ", $from, "\n",
"Subject : ", $msg->GetSubject, "\n",
$msg->GetBody, "\n";
$name = $msg->GetBody;
$data = $msg->GetBody;
print ">>$name\n";
print $data, "\n";
$bot->MessageSend(
to => $from,
from => $to,
resource => '',
type => $msg->GetType,
subject => $msg->GetSubject,
body => $data,
);
}
sub connectedCB {
print "Connected\n";
}
sub authedCB {
print "Authed\n";
$bot->PresenceSend;
}
sub disconnectedCB {
print "Disconnected\n";
} |
Логинится. Принимает сообщение, отправляет его обратно. |
|