X-Git-Url: https://jfr.im/git/irc/evilnet/x3.git/blobdiff_plain/4d69a3b1083db3baf772f28e4768c5c2a19d804a..10fb34f65cebd737faaed4ca8d3d4f92ce5c705f:/src/chanserv.c diff --git a/src/chanserv.c b/src/chanserv.c index 6fd959f..eedb7bc 100644 --- a/src/chanserv.c +++ b/src/chanserv.c @@ -218,6 +218,7 @@ static const struct message_entry msgtab[] = { { "CSMSG_NO_SELF_CLVL", "You cannot change your own access." }, { "CSMSG_NO_BUMP_ACCESS", "You cannot give users access greater than or equal to your own." }, { "CSMSG_MULTIPLE_OWNERS", "There is more than one owner in %s; please use $bCLVL$b, $bDELOWNER$b and/or $bADDOWNER$b instead." }, + { "CSMSG_NO_OWNER", "There is no owner for %s; please use $bCLVL$b and/or $bADDOWNER$b instead." }, { "CSMSG_TRANSFER_WAIT", "You must wait %s before you can give ownership of $b%s$b to someone else." }, { "CSMSG_NO_TRANSFER_SELF", "You cannot give ownership to your own account." }, { "CSMSG_OWNERSHIP_GIVEN", "Ownership of $b%s$b has been transferred to account $b%s$b." }, @@ -296,6 +297,7 @@ static const struct message_entry msgtab[] = { { "CSMSG_USET_AUTOOP", "$bAutoOp $b %s" }, { "CSMSG_USET_AUTOVOICE", "$bAutoVoice $b %s" }, { "CSMSG_USET_AUTOINVITE", "$bAutoInvite $b %s" }, + { "CSMSG_USET_AUTOJOIN", "$bAutoJoin $b %s" }, { "CSMSG_USET_INFO", "$bInfo $b %s" }, { "CSMSG_USER_PROTECTED", "Sorry, $b%s$b is protected." }, @@ -3756,6 +3758,8 @@ static CHANSERV_FUNC(cmd_myaccess) } if(IsUserAutoInvite(uData) && (uData->access >= cData->lvlOpts[lvlInviteMe])) string_buffer_append(&sbuf, 'i'); + if(IsUserAutoJoin(uData) && (uData->access >= cData->lvlOpts[lvlInviteMe])) + string_buffer_append(&sbuf, 'j'); if(uData->info) string_buffer_append_printf(&sbuf, ")] %s", uData->info); else @@ -6231,11 +6235,10 @@ static MODCMD_FUNC(user_opt_autoop) reply("CSMSG_NOT_USER", channel->name); return 0; } - if(uData->access < UL_OP /*channel->channel_info->lvlOpts[lvlGiveOps]*/) + if(uData->access < UL_HALFOP /*channel->channel_info->lvlOpts[lvlGiveOps]*/) return user_binary_option("CSMSG_USET_AUTOVOICE", USER_AUTO_OP, CSFUNC_ARGS); else return user_binary_option("CSMSG_USET_AUTOOP", USER_AUTO_OP, CSFUNC_ARGS); - /* TODO: add halfops error message? or is the op one generic enough? */ } static MODCMD_FUNC(user_opt_autoinvite) @@ -6243,6 +6246,11 @@ static MODCMD_FUNC(user_opt_autoinvite) return user_binary_option("CSMSG_USET_AUTOINVITE", USER_AUTO_INVITE, CSFUNC_ARGS); } +static MODCMD_FUNC(user_opt_autojoin) +{ + return user_binary_option("CSMSG_USET_AUTOJOIN", USER_AUTO_JOIN, CSFUNC_ARGS); +} + static MODCMD_FUNC(user_opt_info) { struct userData *uData; @@ -6301,7 +6309,7 @@ static CHANSERV_FUNC(cmd_uset) { char *options[] = { - "AutoOp", "AutoInvite", "Info" + "AutoOp", "AutoInvite", "AutoJoin", "Info" }; if(!uset_shows_list.size) @@ -6390,6 +6398,10 @@ static CHANSERV_FUNC(cmd_giveownership) reply("CSMSG_TRANSFER_WAIT", delay, channel->name); return 0; } + if (!curr_user) { + reply("CSMSG_NO_OWNER", channel->name); + return 0; + } if(!(new_owner_hi = modcmd_get_handle_info(user, argv[1]))) return 0; if(new_owner_hi == user->handle_info) @@ -6936,6 +6948,19 @@ static CHANSERV_FUNC(cmd_calc) return 1; } +static CHANSERV_FUNC(cmd_reply) +{ + + REQUIRE_PARAMS(2); + unsplit_string(argv + 1, argc - 1, NULL); + + if(channel) + send_channel_message(channel, cmd->parent->bot, "$b%s$b: %s", user->nick, unsplit_string(argv + 1, argc - 1, NULL)); + else + send_message_type(4, user, cmd->parent->bot, "%s", unsplit_string(argv + 1, argc - 1, NULL)); + return 1; +} + static void chanserv_adjust_limit(void *data) { @@ -7167,6 +7192,35 @@ handle_join(struct modeNode *mNode) return 0; } +static void +chanserv_autojoin_channel(void *data) +{ + struct userData *channel; + struct userNode *user = data; + + for(channel = user->handle_info->channels; channel; channel = channel->u_next) + { + struct chanNode *cn; + struct modeNode *mn; + + if(IsUserSuspended(channel) + || IsSuspended(channel->channel) + || !(cn = channel->channel->channel)) + continue; + + mn = GetUserMode(cn, user); + if(!mn) + { + if(!IsUserSuspended(channel) + && IsUserAutoJoin(channel) + && (channel->access >= channel->channel->lvlOpts[lvlInviteMe]) + && !self->burst + && !user->uplink->burst) + irc_svsjoin(chanserv, user, cn); + } + } +} + static void handle_auth(struct userNode *user, UNUSED_ARG(struct handle_info *old_handle)) { @@ -7182,12 +7236,14 @@ handle_auth(struct userNode *user, UNUSED_ARG(struct handle_info *old_handle)) for(channel = user->handle_info->channels; channel; channel = channel->u_next) { struct chanNode *cn; + struct chanData *cData; struct modeNode *mn; if(IsUserSuspended(channel) || IsSuspended(channel->channel) || !(cn = channel->channel->channel)) continue; + cData = cn->channel_info; mn = GetUserMode(cn, user); if(!mn) { @@ -7203,7 +7259,7 @@ handle_auth(struct userNode *user, UNUSED_ARG(struct handle_info *old_handle)) if(channel->access >= UL_PRESENT) channel->channel->visited = now; - if(IsUserAutoOp(channel)) + if(IsUserAutoOp(channel) && cData->chOpts[chAutomode] != 'n') { if(channel->access >= UL_OP ) change.args[0].mode = MODE_CHANOP; @@ -7271,6 +7327,10 @@ handle_auth(struct userNode *user, UNUSED_ARG(struct handle_info *old_handle)) if (user->handle_info->epithet) irc_swhois(chanserv, user, user->handle_info->epithet); + + /* process autojoin channels 5 seconds later as this sometimes + happens before autohide */ + timeq_add(now + 5, chanserv_autojoin_channel, user); } static void @@ -8581,6 +8641,7 @@ init_chanserv(const char *nick) DEFINE_COMMAND(d, 1, 0, "flags", "+nolog,+toy,+acceptchan", NULL); DEFINE_COMMAND(huggle, 1, 0, "flags", "+nolog,+toy,+acceptchan", NULL); DEFINE_COMMAND(calc, 1, 0, "flags", "+nolog,+toy,+acceptchan", NULL); + DEFINE_COMMAND(reply, 1, 0, "flags", "+nolog,+toy,+acceptchan", NULL); /* Channel options */ DEFINE_CHANNEL_OPTION(defaulttopic); @@ -8615,6 +8676,7 @@ init_chanserv(const char *nick) /* User options */ DEFINE_USER_OPTION(autoinvite); + DEFINE_USER_OPTION(autojoin); DEFINE_USER_OPTION(info); DEFINE_USER_OPTION(autoop);