static void cs_cmd_invite(struct sourceinfo *si, int parc, char *parv[]) { char *chan = parv[0]; struct mychan *mc; if (si->su == NULL) { command_fail(si, fault_noprivs, STR_IRC_COMMAND_ONLY, "INVITE"); return; } /* This command is not useful if the user is already in the channel, * ignore it if it is a fantasy command so users can program bots to * react on it without interference from ChanServ. */ if (si->c != NULL) return; if (!chan) { command_fail(si, fault_needmoreparams, STR_INSUFFICIENT_PARAMS, "INVITE"); command_fail(si, fault_needmoreparams, _("Syntax: INVITE <#channel>")); return; } if (!(mc = mychan_find(chan))) { command_fail(si, fault_nosuch_target, STR_IS_NOT_REGISTERED, chan); return; } if (metadata_find(mc, "private:close:closer")) { command_fail(si, fault_noprivs, STR_CHANNEL_IS_CLOSED, chan); return; } if (!chanacs_source_has_flag(mc, si, CA_INVITE)) { command_fail(si, fault_noprivs, STR_NOT_AUTHORIZED); return; } if (!mc->chan) { command_fail(si, fault_nosuch_target, STR_CHANNEL_IS_EMPTY, mc->name); return; } if (chanuser_find(mc->chan, si->su)) { command_fail(si, fault_noprivs, _("You're already on \2%s\2."), mc->name); return; } invite_sts(si->service->me, si->su, mc->chan); logcommand(si, CMDLOG_DO, "INVITE: \2%s\2", mc->name); command_success_nodata(si, _("You have been invited to \2%s\2."), mc->name); }
static void cs_cmd_invite(sourceinfo_t *si, int parc, char *parv[]) { char *chan = parv[0]; mychan_t *mc; if (si->su == NULL) { command_fail(si, fault_noprivs, _("\2%s\2 can only be executed via IRC."), "INVITE"); return; } /* This command is not useful if the user is already in the channel, * ignore it if it is a fantasy command so users can program bots to * react on it without interference from ChanServ. */ if (si->c != NULL) return; if (!chan) { command_fail(si, fault_needmoreparams, STR_INSUFFICIENT_PARAMS, "INVITE"); command_fail(si, fault_needmoreparams, _("Syntax: INVITE <#channel>")); return; } mc = mychan_find(chan); if (!mc) { command_fail(si, fault_nosuch_target, _("Channel \2%s\2 is not registered."), chan); return; } if (metadata_find(mc, "private:close:closer")) { command_fail(si, fault_noprivs, _("\2%s\2 is closed."), chan); return; } if (!chanacs_source_has_flag(mc, si, CA_INVITE)) { command_fail(si, fault_noprivs, _("You are not authorized to perform this operation.")); return; } if (!mc->chan) { command_fail(si, fault_nosuch_target, _("\2%s\2 is currently empty."), mc->name); return; } if (chanuser_find(mc->chan, si->su)) { command_fail(si, fault_noprivs, _("You're already on \2%s\2."), mc->name); return; } invite_sts(si->service->me, si->su, mc->chan); logcommand(si, CMDLOG_DO, "INVITE: \2%s\2", mc->name); command_success_nodata(si, _("You have been invited to \2%s\2."), mc->name); }