1
0
mirror of https://github.com/irssi/irssi.git synced 2024-09-29 04:45:57 -04:00

Format RPL_HELPSTART/RPL_HELPTXT/RPL_ENDOFHELP

They are typical replies when using the HELP command.
This commit is contained in:
Valentin Lorentz 2022-04-01 15:52:54 +02:00 committed by Ailin Nemui
parent e300fee93d
commit 3a3301e19b
3 changed files with 59 additions and 2 deletions

View File

@ -554,6 +554,54 @@ static void event_489(IRC_SERVER_REC *server, const char *data, const char *nick
g_free(params);
}
static void event_help(IRC_SERVER_REC *server, int formatnum, const char *data) {
/* Common handling for umerics 704 (RPL_HELPSTART), 705 (RPL_HELPTXT),
* and 706 (RPL_ENDOFHELP); sent as a reply to HELP or HELPOP command.
*/
char *params, *topic, *help_text;
g_return_if_fail(data != NULL);
params = event_get_params(data, 3, NULL, &topic, &help_text);
g_return_if_fail(help_text != NULL);
if (help_text[0] == '\0') {
/* Empty lines can be used by servers for styling; and we need to replace
* them with something non-empty or they would be dropped when displayed.
*/
help_text = " ";
}
printformat(server, NULL, MSGLEVEL_CRAP, formatnum,
topic, help_text);
g_free(params);
}
static void event_helpstart(IRC_SERVER_REC *server, const char *data,
const char *nick)
{
/* Numeric 704 (RPL_HELPSTART) sent as a reply to HELP or HELPOP command.
*/
event_help(server, IRCTXT_HELP_START, data);
}
static void event_helptxt(IRC_SERVER_REC *server, const char *data,
const char *nick)
{
/* Numeric 705 (RPL_HELPTXT), sent as a reply to HELP or HELPOP command.
*/
event_help(server, IRCTXT_HELP_TXT, data);
}
static void event_endofhelp(IRC_SERVER_REC *server, const char *data,
const char *nick)
{
/* Numeric 706 (RPL_ENDOFHELP), sent as a reply to HELP or HELPOP command.
*/
event_help(server, IRCTXT_END_OF_HELP, data);
}
static void event_target_too_fast(IRC_SERVER_REC *server, const char *data,
const char *nick)
{
@ -713,6 +761,9 @@ void fe_events_numeric_init(void)
signal_add("event 372", (SIGNAL_FUNC) event_motd);
signal_add("event 422", (SIGNAL_FUNC) event_motd);
signal_add("event 439", (SIGNAL_FUNC) event_target_too_fast);
signal_add("event 704", (SIGNAL_FUNC) event_helpstart);
signal_add("event 705", (SIGNAL_FUNC) event_helptxt);
signal_add("event 706", (SIGNAL_FUNC) event_endofhelp);
signal_add("event 707", (SIGNAL_FUNC) event_target_too_fast);
signal_add("default event numeric", (SIGNAL_FUNC) event_numeric);

View File

@ -89,6 +89,9 @@ FORMAT_REC fecommon_irc_formats[] = {
{ "invitelist_long", "{channel $0}: invite {ban $1} {comment by {nick $2}, $3 secs ago}", 4, { 0, 0, 0, 1 } },
{ "no_such_channel", "{channel $0}: No such channel", 1, { 0 } },
{ "channel_synced", "Join to {channel $0} was synced in {hilight $1} secs", 2, { 0, 2 } },
{ "irctxt_help_start", "$1", 2, { 0, 0 } },
{ "irctxt_help_txt", "$1", 2, { 0, 0 } },
{ "irctxt_end_of_help", "$1", 2, { 0, 0 } },
/* ---- */
{ NULL, "Nick", 0 },

View File

@ -66,6 +66,9 @@ enum {
IRCTXT_INVITELIST_LONG,
IRCTXT_NO_SUCH_CHANNEL,
IRCTXT_CHANNEL_SYNCED,
IRCTXT_HELP_START,
IRCTXT_HELP_TXT,
IRCTXT_END_OF_HELP,
IRCTXT_FILL_4,
@ -89,7 +92,7 @@ enum {
IRCTXT_WHOIS_OPER,
IRCTXT_WHOIS_MODES,
IRCTXT_WHOIS_REALHOST,
IRCTXT_WHOIS_USERMODE,
IRCTXT_WHOIS_USERMODE,
IRCTXT_WHOIS_CHANNELS,
IRCTXT_WHOIS_AWAY,
IRCTXT_WHOIS_SPECIAL,
@ -143,7 +146,7 @@ enum {
IRCTXT_SILENCED,
IRCTXT_UNSILENCED,
IRCTXT_SILENCE_LINE,
IRCTXT_ASK_OPER_PASS,
IRCTXT_ASK_OPER_PASS,
IRCTXT_ACCEPT_LIST
};
/* clang-format on */