Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #include "module.h"
00015
00016 class CommandCSInvite : public Command
00017 {
00018 public:
00019 CommandCSInvite(Module *creator) : Command(creator, "chanserv/invite", 1, 3)
00020 {
00021 this->SetDesc(_("Invites you or an optionally specified nick into a channel"));
00022 this->SetSyntax(_("\037channel\037 [\037nick\037]"));
00023 }
00024
00025 void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override
00026 {
00027 const Anope::string &chan = params[0];
00028
00029 User *u = source.GetUser();
00030 Channel *c = Channel::Find(chan);
00031
00032 if (!c)
00033 {
00034 source.Reply(CHAN_X_NOT_IN_USE, chan.c_str());
00035 return;
00036 }
00037
00038 ChannelInfo *ci = c->ci;
00039 if (!ci)
00040 {
00041 source.Reply(CHAN_X_NOT_REGISTERED, chan.c_str());
00042 return;
00043 }
00044
00045 if (!source.AccessFor(ci).HasPriv("INVITE") && !source.HasCommand("chanserv/invite"))
00046 {
00047 source.Reply(ACCESS_DENIED);
00048 return;
00049 }
00050
00051 User *u2;
00052 if (params.size() == 1)
00053 u2 = u;
00054 else
00055 u2 = User::Find(params[1], true);
00056
00057 if (!u2)
00058 {
00059 source.Reply(NICK_X_NOT_IN_USE, params.size() > 1 ? params[1].c_str() : source.GetNick().c_str());
00060 return;
00061 }
00062
00063 if (c->FindUser(u2))
00064 {
00065 if (u2 == u)
00066 source.Reply(_("You are already in \002%s\002!"), c->name.c_str());
00067 else
00068 source.Reply(_("\002%s\002 is already in \002%s\002!"), u2->nick.c_str(), c->name.c_str());
00069 }
00070 else
00071 {
00072 bool override = !source.AccessFor(ci).HasPriv("INVITE");
00073
00074 IRCD->SendInvite(ci->WhoSends(), c, u2);
00075 if (u2 != u)
00076 {
00077 source.Reply(_("\002%s\002 has been invited to \002%s\002."), u2->nick.c_str(), c->name.c_str());
00078 Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "for " << u2->nick;
00079 }
00080 else
00081 {
00082 Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci);
00083 }
00084 u2->SendMessage(ci->WhoSends(), _("You have been invited to \002%s\002."), c->name.c_str());
00085 }
00086 return;
00087 }
00088
00089 bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
00090 {
00091 this->SendSyntax(source);
00092 source.Reply(" ");
00093 source.Reply(_("Tells %s to invite you or an optionally specified\n"
00094 "nick into the given channel.\n"
00095 " \n"
00096 "By default, limited to AOPs or those with level 5 and above\n"
00097 "on the channel."), source.service->nick.c_str());
00098 return true;
00099 }
00100 };
00101
00102 class CSInvite : public Module
00103 {
00104 CommandCSInvite commandcsinvite;
00105
00106 public:
00107 CSInvite(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, CORE), commandcsinvite(this)
00108 {
00109 this->SetAuthor("Anope");
00110
00111 }
00112 };
00113
00114 MODULE_INIT(CSInvite)