#include "conf.h"
#include "global.h"
#include "modcmd.h"
-#include "opserv.h" /* for opserv_bad_channel() */
+#include "opserv.h" /* for opserv_bad_channel() and devnull management */
#include "nickserv.h" /* for oper_outranks() */
#include "saxdb.h"
#include "spamserv.h"
/* User management */
{ "CSMSG_ADDED_USER", "Added %s to the %s user list with access %d." },
{ "CSMSG_DELETED_USER", "Deleted %s (with access %d) from the %s user list." },
- { "CSMSG_BAD_RANGE", "Invalid access range; minimum (%d) must be greater than maximum (%d)." },
+ { "CSMSG_BAD_RANGE", "Invalid access range; minimum (%d) must be lower than maximum (%d)." },
{ "CSMSG_DELETED_USERS", "Deleted accounts matching $b%s$b with access from $b%d$b to $b%d$b from the %s user list." },
{ "CSMSG_TRIMMED_USERS", "Trimmed $b%d users$b with access from %d to %d from the %s user list who were inactive for at least %s." },
{ "CSMSG_INCORRECT_ACCESS", "%s has access $b%d$b, not %s." },
{ "CSMSG_ACCESS_SEARCH_HEADER", "%s users from level %d to %d matching %s:" },
{ "CSMSG_INVALID_ACCESS", "$b%s$b is an invalid access level." },
{ "CSMSG_CHANGED_ACCESS", "%s now has access $b%d$b in %s." },
+ { "CSMSG_TOTAL_USERS", "There are $b%d$b users in %s." },
/* Channel note list */
{ "CSMSG_NOTELIST_HEADER", "Notes for $b%s$b:" },
{ "CSMSG_UC_H_TITLE", "network helper" },
{ "CSMSG_LC_H_TITLE", "support helper" },
{ "CSMSG_LAME_SMURF_TARGET", "%s is an IRC operator." },
- { "CSMSG_MYACCESS_COUNT", "%s has access in $b%d$b channels." },
- { "CSMSG_MYACCESS_COUNT_1", "%s has access in $b%d$b channel." },
+ { "CSMSG_MYACCESS_COUNT", "%s has access in $b%d$b channels and is owner of $b%d$b channel(s)." },
+ { "CSMSG_MYACCESS_COUNT_1", "%s has access in $b%d$b channel and is owner of $b%d$b channel(s)." },
+
/* Seen information */
{ "CSMSG_NEVER_SEEN", "%s has never been seen in $b%s$b." },
}
static void
-expire_channels(UNUSED_ARG(void *data))
+expire_channels(void *data)
{
struct chanData *channel, *next;
struct userData *user;
unregister_channel(channel, "registration expired.");
}
- if(chanserv_conf.channel_expire_frequency)
+ if(chanserv_conf.channel_expire_frequency && !data)
timeq_add(now + chanserv_conf.channel_expire_frequency, expire_channels, NULL);
}
return 0;
}
- if(IsProtected(cData))
+ if(IsProtected(cData) && !IsOper(user))
{
reply("CSMSG_UNREG_NODELETE", channel->name);
return 0;
unsigned int count;
unsigned long limit;
- actor = GetChannelAccess(channel->channel_info, user->handle_info);
+ actor = GetChannelUser(channel->channel_info, user->handle_info);
if(min_access > max_access)
{
send_message(user, chanserv, "CSMSG_BAD_RANGE", min_access, max_access);
return modify_users(CSFUNC_ARGS, NULL, MODE_REMOVE|MODE_VOICE, "CSMSG_DEVOICED_USERS");
}
+static CHANSERV_FUNC(cmd_opme)
+{
+ struct mod_chanmode change;
+ const char *errmsg;
+
+ mod_chanmode_init(&change);
+ change.argc = 1;
+ change.args[0].u.member = GetUserMode(channel, user);
+ if(!change.args[0].u.member)
+ {
+ if(argc)
+ reply("MSG_CHANNEL_ABSENT", channel->name);
+ return 0;
+ }
+
+ struct devnull_class *devnull;
+ if(user->handle_info->devnull && (devnull = devnull_get(user->handle_info->devnull)) && (devnull->modes & DEVNULL_MODE_OPME))
+ {
+ change.args[0].mode = MODE_CHANOP;
+ errmsg = "CSMSG_ALREADY_OPPED";
+ }
+ else
+ {
+ if(argc)
+ reply("CSMSG_NO_ACCESS");
+ return 0;
+ }
+ change.args[0].mode &= ~change.args[0].u.member->modes;
+ if(!change.args[0].mode)
+ {
+ if(argc)
+ reply(errmsg, channel->name);
+ return 0;
+ }
+ modcmd_chanmode_announce(&change);
+ return 1;
+}
+
static int
bad_channel_ban(struct chanNode *channel, struct userNode *user, const char *ban, unsigned int *victimCount, struct modeNode **victims)
{
struct handle_info *target_handle;
struct userData *uData;
int ccount = 0;
+ int ocount = 0;
if(argc < 2)
target_handle = user->handle_info;
{
struct chanData *cData = uData->channel;
ccount++;
+ unsigned int base_len;
if(uData->access > UL_OWNER)
continue;
+ if(uData->access == UL_OWNER)
+ ocount++;
+
if(IsProtected(cData)
&& (target_handle != user->handle_info)
- && !GetTrueChannelAccess(cData, user->handle_info))
+ && !GetTrueChannelAccess(cData, user->handle_info)
+ && !IsNetworkHelper(user))
continue;
sbuf.used = 0;
- string_buffer_append_printf(&sbuf, "[%s (%d", cData->channel->name, uData->access);
- if(uData->flags != USER_AUTO_OP)
- string_buffer_append(&sbuf, ',');
+ string_buffer_append_printf(&sbuf, "[%s (%d,", cData->channel->name, uData->access);
+ base_len = sbuf.used;
if(IsUserSuspended(uData))
string_buffer_append(&sbuf, 's');
if(IsUserAutoOp(uData))
}
if(IsUserAutoInvite(uData) && (uData->access >= cData->lvlOpts[lvlInviteMe]))
string_buffer_append(&sbuf, 'i');
+ if(sbuf.used==base_len)
+ sbuf.used--;
if(uData->info)
string_buffer_append_printf(&sbuf, ")] %s", uData->info);
else
}
if(ccount == 1) {
- reply("CSMSG_MYACCESS_COUNT_1", target_handle->handle, ccount);
+ reply("CSMSG_MYACCESS_COUNT_1", target_handle->handle, ccount, ocount);
} else {
- reply("CSMSG_MYACCESS_COUNT", target_handle->handle, ccount);
+ reply("CSMSG_MYACCESS_COUNT", target_handle->handle, ccount, ocount);
}
return 1;
return 1;
}
-static void
-zoot_list(struct listData *list)
-{
- struct userData *uData;
- unsigned int start, curr, highest, lowest;
- struct helpfile_table tmp_table;
- const char **temp, *msg;
-
- if(list->table.length == 1)
- {
- if(list->search)
- send_message(list->user, list->bot, "CSMSG_ACCESS_SEARCH_HEADER", list->channel->name, list->lowest, list->highest, list->search);
- else
- send_message(list->user, list->bot, "CSMSG_ACCESS_ALL_HEADER", list->channel->name, list->lowest, list->highest);
- msg = user_find_message(list->user, "MSG_NONE");
- send_message_type(4, list->user, list->bot, " %s", msg);
- }
- tmp_table.width = list->table.width;
- tmp_table.flags = list->table.flags;
- list->table.contents[0][0] = " ";
- highest = list->highest;
- if(list->lowest != 0)
- lowest = list->lowest;
- else if(highest < 100)
- lowest = 1;
- else
- lowest = highest - 100;
- for(start = curr = 1; curr < list->table.length; )
- {
- uData = list->users[curr-1];
- list->table.contents[curr++][0] = " ";
- if((curr == list->table.length) || (list->users[curr-1]->access < lowest))
- {
- if(list->search)
- send_message(list->user, list->bot, "CSMSG_ACCESS_SEARCH_HEADER", list->channel->name, lowest, highest, list->search);
- else
- send_message(list->user, list->bot, "CSMSG_ACCESS_ALL_HEADER", list->channel->name, lowest, highest);
- temp = list->table.contents[--start];
- list->table.contents[start] = list->table.contents[0];
- tmp_table.contents = list->table.contents + start;
- tmp_table.length = curr - start;
- table_send(list->bot, list->user->nick, 0, NULL, tmp_table);
- list->table.contents[start] = temp;
- start = curr;
- highest = lowest - 1;
- lowest = (highest < 100) ? 0 : (highest - 99);
- }
- }
-}
-
static void
def_list(struct listData *list)
{
lData.highest = highest;
lData.search = (argc > 1) ? argv[1] : NULL;
send_list = def_list;
- (void)zoot_list; /* since it doesn't show user levels */
if(user->handle_info)
{
}
free(lData.table.contents[0]);
free(lData.table.contents);
+ reply("CSMSG_TOTAL_USERS",(lData.table.length - 1),channel->name);
return 1;
}
static CHANSERV_FUNC(cmd_invite)
{
- struct userData *uData;
struct userNode *invite;
struct ChanUser *chanuser;
unsigned int i;
- uData = GetChannelUser(channel->channel_info, user->handle_info);
-
if(argc > 1)
{
if(!(invite = GetUserH(argv[1])))
static CHANSERV_FUNC(cmd_expire)
{
int channel_count = registered_channels;
- expire_channels(NULL);
+ expire_channels(chanserv);
reply("CSMSG_CHANNELS_EXPIRED", channel_count - registered_channels);
return 1;
}
str = database_get_data(conf_node, KEY_SUPPORT_HELPER_EPITHET, RECDB_QSTRING);
chanserv_conf.support_helper_epithet = str ? str : "a wannabe tyrant";
str = database_get_data(conf_node, KEY_NEW_CHANNEL_AUTHED, RECDB_QSTRING);
- chanserv_conf.new_channel_authed = str ? str : NULL;
+ chanserv_conf.new_channel_authed = (str && *str) ? str : NULL;
str = database_get_data(conf_node, KEY_NEW_CHANNEL_UNAUTHED, RECDB_QSTRING);
- chanserv_conf.new_channel_unauthed = str ? str : NULL;
+ chanserv_conf.new_channel_unauthed = (str && *str) ? str : NULL;
str = database_get_data(conf_node, KEY_NEW_CHANNEL_MSG, RECDB_QSTRING);
- chanserv_conf.new_channel_msg = str ? str : NULL;
+ chanserv_conf.new_channel_msg = (str && *str) ? str : NULL;
str = database_get_data(conf_node, "default_modes", RECDB_QSTRING);
if(!str)
str = "+nt";
static void
ban_read_helper(const char *key, struct record_data *rd, struct chanData *chan)
{
- struct banData *bData;
char *set, *triggered, *s_duration, *s_expires, *reason, *owner;
unsigned long set_time, triggered_time, expires_time;
if(!reason || (expires_time && (expires_time < now)))
return;
- bData = add_channel_ban(chan, key, owner, set_time, triggered_time, expires_time, reason);
+ add_channel_ban(chan, key, owner, set_time, triggered_time, expires_time, reason);
}
static struct suspended *
DEFINE_COMMAND(unf, 1, 0, "flags", "+nolog,+toy,+acceptchan", NULL);
DEFINE_COMMAND(ping, 1, 0, "flags", "+nolog,+toy,+acceptchan", NULL);
DEFINE_COMMAND(wut, 1, 0, "flags", "+nolog,+toy,+acceptchan", NULL);
- DEFINE_COMMAND(8ball, 1, 0, "flags", "+nolog,+toy,+acceptchan", NULL);
- DEFINE_COMMAND(d, 1, 0, "flags", "+nolog,+toy,+acceptchan", NULL);
+ DEFINE_COMMAND(8ball, 2, 0, "flags", "+nolog,+toy,+acceptchan", NULL);
+ DEFINE_COMMAND(d, 2, 0, "flags", "+nolog,+toy,+acceptchan", NULL);
DEFINE_COMMAND(huggle, 1, 0, "flags", "+nolog,+toy,+acceptchan", NULL);
- DEFINE_COMMAND(addvote, 1, MODCMD_REQUIRE_AUTHED, NULL);
- DEFINE_COMMAND(delvote, 1, MODCMD_REQUIRE_AUTHED, NULL);
- DEFINE_COMMAND(addoption, 1, MODCMD_REQUIRE_AUTHED, NULL);
- DEFINE_COMMAND(deloption, 1, MODCMD_REQUIRE_AUTHED, NULL);
- DEFINE_COMMAND(vote, 1, MODCMD_REQUIRE_AUTHED, NULL);
- DEFINE_COMMAND(startvote, 1, MODCMD_REQUIRE_AUTHED, NULL);
- DEFINE_COMMAND(endvote, 1, MODCMD_REQUIRE_AUTHED, NULL);
- DEFINE_COMMAND(voteresults, 1, MODCMD_REQUIRE_AUTHED, NULL);
-
+ DEFINE_COMMAND(addvote, 1, MODCMD_REQUIRE_AUTHED | MODCMD_REQUIRE_REGCHAN, NULL);
+ DEFINE_COMMAND(delvote, 1, MODCMD_REQUIRE_AUTHED | MODCMD_REQUIRE_REGCHAN, NULL);
+ DEFINE_COMMAND(addoption, 1, MODCMD_REQUIRE_AUTHED | MODCMD_REQUIRE_REGCHAN, NULL);
+ DEFINE_COMMAND(deloption, 1, MODCMD_REQUIRE_AUTHED | MODCMD_REQUIRE_REGCHAN, NULL);
+ DEFINE_COMMAND(vote, 1, MODCMD_REQUIRE_AUTHED | MODCMD_REQUIRE_REGCHAN, NULL);
+ DEFINE_COMMAND(startvote, 1, MODCMD_REQUIRE_AUTHED | MODCMD_REQUIRE_REGCHAN, NULL);
+ DEFINE_COMMAND(endvote, 1, MODCMD_REQUIRE_AUTHED | MODCMD_REQUIRE_REGCHAN, NULL);
+ DEFINE_COMMAND(voteresults, 1, MODCMD_REQUIRE_AUTHED | MODCMD_REQUIRE_REGCHAN, NULL);
+
+ DEFINE_COMMAND(opme, 1, MODCMD_REQUIRE_AUTHED|MODCMD_REQUIRE_CHANNEL, NULL);
+
/* Channel options */
DEFINE_CHANNEL_OPTION(defaulttopic);
DEFINE_CHANNEL_OPTION(topicmask);