mirror of
https://github.com/irssi/irssi.git
synced 2024-12-04 14:46:39 -05:00
Introduce some more chantypes awareness
This commit is contained in:
parent
35d30c19a1
commit
57d645f246
@ -42,6 +42,9 @@
|
|||||||
#include "fe-windows.h"
|
#include "fe-windows.h"
|
||||||
#include "fe-irc-server.h"
|
#include "fe-irc-server.h"
|
||||||
|
|
||||||
|
int fe_channel_is_opchannel(IRC_SERVER_REC *server, const char *target);
|
||||||
|
const char *fe_channel_skip_prefix(IRC_SERVER_REC *server, const char *target);
|
||||||
|
|
||||||
static void event_privmsg(IRC_SERVER_REC *server, const char *data,
|
static void event_privmsg(IRC_SERVER_REC *server, const char *data,
|
||||||
const char *nick, const char *addr)
|
const char *nick, const char *addr)
|
||||||
{
|
{
|
||||||
@ -52,12 +55,14 @@ static void event_privmsg(IRC_SERVER_REC *server, const char *data,
|
|||||||
params = event_get_params(data, 2 | PARAM_FLAG_GETREST, &target, &msg);
|
params = event_get_params(data, 2 | PARAM_FLAG_GETREST, &target, &msg);
|
||||||
if (nick == NULL) nick = server->real_address;
|
if (nick == NULL) nick = server->real_address;
|
||||||
if (addr == NULL) addr = "";
|
if (addr == NULL) addr = "";
|
||||||
if (*target == '@' && server_ischannel(SERVER(server), &target[1])) {
|
|
||||||
|
if (fe_channel_is_opchannel(server, target)) {
|
||||||
/* Hybrid 6 feature, send msg to all ops in channel */
|
/* Hybrid 6 feature, send msg to all ops in channel */
|
||||||
recoded = recode_in(SERVER(server), msg, target+1);
|
target = (char *)fe_channel_skip_prefix(server, target);
|
||||||
|
recoded = recode_in(SERVER(server), msg, target);
|
||||||
signal_emit("message irc op_public", 5,
|
signal_emit("message irc op_public", 5,
|
||||||
server, recoded, nick, addr,
|
server, recoded, nick, addr,
|
||||||
get_visible_target(server, target+1));
|
get_visible_target(server, target));
|
||||||
} else {
|
} else {
|
||||||
recoded = recode_in(SERVER(server), msg, server_ischannel(SERVER(server), target) ? target : nick);
|
recoded = recode_in(SERVER(server), msg, server_ischannel(SERVER(server), target) ? target : nick);
|
||||||
signal_emit(server_ischannel(SERVER(server), target) ?
|
signal_emit(server_ischannel(SERVER(server), target) ?
|
||||||
|
@ -37,28 +37,47 @@
|
|||||||
#include "fe-queries.h"
|
#include "fe-queries.h"
|
||||||
#include "window-items.h"
|
#include "window-items.h"
|
||||||
|
|
||||||
static const char *skip_target(IRC_SERVER_REC *server, const char *target)
|
int fe_channel_is_opchannel(IRC_SERVER_REC *server, const char *target)
|
||||||
{
|
{
|
||||||
int i = 0;
|
const char *statusmsg;
|
||||||
const char *val, *chars;
|
|
||||||
|
/* Quick check */
|
||||||
|
if (server == NULL || server->prefix[(int)(unsigned char)*target] == 0)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
statusmsg = g_hash_table_lookup(server->isupport, "statusmsg");
|
||||||
|
if (statusmsg == NULL)
|
||||||
|
statusmsg = "@+";
|
||||||
|
|
||||||
|
return strchr(statusmsg, *target) != NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *fe_channel_skip_prefix(IRC_SERVER_REC *server, const char *target)
|
||||||
|
{
|
||||||
|
const char *statusmsg;
|
||||||
|
|
||||||
/* Quick check */
|
/* Quick check */
|
||||||
if (server == NULL || server->prefix[(int)(unsigned char)*target] == 0)
|
if (server == NULL || server->prefix[(int)(unsigned char)*target] == 0)
|
||||||
return target;
|
return target;
|
||||||
|
|
||||||
|
/* Exit early if target doesn't name a channel */
|
||||||
|
if (server_ischannel(SERVER(server), target) == FALSE)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
statusmsg = g_hash_table_lookup(server->isupport, "statusmsg");
|
||||||
|
|
||||||
/* Hack: for bahamut 1.4 which sends neither STATUSMSG nor
|
/* Hack: for bahamut 1.4 which sends neither STATUSMSG nor
|
||||||
* WALLCHOPS in 005, accept @#chan and @+#chan (but not +#chan) */
|
* WALLCHOPS in 005, accept @#chan and @+#chan (but not +#chan) */
|
||||||
val = g_hash_table_lookup(server->isupport, "STATUSMSG");
|
if (statusmsg == NULL && *target != '@')
|
||||||
if (val == NULL && *target != '@')
|
|
||||||
return target;
|
return target;
|
||||||
chars = val ? val : "@+";
|
|
||||||
for(i = 0; target[i] != '\0'; i++) {
|
|
||||||
if (strchr(chars, target[i]) == NULL)
|
|
||||||
break;
|
|
||||||
};
|
|
||||||
|
|
||||||
if(server_ischannel(SERVER(server), &target[i]))
|
if (statusmsg == NULL)
|
||||||
target += i;
|
statusmsg = "@+";
|
||||||
|
|
||||||
|
/* Strip the leading statusmsg prefixes */
|
||||||
|
while (strchr(statusmsg, *target) != NULL) {
|
||||||
|
target++;
|
||||||
|
}
|
||||||
|
|
||||||
return target;
|
return target;
|
||||||
}
|
}
|
||||||
@ -72,7 +91,7 @@ static void sig_message_own_public(SERVER_REC *server, const char *msg,
|
|||||||
if (!IS_IRC_SERVER(server))
|
if (!IS_IRC_SERVER(server))
|
||||||
return;
|
return;
|
||||||
oldtarget = target;
|
oldtarget = target;
|
||||||
target = skip_target(IRC_SERVER(server), target);
|
target = fe_channel_skip_prefix(IRC_SERVER(server), target);
|
||||||
if (target != oldtarget) {
|
if (target != oldtarget) {
|
||||||
/* Hybrid 6 / Bahamut feature, send msg to all
|
/* Hybrid 6 / Bahamut feature, send msg to all
|
||||||
ops / ops+voices in channel */
|
ops / ops+voices in channel */
|
||||||
@ -135,7 +154,7 @@ static void sig_message_own_action(IRC_SERVER_REC *server, const char *msg,
|
|||||||
char *freemsg = NULL;
|
char *freemsg = NULL;
|
||||||
|
|
||||||
oldtarget = target;
|
oldtarget = target;
|
||||||
target = skip_target(IRC_SERVER(server), target);
|
target = fe_channel_skip_prefix(IRC_SERVER(server), target);
|
||||||
if (server_ischannel(SERVER(server), target))
|
if (server_ischannel(SERVER(server), target))
|
||||||
item = irc_channel_find(server, target);
|
item = irc_channel_find(server, target);
|
||||||
else
|
else
|
||||||
@ -163,7 +182,7 @@ static void sig_message_irc_action(IRC_SERVER_REC *server, const char *msg,
|
|||||||
int own = FALSE;
|
int own = FALSE;
|
||||||
|
|
||||||
oldtarget = target;
|
oldtarget = target;
|
||||||
target = skip_target(IRC_SERVER(server), target);
|
target = fe_channel_skip_prefix(IRC_SERVER(server), target);
|
||||||
|
|
||||||
level = MSGLEVEL_ACTIONS |
|
level = MSGLEVEL_ACTIONS |
|
||||||
(server_ischannel(SERVER(server), target) ? MSGLEVEL_PUBLIC : MSGLEVEL_MSGS);
|
(server_ischannel(SERVER(server), target) ? MSGLEVEL_PUBLIC : MSGLEVEL_MSGS);
|
||||||
@ -219,7 +238,7 @@ static void sig_message_irc_action(IRC_SERVER_REC *server, const char *msg,
|
|||||||
static void sig_message_own_notice(IRC_SERVER_REC *server, const char *msg,
|
static void sig_message_own_notice(IRC_SERVER_REC *server, const char *msg,
|
||||||
const char *target)
|
const char *target)
|
||||||
{
|
{
|
||||||
printformat(server, skip_target(server, target), MSGLEVEL_NOTICES |
|
printformat(server, fe_channel_skip_prefix(server, target), MSGLEVEL_NOTICES |
|
||||||
MSGLEVEL_NOHILIGHT | MSGLEVEL_NO_ACT,
|
MSGLEVEL_NOHILIGHT | MSGLEVEL_NO_ACT,
|
||||||
IRCTXT_OWN_NOTICE, target, msg);
|
IRCTXT_OWN_NOTICE, target, msg);
|
||||||
}
|
}
|
||||||
@ -232,7 +251,7 @@ static void sig_message_irc_notice(SERVER_REC *server, const char *msg,
|
|||||||
int level = MSGLEVEL_NOTICES;
|
int level = MSGLEVEL_NOTICES;
|
||||||
|
|
||||||
oldtarget = target;
|
oldtarget = target;
|
||||||
target = skip_target(IRC_SERVER(server), target);
|
target = fe_channel_skip_prefix(IRC_SERVER(server), target);
|
||||||
|
|
||||||
if (address == NULL || *address == '\0') {
|
if (address == NULL || *address == '\0') {
|
||||||
/* notice from server */
|
/* notice from server */
|
||||||
@ -270,7 +289,7 @@ static void sig_message_irc_notice(SERVER_REC *server, const char *msg,
|
|||||||
static void sig_message_own_ctcp(IRC_SERVER_REC *server, const char *cmd,
|
static void sig_message_own_ctcp(IRC_SERVER_REC *server, const char *cmd,
|
||||||
const char *data, const char *target)
|
const char *data, const char *target)
|
||||||
{
|
{
|
||||||
printformat(server, skip_target(server, target), MSGLEVEL_CTCPS |
|
printformat(server, fe_channel_skip_prefix(server, target), MSGLEVEL_CTCPS |
|
||||||
MSGLEVEL_NOHILIGHT | MSGLEVEL_NO_ACT,
|
MSGLEVEL_NOHILIGHT | MSGLEVEL_NO_ACT,
|
||||||
IRCTXT_OWN_CTCP, target, cmd, data);
|
IRCTXT_OWN_CTCP, target, cmd, data);
|
||||||
}
|
}
|
||||||
@ -282,7 +301,7 @@ static void sig_message_irc_ctcp(IRC_SERVER_REC *server, const char *cmd,
|
|||||||
const char *oldtarget;
|
const char *oldtarget;
|
||||||
|
|
||||||
oldtarget = target;
|
oldtarget = target;
|
||||||
target = skip_target(server, target);
|
target = fe_channel_skip_prefix(server, target);
|
||||||
printformat(server, server_ischannel(SERVER(server), target) ? target : nick, MSGLEVEL_CTCPS,
|
printformat(server, server_ischannel(SERVER(server), target) ? target : nick, MSGLEVEL_CTCPS,
|
||||||
IRCTXT_CTCP_REQUESTED, nick, addr, cmd, data, oldtarget);
|
IRCTXT_CTCP_REQUESTED, nick, addr, cmd, data, oldtarget);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user