Changeset d474ee9 for perl/modules/Jabber/lib/BarnOwl/Module/Jabber/Impl.pm
- Timestamp:
- Mar 13, 2012, 1:55:24 PM (12 years ago)
- Children:
- f421190
- Parents:
- 3e34a69
- git-author:
- David Benjamin <davidben@mit.edu> (03/13/12 13:52:23)
- git-committer:
- David Benjamin <davidben@mit.edu> (03/13/12 13:55:24)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
perl/modules/Jabber/lib/BarnOwl/Module/Jabber/Impl.pm
r3e34a69 rd474ee9 65 65 our %completion_jids; 66 66 67 # Called by BarnOwl::Module::Jabber. 67 68 sub onStart { 68 if ( *BarnOwl::queue_message{CODE} ) { 69 register_owl_commands(); 70 register_keybindings(); 71 register_filters(); 72 $BarnOwl::Hooks::getBuddyList->add("BarnOwl::Module::Jabber::Impl::onGetBuddyList"); 73 $BarnOwl::Hooks::getQuickstart->add("BarnOwl::Module::Jabber::Impl::onGetQuickstart"); 74 $vars{show} = ''; 75 BarnOwl::new_variable_bool("jabber:show_offline_buddies", 76 { default => 1, 77 summary => 'Show offline or pending buddies.'}); 78 BarnOwl::new_variable_bool("jabber:show_logins", 79 { default => 0, 80 summary => 'Show login/logout messages.'}); 81 BarnOwl::new_variable_bool("jabber:spew", 82 { default => 0, 83 summary => 'Display unrecognized Jabber messages.'}); 84 BarnOwl::new_variable_int("jabber:auto_away_timeout", 85 { default => 5, 86 summary => 'After minutes idle, auto away.', 87 }); 88 BarnOwl::new_variable_int("jabber:auto_xa_timeout", 89 { default => 15, 90 summary => 'After minutes idle, auto extended away.' 91 }); 92 BarnOwl::new_variable_bool("jabber:reconnect", 93 { default => 1, 94 summary => 'Auto-reconnect when disconnected from servers.' 95 }); 96 # Force these. Reload can screw them up. 97 # Taken from Net::Jabber::Protocol. 98 $Net::XMPP::Protocol::NEWOBJECT{'iq'} = "Net::Jabber::IQ"; 99 $Net::XMPP::Protocol::NEWOBJECT{'message'} = "Net::Jabber::Message"; 100 $Net::XMPP::Protocol::NEWOBJECT{'presence'} = "Net::Jabber::Presence"; 101 $Net::XMPP::Protocol::NEWOBJECT{'jid'} = "Net::Jabber::JID"; 102 } else { 103 # Our owl doesn't support queue_message. Unfortunately, this 104 # means it probably *also* doesn't support BarnOwl::error. So just 105 # give up silently. 106 } 107 } 108 109 $BarnOwl::Hooks::startup->add("BarnOwl::Module::Jabber::Impl::onStart"); 69 $BarnOwl::Hooks::getBuddyList->add("BarnOwl::Module::Jabber::Impl::onGetBuddyList"); 70 71 $vars{show} = ''; 72 73 # Force these. Reload can screw them up. 74 # Taken from Net::Jabber::Protocol. 75 $Net::XMPP::Protocol::NEWOBJECT{'iq'} = "Net::Jabber::IQ"; 76 $Net::XMPP::Protocol::NEWOBJECT{'message'} = "Net::Jabber::Message"; 77 $Net::XMPP::Protocol::NEWOBJECT{'presence'} = "Net::Jabber::Presence"; 78 $Net::XMPP::Protocol::NEWOBJECT{'jid'} = "Net::Jabber::JID"; 79 } 110 80 111 81 sub do_keep_alive_and_auto_away { … … 253 223 } 254 224 255 sub onGetQuickstart {256 return <<'EOF'257 @b(Jabber:)258 Type ':jabberlogin @b(username@mit.edu)' to log in to Jabber. The command259 ':jroster sub @b(somebody@gmail.com)' will request that they let you message260 them. Once you get a message saying you are subscribed, you can message261 them by typing ':jwrite @b(somebody@gmail.com)' or just 'j @b(somebody)'.262 EOF263 }264 265 225 ################################################################################ 266 226 ### Owl Commands 267 sub register_owl_commands() {268 BarnOwl::new_command(269 jabberlogin => \&cmd_login,270 {271 summary => "Log in to Jabber",272 usage => "jabberlogin <jid> [<password>]"273 }274 );275 BarnOwl::new_command(276 jabberlogout => \&cmd_logout,277 {278 summary => "Log out of Jabber",279 usage => "jabberlogout [-A|<jid>]",280 description => "jabberlogout logs you out of Jabber.\n\n"281 . "If you are connected to one account, no further arguments are necessary.\n\n"282 . "-A Log out of all accounts.\n"283 . "<jid> Which account to log out of.\n"284 }285 );286 BarnOwl::new_command(287 jwrite => \&cmd_jwrite,288 {289 summary => "Send a Jabber Message",290 usage => "jwrite <jid> [-t <thread>] [-s <subject>] [-a <account>] [-m <message>]"291 }292 );293 BarnOwl::new_command(294 jaway => \&cmd_jaway,295 {296 summary => "Set Jabber away / presence information",297 usage => "jaway [-s online|dnd|...] [<message>]"298 }299 );300 BarnOwl::new_command(301 jlist => \&cmd_jlist,302 {303 summary => "Show your Jabber roster.",304 usage => "jlist"305 }306 );307 BarnOwl::new_command(308 jmuc => \&cmd_jmuc,309 {310 summary => "Jabber MUC related commands.",311 description => "jmuc sends Jabber commands related to MUC.\n\n"312 . "The following commands are available\n\n"313 . "join <muc>[/<nick>]\n"314 . " Join a MUC (with a given nickname, or otherwise your JID).\n\n"315 . "part <muc> Part a MUC.\n"316 . " The MUC is taken from the current message if not supplied.\n\n"317 . "invite <jid> [<muc>]\n"318 . " Invite <jid> to <muc>.\n"319 . " The MUC is taken from the current message if not supplied.\n\n"320 . "configure [<muc>]\n"321 . " Configures a MUC.\n"322 . " Necessary to initalize a new MUC.\n"323 . " At present, only the default configuration is supported.\n"324 . " The MUC is taken from the current message if not supplied.\n\n"325 . "presence [<muc>]\n"326 . " Shows the roster for <muc>.\n"327 . " The MUC is taken from the current message if not supplied.\n\n"328 . "presence -a\n"329 . " Shows rosters for all MUCs you're participating in.\n\n",330 usage => "jmuc <command> [<args>]"331 }332 );333 BarnOwl::new_command(334 jroster => \&cmd_jroster,335 {336 summary => "Jabber roster related commands.",337 description => "jroster sends Jabber commands related to rosters.\n\n"338 . "The following commands are available\n\n"339 . "sub <jid> Subscribe to <jid>'s presence. (implicit add)\n\n"340 . "add <jid> Adds <jid> to your roster.\n\n"341 . "unsub <jid> Unsubscribe from <jid>'s presence.\n\n"342 . "remove <jid> Removes <jid> from your roster. (implicit unsub)\n\n"343 . "auth <jid> Authorizes <jid> to subscribe to your presence.\n\n"344 . "deauth <jid> De-authorizes <jid>'s subscription to your presence.\n\n"345 . "The following arguments are supported for all commands\n\n"346 . "-a <jid> Specify which account to make the roster changes on.\n"347 . " Required if you're signed into more than one account.\n\n"348 . "The following arguments only work with the add and sub commands.\n\n"349 . "-g <group> Add <jid> to group <group>.\n"350 . " May be specified more than once, will not remove <jid> from any groups.\n\n"351 . "-p Purge. Removes <jid> from all groups.\n"352 . " May be combined with -g.\n\n"353 . "-n <name> Sets <name> as <jid>'s short name.\n\n"354 . "Note: Unless -n is used, you can specify multiple <jid> arguments.\n",355 usage => "jroster <command> <args>"356 }357 );358 }359 360 sub register_keybindings {361 BarnOwl::bindkey(qw(recv j command start-command), 'jwrite ');362 }363 364 sub register_filters {365 BarnOwl::filter(qw(jabber type ^jabber$));366 }367 227 368 228 sub cmd_login {
Note: See TracChangeset
for help on using the changeset viewer.