X-Git-Url: https://jfr.im/git/irc/evilnet/x3.git/blobdiff_plain/7827220c933cf2fd53437d1285b639a49b213508..50220e579db9eb8e9d5ade20154302ec750da8ab:/src/global.c diff --git a/src/global.c b/src/global.c index 0faf87b..2a50d50 100644 --- a/src/global.c +++ b/src/global.c @@ -5,7 +5,7 @@ * * x3 is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or + * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, @@ -81,6 +81,8 @@ static const struct message_entry msgtab[] = { { "HSMSG_BOT_REGISTERED", "HelpServ %s (%s) registered to %s by %s." }, { "HSMSG_BOT_EXPIRED", "HelpServ %s (%s) expired at request of %s." }, { "HSMSG_BOT_UNREGISTERED", "HelpServ %s (%s) unregistered by %s." }, + { "HSMSG_SUSPENDED_BY", "%s suspended by %s. (HelpServ)" }, + { "HSMSG_UNSUSPENDED_BY", "%s unsuspended by %s. (HelpServ)" }, /* nickserv.c */ { "NSMSG_ACCOUNT_RENAMED", "%s renamed account %s to %s." }, @@ -243,6 +245,8 @@ message_create(struct userNode *user, unsigned int argc, char *argv[]) if(!irccasecmp(argv[i], "all")) { flags |= MESSAGE_RECIPIENT_ALL; + } else if(!irccasecmp(argv[i], "authed")) { + flags |= MESSAGE_RECIPIENT_AUTHED; } else if(!irccasecmp(argv[i], "users")) { flags |= MESSAGE_RECIPIENT_LUSERS; } else if(!irccasecmp(argv[i], "helpers")) { @@ -253,6 +257,8 @@ message_create(struct userNode *user, unsigned int argc, char *argv[]) flags |= MESSAGE_RECIPIENT_STAFF; } else if(!irccasecmp(argv[i], "channels")) { flags |= MESSAGE_RECIPIENT_CHANNELS; + } else if(!irccasecmp(argv[i], "rchannels")) { + flags |= MESSAGE_RECIPIENT_RCHANNELS; } else if(!irccasecmp(argv[i], "announcement") || !irccasecmp(argv[i], "announce")) { flags |= MESSAGE_RECIPIENT_ANNOUNCE; } else { @@ -309,6 +315,14 @@ messageType(const struct globalMessage *message) { return "users"; } + else if(message->flags & MESSAGE_RECIPIENT_AUTHED) + { + return "authed"; + } + else if(message->flags & MESSAGE_RECIPIENT_RCHANNELS) + { + return "rchannels"; + } else { return "channels"; @@ -352,7 +366,25 @@ message_send(struct globalMessage *message) if(message->flags & MESSAGE_RECIPIENT_CHANNELS) { - dict_foreach(channels, notice_channel, message); + dict_iterator_t it; + + for (it = dict_first(channels); it; it = iter_next(it)) { + struct chanNode *chan = iter_data(it); + + notice_target(chan->name, message); + } + } + + if(message->flags & MESSAGE_RECIPIENT_RCHANNELS) + { + dict_iterator_t it; + + for (it = dict_first(channels); it; it = iter_next(it)) { + struct chanNode *chan = iter_data(it); + + if (chan->channel_info) + notice_target(chan->name, message); + } } if(message->flags & MESSAGE_RECIPIENT_LUSERS) @@ -398,6 +430,16 @@ message_send(struct globalMessage *message) notice_target(user->nick, message); } } + + if(message->flags & MESSAGE_RECIPIENT_AUTHED) + { + dict_iterator_t it; + for (it = dict_first(clients); it; it = iter_next(it)) { + struct userNode *luser = iter_data(it); + if (luser->handle_info) + notice_target(luser->nick, message); + } + } } void @@ -424,6 +466,9 @@ global_message_args(long targets, const char *language_entry, ...) vsnprintf(response, MAXLEN-2, language_entry, arg_list); response[MAXLEN-1] = 0; + if (message) + message_del(message); + message = message_add(targets | MESSAGE_OPTION_SOURCELESS, now, 0, "", response); if (!message) continue; @@ -433,7 +478,8 @@ global_message_args(long targets, const char *language_entry, ...) if(luser->uplink != self) notice_target(luser->nick, message); - if ((message->flags & MESSAGE_RECIPIENT_LUSERS) || (message->flags & MESSAGE_RECIPIENT_HELPERS)) + if ((message->flags & MESSAGE_RECIPIENT_LUSERS) || (message->flags & MESSAGE_RECIPIENT_HELPERS) || + (message->flags & MESSAGE_RECIPIENT_AUTHED)) continue; } @@ -441,13 +487,23 @@ global_message_args(long targets, const char *language_entry, ...) if (message->flags & MESSAGE_RECIPIENT_HELPERS && IsHelper(luser)) { notice_target(luser->nick, message); - if (message->flags & MESSAGE_RECIPIENT_LUSERS) + if ((message->flags & MESSAGE_RECIPIENT_LUSERS) || (message->flags & MESSAGE_RECIPIENT_AUTHED)) continue; } + /* authed */ + if ((message->flags & MESSAGE_RECIPIENT_AUTHED) && luser->handle_info) { + notice_target(luser->nick, message); + + if (message->flags & MESSAGE_RECIPIENT_LUSERS) + continue; + } + /* users */ - if (message->flags & MESSAGE_RECIPIENT_LUSERS) + if (message->flags & MESSAGE_RECIPIENT_LUSERS) { notice_target(luser->nick, message); + + } } message_del(message); @@ -482,6 +538,8 @@ static GLOBAL_FUNC(cmd_notice) target = MESSAGE_RECIPIENT_ALL; } else if(!irccasecmp(argv[1], "users")) { target = MESSAGE_RECIPIENT_LUSERS; + } else if(!irccasecmp(argv[1], "authed")) { + target = MESSAGE_RECIPIENT_AUTHED; } else if(!irccasecmp(argv[1], "helpers")) { target = MESSAGE_RECIPIENT_HELPERS; } else if(!irccasecmp(argv[1], "opers")) { @@ -492,6 +550,8 @@ static GLOBAL_FUNC(cmd_notice) target |= MESSAGE_RECIPIENT_ANNOUNCE; } else if(!irccasecmp(argv[1], "channels")) { target = MESSAGE_RECIPIENT_CHANNELS; + } else if(!irccasecmp(argv[1], "rchannels")) { + target = MESSAGE_RECIPIENT_RCHANNELS; } else { global_notice(user, "GMSG_INVALID_TARGET", argv[1]); return 0; @@ -645,7 +705,7 @@ send_messages(struct userNode *user, long mask, int obstreperize) static GLOBAL_FUNC(cmd_messages) { - long mask = MESSAGE_RECIPIENT_LUSERS | MESSAGE_RECIPIENT_CHANNELS; + long mask = MESSAGE_RECIPIENT_AUTHED | MESSAGE_RECIPIENT_LUSERS | MESSAGE_RECIPIENT_CHANNELS | MESSAGE_RECIPIENT_RCHANNELS; unsigned int count; if(IsOper(user))