unsigned int announcements_default : 1;
} global_conf;
-#define global_notice(target, format...) send_message(target , global , ## format)
+#if defined(GCC_VARMACROS)
+# define global_notice(target, ARGS...) send_message(target, global, ARGS)
+#elif defined(C99_VARMACROS)
+# define global_notice(target, ...) send_message(target, global, __VA_ARGS__)
+#endif
void message_expire(void *data);
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")) {
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 {
{
return "users";
}
+ else if(message->flags & MESSAGE_RECIPIENT_AUTHED)
+ {
+ return "authed";
+ }
+ else if(message->flags & MESSAGE_RECIPIENT_RCHANNELS)
+ {
+ return "rchannels";
+ }
else
{
return "channels";
send_target_message(4, target, global, "%s", message->message);
}
-static int
-notice_channel(const char *key, void *data, void *extra)
-{
- struct chanNode *channel = data;
- /* It should be safe to assume channel is not NULL. */
- if(channel->channel_info)
- notice_target(key, extra);
- return 0;
-}
-
static void
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)
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
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;
}
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);
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")) {
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;
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))
}
static int
-global_process_user(struct userNode *user)
+global_process_user(struct userNode *user, UNUSED_ARG(void *extra))
{
if(IsLocal(user) || self->uplink->burst || user->uplink->burst)
return 0;
}
static void
-global_process_auth(struct userNode *user, UNUSED_ARG(struct handle_info *old_handle))
+global_process_auth(struct userNode *user, UNUSED_ARG(struct handle_info *old_handle), UNUSED_ARG(void *extra))
{
if(IsHelper(user))
send_messages(user, MESSAGE_RECIPIENT_HELPERS, 0);
}
static void
-global_process_oper(struct userNode *user)
+global_process_oper(struct userNode *user, UNUSED_ARG(void *extra))
{
if(user->uplink->burst)
return;
}
static void
-global_db_cleanup(void)
+global_db_cleanup(UNUSED_ARG(void *extra))
{
while(messageList)
message_del(messageList);
struct chanNode *chan;
unsigned int i;
G_LOG = log_register_type("Global", "file:global.log");
- reg_new_user_func(global_process_user);
- reg_auth_func(global_process_auth);
- reg_oper_func(global_process_oper);
+ reg_new_user_func(global_process_user, NULL);
+ reg_auth_func(global_process_auth, NULL);
+ reg_oper_func(global_process_oper, NULL);
conf_register_reload(global_conf_read);
if(nick)
{
const char *modes = conf_get_data("services/global/modes", RECDB_QSTRING);
- global = AddService(nick, modes ? modes : NULL, "Global Services", NULL);
+ global = AddLocalUser(nick, nick, NULL, "Global Services", modes);
global_service = service_register(global);
}
}
saxdb_register("Global", global_saxdb_read, global_saxdb_write);
- reg_exit_func(global_db_cleanup);
+ reg_exit_func(global_db_cleanup, NULL);
message_register_table(msgtab);
}