diff options
author | Timo Sirainen <cras@irssi.org> | 2001-01-28 03:17:55 +0000 |
---|---|---|
committer | cras <cras@dbcabf3a-b0e7-0310-adc4-f8d773084564> | 2001-01-28 03:17:55 +0000 |
commit | f6e9160bc93a26843f149d73f4297117c96a21ac (patch) | |
tree | dac567d241b9b6d128a35291e5176b23ecadc5b3 /src/fe-common/irc/fe-netjoin.c | |
parent | 00492856da793220840d7f1fc1b4126083bf1dc4 (diff) | |
download | irssi-f6e9160bc93a26843f149d73f4297117c96a21ac.zip |
Netjoin mode printing: handle +v and +h like +o was handled (joins:
@opnick +voicenick %halfopick)
git-svn-id: http://svn.irssi.org/repos/irssi/trunk@1145 dbcabf3a-b0e7-0310-adc4-f8d773084564
Diffstat (limited to 'src/fe-common/irc/fe-netjoin.c')
-rw-r--r-- | src/fe-common/irc/fe-netjoin.c | 33 |
1 files changed, 24 insertions, 9 deletions
diff --git a/src/fe-common/irc/fe-netjoin.c b/src/fe-common/irc/fe-netjoin.c index 916a1985..f1ce1197 100644 --- a/src/fe-common/irc/fe-netjoin.c +++ b/src/fe-common/irc/fe-netjoin.c @@ -185,7 +185,7 @@ static void print_netjoins(NETJOIN_SERVER_REC *server) next = tmp->next; while (rec->now_channels != NULL) { char *channel = rec->now_channels->data; - char *realchannel = channel + (*channel == '@'); + char *realchannel = channel + isnickflag(*channel); temp = g_hash_table_lookup(channels, realchannel); if (temp == NULL) { @@ -198,8 +198,9 @@ static void print_netjoins(NETJOIN_SERVER_REC *server) temp->count++; if (temp->count <= netjoin_max_nicks) { - if (*channel == '@') - g_string_append_c(temp->nicks, '@'); + if (isnickflag(*channel)) + g_string_append_c(temp->nicks, + *channel); g_string_sprintfa(temp->nicks, "%s, ", rec->nick); } @@ -321,20 +322,34 @@ static void msg_join(IRC_SERVER_REC *server, const char *channel, signal_stop(); } -static int netjoin_set_operator(NETJOIN_REC *rec, const char *channel, int on) +static int netjoin_set_nickmode(NETJOIN_REC *rec, const char *channel, + char mode) { GSList *pos; + char *oldchannel; pos = gslist_find_icase_string(rec->now_channels, channel); if (pos == NULL) return FALSE; + oldchannel = pos->data; + if (isnickflag(*oldchannel) && mode != '\0') { + /* already set some mode, should we use old or new one? */ + if (mode == '+' || (mode == '%' && *oldchannel == '@')) + return TRUE; + } + g_free(pos->data); - pos->data = !on ? g_strdup(channel) : - g_strconcat("@", channel, NULL); + pos->data = mode == '\0' ? g_strdup(channel) : + g_strdup_printf("%c%s", mode, channel); return TRUE; } +#define isnickmode(c) \ + ((c) == 'o' || (c) == 'v' || (c) == 'h') +#define nickmodechar(c) \ + ((c) == 'o' ? '@' : ((c) == 'v' ? '+' : ((c) == 'h' ? '%' : '\0'))) + static void msg_mode(IRC_SERVER_REC *server, const char *channel, const char *sender, const char *addr, const char *data) { @@ -361,11 +376,11 @@ static void msg_mode(IRC_SERVER_REC *server, const char *channel, continue; } - if (*mode == 'o' && *nick != NULL) { + if (*nick != NULL && isnickmode(*mode)) { /* give/remove ops */ rec = netjoin_find(server, *nick); - if (rec == NULL || - !netjoin_set_operator(rec, channel, type == '+')) + if (rec == NULL || !netjoin_set_nickmode(rec, channel, + nickmodechar(type))) show = TRUE; nick++; } else { |