X-Git-Url: https://jfr.im/git/irc/evilnet/x3.git/blobdiff_plain/5678501c253bdf8590217bc37a9fb50abba9c23b..10fb34f65cebd737faaed4ca8d3d4f92ce5c705f:/src/chanserv.c?ds=sidebyside diff --git a/src/chanserv.c b/src/chanserv.c index 1a871fb..eedb7bc 100644 --- a/src/chanserv.c +++ b/src/chanserv.c @@ -297,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." }, @@ -3757,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 @@ -6232,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) @@ -6244,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; @@ -6302,7 +6309,7 @@ static CHANSERV_FUNC(cmd_uset) { char *options[] = { - "AutoOp", "AutoInvite", "Info" + "AutoOp", "AutoInvite", "AutoJoin", "Info" }; if(!uset_shows_list.size) @@ -6941,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) { @@ -7172,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)) { @@ -7187,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) { @@ -7208,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; @@ -7276,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 @@ -8586,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); @@ -8620,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);