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

Merge pull request #1196 from mh-source/master

Add better support for numeric 489 ERR_SECUREONLYCHAN along with a print format
This commit is contained in:
ailin-nemui 2020-05-16 13:58:35 +02:00 committed by GitHub
commit 2a2f7b826d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 36 additions and 5 deletions

View File

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

View File

@ -511,8 +511,7 @@ static void event_bad_channel_mask(IRC_SERVER_REC *server, const char *data)
cannot_join(server, data, IRCTXT_JOINERROR_BAD_MASK); cannot_join(server, data, IRCTXT_JOINERROR_BAD_MASK);
} }
static void event_477(IRC_SERVER_REC *server, const char *data, static void event_477(IRC_SERVER_REC *server, const char *data, const char *nick)
const char *nick)
{ {
/* Numeric 477 can mean many things: /* Numeric 477 can mean many things:
* modeless channel, cannot join/send to channel (+r/+R/+M). * modeless channel, cannot join/send to channel (+r/+R/+M).
@ -531,6 +530,30 @@ static void event_477(IRC_SERVER_REC *server, const char *data,
g_free(params); g_free(params);
} }
static void event_489(IRC_SERVER_REC *server, const char *data, const char *nick)
{
/* Numeric 489 can mean one of two things things:
* cannot join to channel (secure only), or not chanop or voice.
* If we tried to join this channel, display the joinerror.
* Otherwise depending on the channel being joined or not
* display the error in the channel or status window.
*/
IRC_CHANNEL_REC *chanrec;
char *params, *channel;
g_return_if_fail(data != NULL);
params = event_get_params(data, 2, NULL, &channel);
chanrec = irc_channel_find(server, channel);
if (chanrec != NULL && !chanrec->joined) {
cannot_join(server, data, IRCTXT_JOINERROR_SECURE_ONLY);
} else {
print_event_received(server, data, nick, chanrec == NULL || chanrec->joined);
}
g_free(params);
}
static void event_target_too_fast(IRC_SERVER_REC *server, const char *data, static void event_target_too_fast(IRC_SERVER_REC *server, const char *data,
const char *nick) const char *nick)
{ {
@ -647,6 +670,7 @@ void fe_events_numeric_init(void)
last_away_nick = NULL; last_away_nick = NULL;
last_away_msg = NULL; last_away_msg = NULL;
/* clang-format off */
signal_add("event 221", (SIGNAL_FUNC) event_user_mode); signal_add("event 221", (SIGNAL_FUNC) event_user_mode);
signal_add("event 303", (SIGNAL_FUNC) event_ison); signal_add("event 303", (SIGNAL_FUNC) event_ison);
signal_add("event 353", (SIGNAL_FUNC) event_names_list); signal_add("event 353", (SIGNAL_FUNC) event_names_list);
@ -683,6 +707,7 @@ void fe_events_numeric_init(void)
signal_add("event 475", (SIGNAL_FUNC) event_bad_channel_key); signal_add("event 475", (SIGNAL_FUNC) event_bad_channel_key);
signal_add("event 476", (SIGNAL_FUNC) event_bad_channel_mask); signal_add("event 476", (SIGNAL_FUNC) event_bad_channel_mask);
signal_add("event 477", (SIGNAL_FUNC) event_477); signal_add("event 477", (SIGNAL_FUNC) event_477);
signal_add("event 489", (SIGNAL_FUNC) event_489); /* cannot join to channel (secure only), or not chanop or voice. */
signal_add("event 375", (SIGNAL_FUNC) event_motd); signal_add("event 375", (SIGNAL_FUNC) event_motd);
signal_add("event 376", (SIGNAL_FUNC) event_motd); signal_add("event 376", (SIGNAL_FUNC) event_motd);
signal_add("event 372", (SIGNAL_FUNC) event_motd); signal_add("event 372", (SIGNAL_FUNC) event_motd);
@ -726,13 +751,13 @@ void fe_events_numeric_init(void)
signal_add("event 478", (SIGNAL_FUNC) event_target_received); /* ban list is full */ signal_add("event 478", (SIGNAL_FUNC) event_target_received); /* ban list is full */
signal_add("event 482", (SIGNAL_FUNC) event_target_received); /* not chanop */ signal_add("event 482", (SIGNAL_FUNC) event_target_received); /* not chanop */
signal_add("event 486", (SIGNAL_FUNC) event_target_received); /* cannot /msg (+R) */ signal_add("event 486", (SIGNAL_FUNC) event_target_received); /* cannot /msg (+R) */
signal_add("event 489", (SIGNAL_FUNC) event_target_received); /* not chanop or voice */
signal_add("event 494", (SIGNAL_FUNC) event_target_received); /* cannot /msg (own +R) */ signal_add("event 494", (SIGNAL_FUNC) event_target_received); /* cannot /msg (own +R) */
signal_add("event 506", (SIGNAL_FUNC) event_target_received); /* cannot send (+R) */ signal_add("event 506", (SIGNAL_FUNC) event_target_received); /* cannot send (+R) */
signal_add("event 716", (SIGNAL_FUNC) event_target_received); /* cannot /msg (+g) */ signal_add("event 716", (SIGNAL_FUNC) event_target_received); /* cannot /msg (+g) */
signal_add("event 717", (SIGNAL_FUNC) event_target_received); /* +g notified */ signal_add("event 717", (SIGNAL_FUNC) event_target_received); /* +g notified */
signal_add("event 728", (SIGNAL_FUNC) event_target_received); /* quiet (or other) list */ signal_add("event 728", (SIGNAL_FUNC) event_target_received); /* quiet (or other) list */
signal_add("event 729", (SIGNAL_FUNC) event_target_received); /* end of quiet (or other) list */ signal_add("event 729", (SIGNAL_FUNC) event_target_received); /* end of quiet (or other) list */
/* clang-format on */
} }
void fe_events_numeric_deinit(void) void fe_events_numeric_deinit(void)
@ -776,6 +801,7 @@ void fe_events_numeric_deinit(void)
signal_remove("event 475", (SIGNAL_FUNC) event_bad_channel_key); signal_remove("event 475", (SIGNAL_FUNC) event_bad_channel_key);
signal_remove("event 476", (SIGNAL_FUNC) event_bad_channel_mask); signal_remove("event 476", (SIGNAL_FUNC) event_bad_channel_mask);
signal_remove("event 477", (SIGNAL_FUNC) event_477); signal_remove("event 477", (SIGNAL_FUNC) event_477);
signal_remove("event 489", (SIGNAL_FUNC) event_489);
signal_remove("event 375", (SIGNAL_FUNC) event_motd); signal_remove("event 375", (SIGNAL_FUNC) event_motd);
signal_remove("event 376", (SIGNAL_FUNC) event_motd); signal_remove("event 376", (SIGNAL_FUNC) event_motd);
signal_remove("event 372", (SIGNAL_FUNC) event_motd); signal_remove("event 372", (SIGNAL_FUNC) event_motd);
@ -815,7 +841,6 @@ void fe_events_numeric_deinit(void)
signal_remove("event 478", (SIGNAL_FUNC) event_target_received); signal_remove("event 478", (SIGNAL_FUNC) event_target_received);
signal_remove("event 482", (SIGNAL_FUNC) event_target_received); signal_remove("event 482", (SIGNAL_FUNC) event_target_received);
signal_remove("event 486", (SIGNAL_FUNC) event_target_received); signal_remove("event 486", (SIGNAL_FUNC) event_target_received);
signal_remove("event 489", (SIGNAL_FUNC) event_target_received);
signal_remove("event 494", (SIGNAL_FUNC) event_target_received); signal_remove("event 494", (SIGNAL_FUNC) event_target_received);
signal_remove("event 506", (SIGNAL_FUNC) event_target_received); signal_remove("event 506", (SIGNAL_FUNC) event_target_received);
signal_remove("event 716", (SIGNAL_FUNC) event_target_received); signal_remove("event 716", (SIGNAL_FUNC) event_target_received);

View File

@ -21,6 +21,7 @@
#include "module.h" #include "module.h"
#include <irssi/src/fe-common/core/formats.h> #include <irssi/src/fe-common/core/formats.h>
/* clang-format off */
FORMAT_REC fecommon_irc_formats[] = { FORMAT_REC fecommon_irc_formats[] = {
{ MODULE_NAME, "IRC", 0 }, { MODULE_NAME, "IRC", 0 },
@ -63,6 +64,7 @@ FORMAT_REC fecommon_irc_formats[] = {
{ "joinerror_banned", "Cannot join to channel {channel $0} (You are banned)", 1, { 0 } }, { "joinerror_banned", "Cannot join to channel {channel $0} (You are banned)", 1, { 0 } },
{ "joinerror_bad_key", "Cannot join to channel {channel $0} (Bad channel key)", 1, { 0 } }, { "joinerror_bad_key", "Cannot join to channel {channel $0} (Bad channel key)", 1, { 0 } },
{ "joinerror_bad_mask", "Cannot join to channel {channel $0} (Bad channel mask)", 1, { 0 } }, { "joinerror_bad_mask", "Cannot join to channel {channel $0} (Bad channel mask)", 1, { 0 } },
{ "joinerror_secure_only", "Cannot join to channel {channel $0} (Secure clients only)", 1, { 0 } },
{ "joinerror_unavail", "Cannot join to channel {channel $0} (Channel is temporarily unavailable)", 1, { 0 } }, { "joinerror_unavail", "Cannot join to channel {channel $0} (Channel is temporarily unavailable)", 1, { 0 } },
{ "joinerror_duplicate", "Channel {channel $0} already exists - cannot create it", 1, { 0 } }, { "joinerror_duplicate", "Channel {channel $0} already exists - cannot create it", 1, { 0 } },
{ "channel_rejoin", "Channel {channel $0} is temporarily unavailable, this is normally because of netsplits. Irssi will now automatically try to rejoin back to this channel until the join is successful. Use /RMREJOINS command if you wish to abort this.", 1, { 0 } }, { "channel_rejoin", "Channel {channel $0} is temporarily unavailable, this is normally because of netsplits. Irssi will now automatically try to rejoin back to this channel until the join is successful. Use /RMREJOINS command if you wish to abort this.", 1, { 0 } },
@ -175,3 +177,4 @@ FORMAT_REC fecommon_irc_formats[] = {
{ NULL, NULL, 0 } { NULL, NULL, 0 }
}; };
/* clang-format on */

View File

@ -1,5 +1,6 @@
#include <irssi/src/fe-common/core/formats.h> #include <irssi/src/fe-common/core/formats.h>
/* clang-format off */
enum { enum {
IRCTXT_MODULE_NAME, IRCTXT_MODULE_NAME,
@ -40,6 +41,7 @@ enum {
IRCTXT_JOINERROR_BANNED, IRCTXT_JOINERROR_BANNED,
IRCTXT_JOINERROR_BAD_KEY, IRCTXT_JOINERROR_BAD_KEY,
IRCTXT_JOINERROR_BAD_MASK, IRCTXT_JOINERROR_BAD_MASK,
IRCTXT_JOINERROR_SECURE_ONLY,
IRCTXT_JOINERROR_UNAVAIL, IRCTXT_JOINERROR_UNAVAIL,
IRCTXT_JOINERROR_DUPLICATE, IRCTXT_JOINERROR_DUPLICATE,
IRCTXT_CHANNEL_REJOIN, IRCTXT_CHANNEL_REJOIN,
@ -143,5 +145,6 @@ enum {
IRCTXT_ASK_OPER_PASS, IRCTXT_ASK_OPER_PASS,
IRCTXT_ACCEPT_LIST IRCTXT_ACCEPT_LIST
}; };
/* clang-format on */
extern FORMAT_REC fecommon_irc_formats[]; extern FORMAT_REC fecommon_irc_formats[];