Permalink
Browse files

treat msgs to +#channel the same way as @#channel

  • Loading branch information...
mauke committed Mar 14, 2012
1 parent ee4fee0 commit 932b8049939639788824eb9614d91c81732e5366
Showing with 28 additions and 8 deletions.
  1. +1 −0 docs/signals.txt
  2. +4 −3 src/fe-common/irc/fe-events.c
  3. +23 −5 src/fe-common/irc/fe-irc-messages.c
View
@@ -304,6 +304,7 @@ fe-events.c:
fe-irc-messages.c:
"message irc op_public", SERVER_REC, char *msg, char *nick, char *address, char *target
+ "message irc voice_public", SERVER_REC, char *msg, char *nick, char *address, char *target
"message irc own_wall", SERVER_REC, char *msg, char *target
"message irc own_action", SERVER_REC, char *msg, char *target
"message irc action", SERVER_REC, char *msg, char *nick, char *address, char *target
@@ -52,10 +52,11 @@ static void event_privmsg(IRC_SERVER_REC *server, const char *data,
params = event_get_params(data, 2 | PARAM_FLAG_GETREST, &target, &msg);
if (nick == NULL) nick = server->real_address;
if (addr == NULL) addr = "";
- if (*target == '@' && ischannel(target[1])) {
- /* Hybrid 6 feature, send msg to all ops in channel */
+ if ((*target == '@' || *target == '+') && ischannel(target[1])) {
+ /* Hybrid 6 feature, send msg to all ops/voiced in channel */
recoded = recode_in(SERVER(server), msg, target+1);
- signal_emit("message irc op_public", 5,
+ signal_emit(*target == '@' ?
+ "message irc op_public" : "message irc voice_public", 5,
server, recoded, nick, addr,
get_visible_target(server, target+1));
} else {
@@ -52,12 +52,9 @@ static const char *skip_target(IRC_SERVER_REC *server, const char *target)
if (val == NULL && *target != '@')
return target;
chars = val ? val : "@+";
- for(i = 0; target[i] != '\0'; i++) {
- if (strchr(chars, target[i]) == NULL)
- break;
- };
+ i = strspn(target, chars);
- if(ischannel(target[i]))
+ if (ischannel(target[i]))
target += i;
return target;
@@ -109,6 +106,25 @@ static void sig_message_irc_op_public(SERVER_REC *server, const char *msg,
g_free(optarget);
}
+/* received msg to all voices in channel */
+static void sig_message_irc_voice_public(SERVER_REC *server, const char *msg,
+ const char *nick, const char *address,
+ const char *target)
+{
+ char *nickmode, *vtarget;
+
+ nickmode = channel_get_nickmode(channel_find(server, target),
+ nick);
+
+ vtarget = g_strconcat("+", target, NULL);
+ printformat_module("fe-common/core", server, target,
+ MSGLEVEL_PUBLIC,
+ TXT_PUBMSG_CHANNEL,
+ nick, vtarget, msg, nickmode);
+ g_free(nickmode);
+ g_free(vtarget);
+}
+
static void sig_message_own_wall(SERVER_REC *server, const char *msg,
const char *target)
{
@@ -270,6 +286,7 @@ void fe_irc_messages_init(void)
{
signal_add_last("message own_public", (SIGNAL_FUNC) sig_message_own_public);
signal_add_last("message irc op_public", (SIGNAL_FUNC) sig_message_irc_op_public);
+ signal_add_last("message irc voice_public", (SIGNAL_FUNC) sig_message_irc_voice_public);
signal_add_last("message irc own_wall", (SIGNAL_FUNC) sig_message_own_wall);
signal_add_last("message irc own_action", (SIGNAL_FUNC) sig_message_own_action);
signal_add_last("message irc action", (SIGNAL_FUNC) sig_message_irc_action);
@@ -283,6 +300,7 @@ void fe_irc_messages_deinit(void)
{
signal_remove("message own_public", (SIGNAL_FUNC) sig_message_own_public);
signal_remove("message irc op_public", (SIGNAL_FUNC) sig_message_irc_op_public);
+ signal_remove("message irc voice_public", (SIGNAL_FUNC) sig_message_irc_voice_public);
signal_remove("message irc own_wall", (SIGNAL_FUNC) sig_message_own_wall);
signal_remove("message irc own_action", (SIGNAL_FUNC) sig_message_own_action);
signal_remove("message irc action", (SIGNAL_FUNC) sig_message_irc_action);

0 comments on commit 932b804

Please sign in to comment.