user is optional, if not null, it skips checking that userNode
(for the handle_part function) */
static void
-scan_handle_presence(struct chanNode *channel, struct handle_info *handle, struct userNode *user)
+scan_user_presence(struct userData *uData, struct userNode *user)
{
- struct userData *uData;
-
- if(!channel->channel_info || IsSuspended(channel->channel_info))
- return;
+ struct modeNode *mn;
- uData = GetTrueChannelAccess(channel->channel_info, handle);
- if(uData)
+ if(IsSuspended(uData->channel)
+ || IsUserSuspended(uData)
+ || !(mn = find_handle_in_channel(uData->channel->channel, uData->handle, user)))
{
- struct modeNode *mn = find_handle_in_channel(channel, handle, user);
-
- if(mn)
- {
- uData->present = 1;
- uData->seen = now;
- }
- else
- uData->present = 0;
+ uData->present = 0;
+ }
+ else
+ {
+ uData->present = 1;
+ uData->seen = now;
}
}
channel = AddChannel(argv[1], now, NULL, NULL);
cData = register_channel(channel, user->handle_info->handle);
- add_channel_user(cData, handle, UL_OWNER, 0, NULL);
- scan_handle_presence(channel, handle, NULL);
+ scan_user_presence(add_channel_user(cData, handle, UL_OWNER, 0, NULL), NULL);
cData->modes = chanserv_conf.default_modes;
change = mod_chanmode_dup(&cData->modes, 1);
change->args[change->argc].mode = MODE_CHANOP;
return 0;
}
- access = user_level_from_name(argv[1], UL_OWNER);
+ access = user_level_from_name(argv[2], UL_OWNER);
if(!access)
{
- reply("CSMSG_INVALID_ACCESS", argv[1]);
+ reply("CSMSG_INVALID_ACCESS", argv[2]);
return 0;
}
return 0;
}
- if(!(handle = modcmd_get_handle_info(user, argv[2])))
+ if(!(handle = modcmd_get_handle_info(user, argv[1])))
return 0;
if((actee = GetTrueChannelAccess(channel->channel_info, handle)))
}
actee = add_channel_user(channel->channel_info, handle, access, 0, NULL);
- scan_handle_presence(channel, handle, NULL);
+ scan_user_presence(actee, NULL);
reply("CSMSG_ADDED_USER", handle->handle, channel->name, access);
return 1;
}
{
struct chanNode *cn;
struct modeNode *mn;
- if(IsSuspended(channel->channel) || !(cn = channel->channel->channel))
+ if(IsUserSuspended(channel)
+ || IsSuspended(channel->channel)
+ || !(cn = channel->channel->channel))
continue;
mn = GetUserMode(cn, user);
{
struct chanData *cData;
struct userData *uData;
- struct handle_info *handle;
cData = channel->channel_info;
- if(!cData || IsSuspended(cData) || IsLocal(user)) return;
+ if(!cData || IsSuspended(cData) || IsLocal(user))
+ return;
if((cData->flags & CHANNEL_DYNAMIC_LIMIT) && !channel->join_flooded)
{
}
}
- if((handle = user->handle_info) && (uData = GetTrueChannelAccess(cData, handle)))
- {
- uData->seen = now;
- scan_handle_presence(channel, handle, user);
- }
+ if((uData = GetTrueChannelAccess(cData, user->handle_info)))
+ scan_user_presence(uData, user);
if(IsHelping(user) && IsSupportHelper(user))
{
str = database_get_data(conf_node, KEY_MAX_CHAN_BANS, RECDB_QSTRING);
chanserv_conf.max_chan_bans = str ? atoi(str) : 512;
str = database_get_data(conf_node, KEY_NICK, RECDB_QSTRING);
- if(str) NickChange(chanserv, str, 0);
+ if(chanserv && str)
+ NickChange(chanserv, str, 0);
str = database_get_data(conf_node, KEY_REFRESH_PERIOD, RECDB_QSTRING);
chanserv_conf.refresh_period = str ? ParseInterval(str) : 3*60*60;
str = database_get_data(conf_node, KEY_CTCP_SHORT_BAN_DURATION, RECDB_QSTRING);
continue;
cData->chOpts[chOpt] = str[0];
}
- if((str = database_get_data(channel, KEY_FLAGS, RECDB_QSTRING)))
+ if((str = database_get_data(obj, KEY_FLAGS, RECDB_QSTRING)))
cData->flags = atoi(str);
}
else if((str = database_get_data(channel, KEY_FLAGS, RECDB_QSTRING)))
cData->flags &= ~CHANNEL_SUSPENDED;
}
- if((cData->flags & CHANNEL_SUSPENDED) && (suspended->expires > now))
- {
- timeq_add(suspended->expires, chanserv_expire_suspension, suspended);
- }
- else
+ if(!(cData->flags & CHANNEL_SUSPENDED))
{
struct mod_chanmode change;
change.modes_set = change.modes_clear = 0;
change.args[0].member = AddChannelUser(chanserv, cNode);
mod_chanmode_announce(chanserv, cNode, &change);
}
+ else if(suspended->expires > now)
+ {
+ timeq_add(suspended->expires, chanserv_expire_suspension, suspended);
+ }
str = database_get_data(channel, KEY_REGISTERED, RECDB_QSTRING);
cData->registered = str ? (time_t)strtoul(str, NULL, 0) : now;
void
init_chanserv(const char *nick)
{
- chanserv = AddService(nick, "Channel Services");
CS_LOG = log_register_type("ChanServ", "file:chanserv.log");
conf_register_reload(chanserv_conf_read);
note_types = dict_new();
dict_set_free_data(note_types, chanserv_deref_note_type);
+ if(nick)
+ {
+ chanserv = AddService(nick, "Channel Services");
+ service_register(chanserv, '!');
+ reg_chanmsg_func('\001', chanserv, chanserv_ctcp_check);
+ }
saxdb_register("ChanServ", chanserv_saxdb_read, chanserv_saxdb_write);
- reg_chanmsg_func('\001', chanserv, chanserv_ctcp_check);
if(chanserv_conf.channel_expire_frequency)
timeq_add(now + chanserv_conf.channel_expire_frequency, expire_channels, NULL);