Advertisement
bvn13

Untitled

Oct 13th, 2012
280
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.68 KB | None | 0 0
  1. #!/usr/bin/perl -w
  2.  
  3. use strict;
  4. use warnings;
  5.  
  6. use utf8;
  7. use locale;
  8. #use Encode;
  9. #use encoding 'utf8';
  10.  
  11. use AnyEvent;
  12. use AnyEvent::XMPP::Client;
  13. use AnyEvent::XMPP::Ext::Disco;
  14. #use AnyEvent::XMPP::Ext::Version;
  15. use AnyEvent::XMPP::Namespaces qw/xmpp_ns/;
  16.  
  17. #use AnyEvent::XMPP::IM::Connection;
  18.  
  19. #my $jCon = AnyEvent::XMPP::IM::Connection->new(
  20. # username => "bvn13",
  21. # domain => "jabber.org",
  22. # password => "",
  23. # resource => "testingtest"
  24. #);
  25.  
  26. my $JID = 'boyko_vn@jabber.ru';
  27. my $PASS = '';
  28.  
  29. my $j = AnyEvent::->condvar;
  30. my $jClient = AnyEvent::XMPP::Client->new(debug=>1);
  31. my $disco = AnyEvent::XMPP::Ext::Disco->new;
  32. #my $version = AnyEvent::XMPP::Ext::Version->new;
  33. #$jClient->start;
  34.  
  35. $jClient->add_extension($disco);
  36. #$jClient->add_extension($version);
  37.  
  38. $jClient->set_presence(undef, "testingtest", 1);
  39.  
  40. $jClient->add_account($JID, $PASS);
  41. warn "Connecting to $JID...\n";
  42.  
  43. $jClient->reg_cb(
  44. session_ready => sub {
  45. my ($jClient, $account) = @_;
  46. warn "connected!\n";
  47. },
  48. disconnect => sub {
  49. warn "Got disconnected: [@_]\n";
  50. #$jClient->broadcast;
  51. },
  52. connected => sub {
  53. my ($jClient, $account) = @_;
  54.  
  55. print "Connected... $account\n";
  56. },
  57. connect_error => sub {
  58. my ($jClient, $account, $error) = @_;
  59.  
  60. die "ERROR! $error\n";
  61. },
  62. error => sub {
  63. my ($jClient, $account, $error) = @_;
  64.  
  65. die "ERROR! $error\n";
  66. },
  67. added_account => sub {
  68. my ($jClient, $account) = @_;
  69.  
  70. print "Account added...$account\n";
  71. },
  72. removed_account => sub {
  73. my ($jClient, $account) = @_;
  74.  
  75. print "Account removed...$account\n";
  76. }
  77. );
  78.  
  79.  
  80.  
  81. $jClient->start;
  82. $j->wait;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement