1
0
mirror of https://github.com/irssi/irssi.git synced 2024-11-03 04:27:19 -05:00

Merge pull request #82 from ailin-nemui/progval-help

Format RPL_HELPSTART/RPL_HELPTXT/RPL_ENDOFHELP

(cherry picked from commit b446d06b9d)
This commit is contained in:
ailin-nemui 2022-04-21 23:02:17 +02:00 committed by Ailin Nemui
parent 1598c88cfd
commit afed542bfb
4 changed files with 60 additions and 3 deletions

View File

@ -6,7 +6,7 @@
#define IRSSI_GLOBAL_CONFIG "irssi.conf" /* config file name in /etc/ */
#define IRSSI_HOME_CONFIG "config" /* config file name in ~/.irssi/ */
#define IRSSI_ABI_VERSION 44
#define IRSSI_ABI_VERSION 45
#define DEFAULT_SERVER_ADD_PORT 6667
#define DEFAULT_SERVER_ADD_TLS_PORT 6697

View File

@ -554,6 +554,51 @@ 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_SERVER_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_SERVER_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_SERVER_END_OF_HELP, data);
}
static void event_target_too_fast(IRC_SERVER_REC *server, const char *data,
const char *nick)
{
@ -713,6 +758,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);
@ -808,6 +856,9 @@ void fe_events_numeric_deinit(void)
signal_remove("event 372", (SIGNAL_FUNC) event_motd);
signal_remove("event 422", (SIGNAL_FUNC) event_motd);
signal_remove("event 439", (SIGNAL_FUNC) event_target_too_fast);
signal_remove("event 704", (SIGNAL_FUNC) event_helpstart);
signal_remove("event 705", (SIGNAL_FUNC) event_helptxt);
signal_remove("event 706", (SIGNAL_FUNC) event_endofhelp);
signal_remove("event 707", (SIGNAL_FUNC) event_target_too_fast);
signal_remove("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 } },
{ "server_help_start", "$1", 2, { 0, 0 } },
{ "server_help_txt", "$1", 2, { 0, 0 } },
{ "server_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_SERVER_HELP_START,
IRCTXT_SERVER_HELP_TXT,
IRCTXT_SERVER_END_OF_HELP,
IRCTXT_FILL_4,