Allow plugins to modify or append command help text; broke the command help down into pieces which also will aid translators in future, as the entire message blob won't change every time something gets fiddled with.

This commit is contained in:
Brion Vibber 2011-03-16 16:52:37 -07:00
parent e36959d451
commit bd12546984
2 changed files with 84 additions and 41 deletions

View File

@ -911,45 +911,88 @@ class HelpCommand extends Command
{ {
function handle($channel) function handle($channel)
{ {
$channel->output($this->user, // TRANS: Header line of help text for commands.
// TRANS: Help text for commands. Do not translate the command names themselves; they are fixed strings. $out = array(_m('COMMANDHELP', "Commands:"));
_("Commands:\n". $commands = array(// TRANS: Help message for IM/SMS command "on"
"on - turn on notifications\n". "on" => _m('COMMANDHELP', "turn on notifications"),
"off - turn off notifications\n". // TRANS: Help message for IM/SMS command "off"
"help - show this help\n". "off" => _m('COMMANDHELP', "turn off notifications"),
"follow <nickname> - subscribe to user\n". // TRANS: Help message for IM/SMS command "help"
"groups - lists the groups you have joined\n". "help" => _m('COMMANDHELP', "show this help"),
"subscriptions - list the people you follow\n". // TRANS: Help message for IM/SMS command "follow <nickname>"
"subscribers - list the people that follow you\n". "follow <nickname>" => _m('COMMANDHELP', "subscribe to user"),
"leave <nickname> - unsubscribe from user\n". // TRANS: Help message for IM/SMS command "groups"
"d <nickname> <text> - direct message to user\n". "groups" => _m('COMMANDHELP', "lists the groups you have joined"),
"get <nickname> - get last notice from user\n". // TRANS: Help message for IM/SMS command "subscriptions"
"whois <nickname> - get profile info on user\n". "subscriptions" => _m('COMMANDHELP', "list the people you follow"),
"lose <nickname> - force user to stop following you\n". // TRANS: Help message for IM/SMS command "subscribers"
"fav <nickname> - add user's last notice as a 'fave'\n". "subscribers" => _m('COMMANDHELP', "list the people that follow you"),
"fav #<notice_id> - add notice with the given id as a 'fave'\n". // TRANS: Help message for IM/SMS command "leave <nickname>"
"repeat #<notice_id> - repeat a notice with a given id\n". "leave <nickname>" => _m('COMMANDHELP', "unsubscribe from user"),
"repeat <nickname> - repeat the last notice from user\n". // TRANS: Help message for IM/SMS command "d <nickname> <text>"
"reply #<notice_id> - reply to notice with a given id\n". "d <nickname> <text>" => _m('COMMANDHELP', "direct message to user"),
"reply <nickname> - reply to the last notice from user\n". // TRANS: Help message for IM/SMS command "get <nickname>"
"join <group> - join group\n". "get <nickname>" => _m('COMMANDHELP', "get last notice from user"),
"login - Get a link to login to the web interface\n". // TRANS: Help message for IM/SMS command "whois <nickname>"
"drop <group> - leave group\n". "whois <nickname>" => _m('COMMANDHELP', "get profile info on user"),
"stats - get your stats\n". // TRANS: Help message for IM/SMS command "lose <nickname>"
"stop - same as 'off'\n". "lose <nickname>" => _m('COMMANDHELP', "force user to stop following you"),
"quit - same as 'off'\n". // TRANS: Help message for IM/SMS command "fav <nickname>"
"sub <nickname> - same as 'follow'\n". "fav <nickname>" => _m('COMMANDHELP', "add user's last notice as a 'fave'"),
"unsub <nickname> - same as 'leave'\n". // TRANS: Help message for IM/SMS command "fav #<notice_id>"
"last <nickname> - same as 'get'\n". "fav #<notice_id>" => _m('COMMANDHELP', "add notice with the given id as a 'fave'"),
"on <nickname> - not yet implemented.\n". // TRANS: Help message for IM/SMS command "repeat #<notice_id>"
"off <nickname> - not yet implemented.\n". "repeat #<notice_id>" => _m('COMMANDHELP', "repeat a notice with a given id"),
"nudge <nickname> - remind a user to update.\n". // TRANS: Help message for IM/SMS command "repeat <nickname>"
"invite <phone number> - not yet implemented.\n". "repeat <nickname>" => _m('COMMANDHELP', "repeat the last notice from user"),
"track <word> - not yet implemented.\n". // TRANS: Help message for IM/SMS command "reply #<notice_id>"
"untrack <word> - not yet implemented.\n". "reply #<notice_id>" => _m('COMMANDHELP', "reply to notice with a given id"),
"track off - not yet implemented.\n". // TRANS: Help message for IM/SMS command "reply <nickname>"
"untrack all - not yet implemented.\n". "reply <nickname>" => _m('COMMANDHELP', "reply to the last notice from user"),
"tracks - not yet implemented.\n". // TRANS: Help message for IM/SMS command "join <group>"
"tracking - not yet implemented.\n")); "join <group>" => _m('COMMANDHELP', "join group"),
// TRANS: Help message for IM/SMS command "login"
"login" => _m('COMMANDHELP', "Get a link to login to the web interface"),
// TRANS: Help message for IM/SMS command "drop <group>"
"drop <group>" => _m('COMMANDHELP', "leave group"),
// TRANS: Help message for IM/SMS command "stats"
"stats" => _m('COMMANDHELP', "get your stats"),
// TRANS: Help message for IM/SMS command "stop"
"stop" => _m('COMMANDHELP', "same as 'off'"),
// TRANS: Help message for IM/SMS command "quit"
"quit" => _m('COMMANDHELP', "same as 'off'"),
// TRANS: Help message for IM/SMS command "sub <nickname>"
"sub <nickname>" => _m('COMMANDHELP', "same as 'follow'"),
// TRANS: Help message for IM/SMS command "unsub <nickname>"
"unsub <nickname>" => _m('COMMANDHELP', "same as 'leave'"),
// TRANS: Help message for IM/SMS command "last <nickname>"
"last <nickname>" => _m('COMMANDHELP', "same as 'get'"),
// TRANS: Help message for IM/SMS command "on <nickname>"
"on <nickname>" => _m('COMMANDHELP', "not yet implemented."),
// TRANS: Help message for IM/SMS command "off <nickname>"
"off <nickname>" => _m('COMMANDHELP', "not yet implemented."),
// TRANS: Help message for IM/SMS command "nudge <nickname>"
"nudge <nickname>" => _m('COMMANDHELP', "remind a user to update."),
// TRANS: Help message for IM/SMS command "invite <phone number>"
"invite <phone number>" => _m('COMMANDHELP', "not yet implemented."),
// TRANS: Help message for IM/SMS command "track <word>"
"track <word>" => _m('COMMANDHELP', "not yet implemented."),
// TRANS: Help message for IM/SMS command "untrack <word>"
"untrack <word>" => _m('COMMANDHELP', "not yet implemented."),
// TRANS: Help message for IM/SMS command "track off"
"track off" => _m('COMMANDHELP', "not yet implemented."),
// TRANS: Help message for IM/SMS command "untrack all"
"untrack all" => _m('COMMANDHELP', "not yet implemented."),
// TRANS: Help message for IM/SMS command "tracks"
"tracks" => _m('COMMANDHELP', "not yet implemented."),
// TRANS: Help message for IM/SMS command "tracking"
"tracking" => _m('COMMANDHELP', "not yet implemented."));
// Give plugins a chance to add or override...
Event::handle('HelpCommandMessages', array($this, &$commands));
foreach ($commands as $command => $help) {
$out[] = "$command - $help";
}
$channel->output($this->user, implode("\n", $out));
} }
} }

View File

@ -314,7 +314,7 @@ class CommandInterpreter
$result = false; $result = false;
} }
Event::handle('EndInterpretCommand', array($cmd, $arg, $user, $result)); Event::handle('EndInterpretCommand', array($cmd, $arg, $user, &$result));
} }
return $result; return $result;