mirror of
https://github.com/anope/anope.git
synced 2026-06-29 03:26:38 +02:00
Send replies from fantasy commands back to the channel, this will be expanded on later
This commit is contained in:
+38
-35
@@ -16,57 +16,61 @@
|
||||
class CommandMSSet : public Command
|
||||
{
|
||||
private:
|
||||
CommandReturn DoNotify(User *u, const std::vector<Anope::string> ¶ms, MemoInfo *mi)
|
||||
CommandReturn DoNotify(CommandSource &source, const std::vector<Anope::string> ¶ms, MemoInfo *mi)
|
||||
{
|
||||
Anope::string param = params[1];
|
||||
User *u = source.u;
|
||||
const Anope::string ¶m = params[1];
|
||||
|
||||
if (param.equals_ci("ON"))
|
||||
{
|
||||
u->Account()->SetFlag(NI_MEMO_SIGNON);
|
||||
u->Account()->SetFlag(NI_MEMO_RECEIVE);
|
||||
u->SendMessage(MemoServ, MEMO_SET_NOTIFY_ON, Config->s_MemoServ.c_str());
|
||||
source.Reply(MEMO_SET_NOTIFY_ON, Config->s_MemoServ.c_str());
|
||||
}
|
||||
else if (param.equals_ci("LOGON"))
|
||||
{
|
||||
u->Account()->SetFlag(NI_MEMO_SIGNON);
|
||||
u->Account()->UnsetFlag(NI_MEMO_RECEIVE);
|
||||
u->SendMessage(MemoServ, MEMO_SET_NOTIFY_LOGON, Config->s_MemoServ.c_str());
|
||||
source.Reply(MEMO_SET_NOTIFY_LOGON, Config->s_MemoServ.c_str());
|
||||
}
|
||||
else if (param.equals_ci("NEW"))
|
||||
{
|
||||
u->Account()->UnsetFlag(NI_MEMO_SIGNON);
|
||||
u->Account()->SetFlag(NI_MEMO_RECEIVE);
|
||||
u->SendMessage(MemoServ, MEMO_SET_NOTIFY_NEW, Config->s_MemoServ.c_str());
|
||||
source.Reply(MEMO_SET_NOTIFY_NEW, Config->s_MemoServ.c_str());
|
||||
}
|
||||
else if (param.equals_ci("MAIL"))
|
||||
{
|
||||
if (!u->Account()->email.empty())
|
||||
{
|
||||
u->Account()->SetFlag(NI_MEMO_MAIL);
|
||||
u->SendMessage(MemoServ, MEMO_SET_NOTIFY_MAIL);
|
||||
source.Reply(MEMO_SET_NOTIFY_MAIL);
|
||||
}
|
||||
else
|
||||
u->SendMessage(MemoServ, MEMO_SET_NOTIFY_INVALIDMAIL);
|
||||
source.Reply(MEMO_SET_NOTIFY_INVALIDMAIL);
|
||||
}
|
||||
else if (param.equals_ci("NOMAIL"))
|
||||
{
|
||||
u->Account()->UnsetFlag(NI_MEMO_MAIL);
|
||||
u->SendMessage(MemoServ, MEMO_SET_NOTIFY_NOMAIL);
|
||||
source.Reply(MEMO_SET_NOTIFY_NOMAIL);
|
||||
}
|
||||
else if (param.equals_ci("OFF"))
|
||||
{
|
||||
u->Account()->UnsetFlag(NI_MEMO_SIGNON);
|
||||
u->Account()->UnsetFlag(NI_MEMO_RECEIVE);
|
||||
u->Account()->UnsetFlag(NI_MEMO_MAIL);
|
||||
u->SendMessage(MemoServ, MEMO_SET_NOTIFY_OFF, Config->s_MemoServ.c_str());
|
||||
source.Reply(MEMO_SET_NOTIFY_OFF, Config->s_MemoServ.c_str());
|
||||
}
|
||||
else
|
||||
SyntaxError(MemoServ, u, "SET NOTIFY", MEMO_SET_NOTIFY_SYNTAX);
|
||||
|
||||
return MOD_CONT;
|
||||
}
|
||||
|
||||
CommandReturn DoLimit(User *u, const std::vector<Anope::string> ¶ms, MemoInfo *mi)
|
||||
CommandReturn DoLimit(CommandSource &source, const std::vector<Anope::string> ¶ms, MemoInfo *mi)
|
||||
{
|
||||
User *u = source.u;
|
||||
|
||||
Anope::string p1 = params[1];
|
||||
Anope::string p2 = params.size() > 2 ? params[2] : "";
|
||||
Anope::string p3 = params.size() > 3 ? params[3] : "";
|
||||
@@ -84,12 +88,12 @@ class CommandMSSet : public Command
|
||||
p3 = params.size() > 4 ? params[4] : "";
|
||||
if (!(ci = cs_findchan(chan)))
|
||||
{
|
||||
u->SendMessage(MemoServ, CHAN_X_NOT_REGISTERED, chan.c_str());
|
||||
source.Reply(CHAN_X_NOT_REGISTERED, chan.c_str());
|
||||
return MOD_CONT;
|
||||
}
|
||||
else if (!is_servadmin && !check_access(u, ci, CA_MEMO))
|
||||
{
|
||||
u->SendMessage(MemoServ, ACCESS_DENIED);
|
||||
source.Reply(ACCESS_DENIED);
|
||||
return MOD_CONT;
|
||||
}
|
||||
mi = &ci->memos;
|
||||
@@ -101,7 +105,7 @@ class CommandMSSet : public Command
|
||||
NickAlias *na;
|
||||
if (!(na = findnick(p1)))
|
||||
{
|
||||
u->SendMessage(MemoServ, NICK_X_NOT_REGISTERED, p1.c_str());
|
||||
source.Reply(NICK_X_NOT_REGISTERED, p1.c_str());
|
||||
return MOD_CONT;
|
||||
}
|
||||
user = p1;
|
||||
@@ -137,7 +141,7 @@ class CommandMSSet : public Command
|
||||
limit = p1.is_pos_number_only() ? convertTo<int32>(p1) : -1;
|
||||
if (limit < 0 || limit > 32767)
|
||||
{
|
||||
u->SendMessage(MemoServ, MEMO_SET_LIMIT_OVERFLOW, 32767);
|
||||
source.Reply(MEMO_SET_LIMIT_OVERFLOW, 32767);
|
||||
limit = 32767;
|
||||
}
|
||||
if (p1.equals_ci("NONE"))
|
||||
@@ -152,12 +156,12 @@ class CommandMSSet : public Command
|
||||
}
|
||||
if (!chan.empty() && ci->HasFlag(CI_MEMO_HARDMAX))
|
||||
{
|
||||
u->SendMessage(MemoServ, MEMO_SET_LIMIT_FORBIDDEN, chan.c_str());
|
||||
source.Reply(MEMO_SET_LIMIT_FORBIDDEN, chan.c_str());
|
||||
return MOD_CONT;
|
||||
}
|
||||
else if (chan.empty() && nc->HasFlag(NI_MEMO_HARDMAX))
|
||||
{
|
||||
u->SendMessage(MemoServ, MEMO_SET_YOUR_LIMIT_FORBIDDEN);
|
||||
source.Reply(MEMO_SET_YOUR_LIMIT_FORBIDDEN);
|
||||
return MOD_CONT;
|
||||
}
|
||||
limit = p1.is_pos_number_only() ? convertTo<int32>(p1) : -1;
|
||||
@@ -166,14 +170,14 @@ class CommandMSSet : public Command
|
||||
if (limit < 0 || (Config->MSMaxMemos > 0 && static_cast<unsigned>(limit) > Config->MSMaxMemos))
|
||||
{
|
||||
if (!chan.empty())
|
||||
u->SendMessage(MemoServ, MEMO_SET_LIMIT_TOO_HIGH, chan.c_str(), Config->MSMaxMemos);
|
||||
source.Reply(MEMO_SET_LIMIT_TOO_HIGH, chan.c_str(), Config->MSMaxMemos);
|
||||
else
|
||||
u->SendMessage(MemoServ, MEMO_SET_YOUR_LIMIT_TOO_HIGH, Config->MSMaxMemos);
|
||||
source.Reply(MEMO_SET_YOUR_LIMIT_TOO_HIGH, Config->MSMaxMemos);
|
||||
return MOD_CONT;
|
||||
}
|
||||
else if (limit > 32767)
|
||||
{
|
||||
u->SendMessage(MemoServ, MEMO_SET_LIMIT_OVERFLOW, 32767);
|
||||
source.Reply(MEMO_SET_LIMIT_OVERFLOW, 32767);
|
||||
limit = 32767;
|
||||
}
|
||||
}
|
||||
@@ -181,23 +185,23 @@ class CommandMSSet : public Command
|
||||
if (limit > 0)
|
||||
{
|
||||
if (chan.empty() && nc == u->Account())
|
||||
u->SendMessage(MemoServ, MEMO_SET_YOUR_LIMIT, limit);
|
||||
source.Reply(MEMO_SET_YOUR_LIMIT, limit);
|
||||
else
|
||||
u->SendMessage(MemoServ, MEMO_SET_LIMIT, !chan.empty() ? chan.c_str() : user.c_str(), limit);
|
||||
source.Reply(MEMO_SET_LIMIT, !chan.empty() ? chan.c_str() : user.c_str(), limit);
|
||||
}
|
||||
else if (!limit)
|
||||
{
|
||||
if (chan.empty() && nc == u->Account())
|
||||
u->SendMessage(MemoServ, MEMO_SET_YOUR_LIMIT_ZERO);
|
||||
source.Reply(MEMO_SET_YOUR_LIMIT_ZERO);
|
||||
else
|
||||
u->SendMessage(MemoServ, MEMO_SET_LIMIT_ZERO, !chan.empty() ? chan.c_str() : user.c_str());
|
||||
source.Reply(MEMO_SET_LIMIT_ZERO, !chan.empty() ? chan.c_str() : user.c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
if (chan.empty() && nc == u->Account())
|
||||
u->SendMessage(MemoServ, MEMO_UNSET_YOUR_LIMIT);
|
||||
source.Reply(MEMO_UNSET_YOUR_LIMIT);
|
||||
else
|
||||
u->SendMessage(MemoServ, MEMO_UNSET_LIMIT, !chan.empty() ? chan.c_str() : user.c_str());
|
||||
source.Reply(MEMO_UNSET_LIMIT, !chan.empty() ? chan.c_str() : user.c_str());
|
||||
}
|
||||
return MOD_CONT;
|
||||
}
|
||||
@@ -206,25 +210,24 @@ class CommandMSSet : public Command
|
||||
{
|
||||
}
|
||||
|
||||
CommandReturn Execute(User *u, const std::vector<Anope::string> ¶ms)
|
||||
CommandReturn Execute(CommandSource &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
Anope::string cmd = params[0];
|
||||
User *u = source.u;
|
||||
const Anope::string &cmd = params[0];
|
||||
MemoInfo *mi = &u->Account()->memos;
|
||||
|
||||
if (readonly)
|
||||
{
|
||||
u->SendMessage(MemoServ, MEMO_SET_DISABLED);
|
||||
return MOD_CONT;
|
||||
}
|
||||
source.Reply(MEMO_SET_DISABLED);
|
||||
else if (cmd.equals_ci("NOTIFY"))
|
||||
return this->DoNotify(u, params, mi);
|
||||
return this->DoNotify(source, params, mi);
|
||||
else if (cmd.equals_ci("LIMIT"))
|
||||
return this->DoLimit(u, params, mi);
|
||||
return this->DoLimit(source, params, mi);
|
||||
else
|
||||
{
|
||||
u->SendMessage(MemoServ, NICK_SET_UNKNOWN_OPTION, cmd.c_str());
|
||||
u->SendMessage(MemoServ, MORE_INFO, Config->s_MemoServ.c_str(), "SET");
|
||||
source.Reply(NICK_SET_UNKNOWN_OPTION, cmd.c_str());
|
||||
source.Reply(MORE_INFO, Config->s_MemoServ.c_str(), "SET");
|
||||
}
|
||||
|
||||
return MOD_CONT;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user