Merge hubmaier:/home/matej/archiv/programky/eclipse/pidgin-plugins
[pidgin-purple-perl-plugins.git] / login-to-userserv.pl
blobe04773d9500e1cf53aaed5bebbeb644709b8f6c3
1 use Purple;
3 my $login = "mcepl";
4 my $password = "kyrios";
5 my $loggedAccount = "mcepl\@porky.stuttgart.redhat.com";
7 $botname = "USERSERV";
8 %PLUGIN_INFO = (
9 perl_api_version => 2,
10 name => "Perl: Login to $botname",
11 version => "0.1",
12 summary => "Logs to $botname on RH IRC",
13 description => "Send login to $botname on login to the IRC account.",
14 author => "Matěj Cepl <mcepl\@redhat.com>",
15 url => "http://matej.ceplovi.cz",
16 load => "plugin_load",
17 unload => "plugin_unload",
20 #(00:25:06) charding: Can anyone tell me what's the difference
21 #between the 'signing-on' and 'account-connecting' signals? Is
22 #signing-on for when pidgin is starting up? and account-connecting
23 #is when pidgin is already running and you enable and that
24 #particular acct is connecting?
25 #(00:29:18) elb: charding: as best I can tell, the only difference is that
26 #signing-on is called for both registration and regular
27 #connection, and account-connecting is called only for the later
28 #(00:29:22) elb: latter
29 #(00:29:28) elb: they're emitted one right after another in
30 #purple_connection_new
33 sub plugin_load {
34 Purple::Debug::info("loginRHIRC", "start paramterers=@_\n");
35 $plugin = shift;
37 $conn = Purple::Connections::get_handle();
38 Purple::Signal::connect($conn, "signed-on", $plugin,
39 \&signed_on, 0);
40 Purple::Debug::info("loginRHIRC", "Login to $botname plugin loaded\n");
43 sub plugin_unload {
44 Purple::Debug::info("loginRHIRC", "Login to $botname plugin unloaded\n");
47 sub signed_on {
48 my $conn = shift;
49 my $account = $conn->get_account();
50 my $username = $account->get_username();
51 Purple::Debug::misc("loginRHIRC", "signed-on (" . $username . ")\n");
53 # login to USERSERV
54 if ($username eq $loggedAccount) {
55 my $ret = Purple::Prpl::send_raw($conn,
56 ":$login PRIVMSG $botname :login $login $password\n");
57 Purple::Debug::misc("loginRHIRC", "ret=$ret\n");
60 # Purple::timeout_add();
61 sleep(10);
63 my @allChats = Purple::get_ims();
64 my @allTitles = map($_->get_title(),@allChats);
65 Purple::Debug::misc("loginRHIRC", "\@allTitles=@allTitles\n");
66 Purple::Debug::misc("loginRHIRC", "Purple::get_ims() = " . Purple::get_ims());
67 my @userservChats = grep ((
68 $_->get_title() =~ /^\W*$botname\W*$/
69 ), Purple::get_ims());
70 $userservChats[1]->destroy();