Add empty handlers for chat-joined and chat-left signals.
[pidgin-purple-perl-plugins.git] / login-to-userserv.pl
blob1efcf0bef74f83ef982dbe9a25248596695de19a
1 use Purple;
3 my $login = "mcepl";
4 my $password = "kyrios";
5 my $loggedAccount = "mcepl\@porky.stuttgart.redhat.com";
7 my %loggedInServers = ();
9 # send-message("$botname $logins{$server} $passwds{$server}")
10 my %loggins = ();
11 my %passwds = ();
13 $botname = "USERSERV";
14 %PLUGIN_INFO = (
15 perl_api_version => 2,
16 name => "Perl: Login to $botname",
17 version => "0.2",
18 summary => "Logs to $botname on RH IRC",
19 description => "Send login to $botname on login to the IRC account.",
20 author => "Matěj Cepl <mcepl\@redhat.com>",
21 url => "http://matej.ceplovi.cz",
22 load => "plugin_load",
23 unload => "plugin_unload",
26 #(00:25:06) charding: Can anyone tell me what's the difference
27 #between the 'signing-on' and 'account-connecting' signals? Is
28 #signing-on for when pidgin is starting up? and account-connecting
29 #is when pidgin is already running and you enable and that
30 #particular acct is connecting?
31 #(00:29:18) elb: charding: as best I can tell, the only difference is that
32 #signing-on is called for both registration and regular
33 #connection, and account-connecting is called only for the later
34 #(00:29:22) elb: latter
35 #(00:29:28) elb: they're emitted one right after another in
36 #purple_connection_new
39 sub plugin_load {
40 Purple::Debug::info("loginRHIRC", "start paramterers=@_\n");
41 $plugin = shift;
43 $conn = Purple::Connections::get_handle();
44 Purple::Signal::connect($conn, "signed-on", $plugin,
45 \&signed_on, 0);
46 Purple::Signal::connect($conn, "chat-joined", $plugin,
47 \&joined_chatroom, 0);
48 Purple::Debug::info("loginRHIRC", "Login to $botname plugin loaded\n");
51 sub plugin_unload {
52 Purple::Debug::info("loginRHIRC", "Login to $botname plugin unloaded\n");
55 sub signed_on {
56 my $conn = shift;
57 my $account = $conn->get_account();
58 my $username = $account->get_username();
59 Purple::Debug::misc("loginRHIRC", "signed-on (" . $username . ")\n");
61 # login to USERSERV
62 if ($username eq $loggedAccount) {
63 my $ret = Purple::Prpl::send_raw($conn,
64 ":$login PRIVMSG $botname :login $login $password\n");
65 Purple::Debug::misc("loginRHIRC", "ret=$ret\n");
68 # Purple::timeout_add();
69 sleep(10);
71 my @allChats = Purple::get_ims();
72 my @allTitles = map($_->get_title(),@allChats);
73 Purple::Debug::misc("loginRHIRC", "\@allTitles=@allTitles\n");
74 Purple::Debug::misc("loginRHIRC", "Purple::get_ims() = " . Purple::get_ims());
75 my @userservChats = grep ((
76 $_->get_title() =~ /^\W*$botname\W*$/
77 ), Purple::get_ims());
78 $userservChats[1]->destroy();
81 sub joined_chatroom {
82 my $conn = shift; # *PurpleConversation
83 my $IRCserver = "";
84 my $IRCgateway = "";
85 my $account = $conn->get_account();
86 my $identificator = $account->get_username();
87 my $proto = $account->protocol_id();
88 Purple::Debug::misc("loginRHIRC", "opened $identificator, with protocol = $proto.\n");
90 # if server(MUC-JID) in nickservs:
91 # send-message("Nickserv!$server@IRCgateway",
92 # "identify $passwds{$server}")
93 # elif server(MUC-JID) in userservs:
94 # send-message("$botname $logins{$server} $passwds{$server}")