summaryrefslogtreecommitdiff
path: root/modules/core/cs_info.cpp
diff options
context:
space:
mode:
authorNaram Qashat <cyberbotx@cyberbotx.com>2010-07-25 21:58:20 -0400
committerNaram Qashat <cyberbotx@cyberbotx.com>2010-07-25 21:58:20 -0400
commitae38212c1ce829c783edf971081c90137abb49a0 (patch)
tree5c652d9cdc38103dec6fa112d57fca882b4e3e44 /modules/core/cs_info.cpp
parent15d7f0f6fe8bb903275f603f734c13f65f3aa906 (diff)
Epic commit to replace most of the strings in Anope with a single Anope::string class, plus some other little fixes here and there. If you follow 1.9.x development and are testing things, THIS is one of those things that NEEDS testing.
Diffstat (limited to 'modules/core/cs_info.cpp')
-rw-r--r--modules/core/cs_info.cpp69
1 files changed, 35 insertions, 34 deletions
diff --git a/modules/core/cs_info.cpp b/modules/core/cs_info.cpp
index 9b70735dd..5f135ce4d 100644
--- a/modules/core/cs_info.cpp
+++ b/modules/core/cs_info.cpp
@@ -15,7 +15,7 @@
class CommandCSInfo : public Command
{
- void CheckOptStr(std::string &buf, ChannelInfoFlag opt, const std::string &str, ChannelInfo *ci, NickCore *nc)
+ void CheckOptStr(Anope::string &buf, ChannelInfoFlag opt, const Anope::string &str, ChannelInfo *ci, const NickCore *nc)
{
if (ci->HasFlag(opt))
{
@@ -35,9 +35,9 @@ class CommandCSInfo : public Command
this->SetFlag(CFLAG_ALLOW_FORBIDDEN);
}
- CommandReturn Execute(User *u, const std::vector<ci::string> &params)
+ CommandReturn Execute(User *u, const std::vector<Anope::string> &params)
{
- const char *chan = params[0].c_str();
+ Anope::string chan = params[0];
char buf[BUFSIZE];
struct tm *tm;
bool has_auspex = u->IsIdentified() && u->Account()->HasPriv("chanserv/auspex");
@@ -48,10 +48,10 @@ class CommandCSInfo : public Command
if (ci->HasFlag(CI_FORBIDDEN))
{
- if (is_oper(u) && ci->forbidby)
- notice_lang(Config.s_ChanServ, u, CHAN_X_FORBIDDEN_OPER, chan, ci->forbidby, ci->forbidreason ? ci->forbidreason : getstring(u, NO_REASON));
+ if (is_oper(u) && !ci->forbidby.empty())
+ notice_lang(Config.s_ChanServ, u, CHAN_X_FORBIDDEN_OPER, chan.c_str(), ci->forbidby.c_str(), !ci->forbidreason.empty() ? ci->forbidreason.c_str() : getstring(u, NO_REASON));
else
- notice_lang(Config.s_ChanServ, u, CHAN_X_FORBIDDEN, chan);
+ notice_lang(Config.s_ChanServ, u, CHAN_X_FORBIDDEN, chan.c_str());
return MOD_CONT;
}
@@ -60,13 +60,13 @@ class CommandCSInfo : public Command
if (has_auspex && check_access(u, ci, CA_INFO))
show_all = true;
- notice_lang(Config.s_ChanServ, u, CHAN_INFO_HEADER, chan);
- notice_lang(Config.s_ChanServ, u, CHAN_INFO_NO_FOUNDER, ci->founder->display);
+ notice_lang(Config.s_ChanServ, u, CHAN_INFO_HEADER, chan.c_str());
+ notice_lang(Config.s_ChanServ, u, CHAN_INFO_NO_FOUNDER, ci->founder->display.c_str());
if (show_all && ci->successor)
- notice_lang(Config.s_ChanServ, u, CHAN_INFO_NO_SUCCESSOR, ci->successor->display);
+ notice_lang(Config.s_ChanServ, u, CHAN_INFO_NO_SUCCESSOR, ci->successor->display.c_str());
- notice_lang(Config.s_ChanServ, u, CHAN_INFO_DESCRIPTION, ci->desc);
+ notice_lang(Config.s_ChanServ, u, CHAN_INFO_DESCRIPTION, ci->desc.c_str());
tm = localtime(&ci->time_registered);
strftime_lang(buf, sizeof(buf), u, STRFTIME_DATE_TIME_FORMAT, tm);
notice_lang(Config.s_ChanServ, u, CHAN_INFO_TIME_REGGED, buf);
@@ -74,38 +74,38 @@ class CommandCSInfo : public Command
strftime_lang(buf, sizeof(buf), u, STRFTIME_DATE_TIME_FORMAT, tm);
notice_lang(Config.s_ChanServ, u, CHAN_INFO_LAST_USED, buf);
- if (ci->last_topic && (show_all || (!ci->HasMLock(CMODE_SECRET, true) && (!ci->c || !ci->c->HasMode(CMODE_SECRET)))))
+ if (!ci->last_topic.empty() && (show_all || (!ci->HasMLock(CMODE_SECRET, true) && (!ci->c || !ci->c->HasMode(CMODE_SECRET)))))
{
- notice_lang(Config.s_ChanServ, u, CHAN_INFO_LAST_TOPIC, ci->last_topic);
+ notice_lang(Config.s_ChanServ, u, CHAN_INFO_LAST_TOPIC, ci->last_topic.c_str());
notice_lang(Config.s_ChanServ, u, CHAN_INFO_TOPIC_SET_BY, ci->last_topic_setter.c_str());
}
- if (ci->entry_message && show_all)
- notice_lang(Config.s_ChanServ, u, CHAN_INFO_ENTRYMSG, ci->entry_message);
+ if (!ci->entry_message.empty() && show_all)
+ notice_lang(Config.s_ChanServ, u, CHAN_INFO_ENTRYMSG, ci->entry_message.c_str());
if (show_all)
{
notice_lang(Config.s_ChanServ, u, CHAN_INFO_BANTYPE, ci->bantype);
- std::string optbuf;
-
- CheckOptStr(optbuf, CI_KEEPTOPIC, getstring(u, CHAN_INFO_OPT_KEEPTOPIC), ci, u->Account());
- CheckOptStr(optbuf, CI_OPNOTICE, getstring(u, CHAN_INFO_OPT_OPNOTICE), ci, u->Account());
- CheckOptStr(optbuf, CI_PEACE, getstring(u, CHAN_INFO_OPT_PEACE), ci, u->Account());
- CheckOptStr(optbuf, CI_PRIVATE, getstring(u, CHAN_INFO_OPT_PRIVATE), ci, u->Account());
- CheckOptStr(optbuf, CI_RESTRICTED, getstring(u, CHAN_INFO_OPT_RESTRICTED), ci, u->Account());
- CheckOptStr(optbuf, CI_SECURE, getstring(u, CHAN_INFO_OPT_SECURE), ci, u->Account());
- CheckOptStr(optbuf, CI_SECUREFOUNDER, getstring(u, CHAN_INFO_OPT_SECUREFOUNDER), ci, u->Account());
- CheckOptStr(optbuf, CI_SECUREOPS, getstring(u, CHAN_INFO_OPT_SECUREOPS), ci, u->Account());
+ Anope::string optbuf;
+
+ CheckOptStr(optbuf, CI_KEEPTOPIC, getstring(u, CHAN_INFO_OPT_KEEPTOPIC), ci, u->Account());
+ CheckOptStr(optbuf, CI_OPNOTICE, getstring(u, CHAN_INFO_OPT_OPNOTICE), ci, u->Account());
+ CheckOptStr(optbuf, CI_PEACE, getstring(u, CHAN_INFO_OPT_PEACE), ci, u->Account());
+ CheckOptStr(optbuf, CI_PRIVATE, getstring(u, CHAN_INFO_OPT_PRIVATE), ci, u->Account());
+ CheckOptStr(optbuf, CI_RESTRICTED, getstring(u, CHAN_INFO_OPT_RESTRICTED), ci, u->Account());
+ CheckOptStr(optbuf, CI_SECURE, getstring(u, CHAN_INFO_OPT_SECURE), ci, u->Account());
+ CheckOptStr(optbuf, CI_SECUREFOUNDER, getstring(u, CHAN_INFO_OPT_SECUREFOUNDER), ci, u->Account());
+ CheckOptStr(optbuf, CI_SECUREOPS, getstring(u, CHAN_INFO_OPT_SECUREOPS), ci, u->Account());
if (ci->HasFlag(CI_SIGNKICK))
- CheckOptStr(optbuf, CI_SIGNKICK, getstring(u, CHAN_INFO_OPT_SIGNKICK), ci, u->Account());
+ CheckOptStr(optbuf, CI_SIGNKICK, getstring(u, CHAN_INFO_OPT_SIGNKICK), ci, u->Account());
else
- CheckOptStr(optbuf, CI_SIGNKICK_LEVEL, getstring(u, CHAN_INFO_OPT_SIGNKICK), ci, u->Account());
- CheckOptStr(optbuf, CI_TOPICLOCK, getstring(u, CHAN_INFO_OPT_TOPICLOCK), ci, u->Account());
- CheckOptStr(optbuf, CI_XOP, getstring(u, CHAN_INFO_OPT_XOP), ci, u->Account());
+ CheckOptStr(optbuf, CI_SIGNKICK_LEVEL, getstring(u, CHAN_INFO_OPT_SIGNKICK), ci, u->Account());
+ CheckOptStr(optbuf, CI_TOPICLOCK, getstring(u, CHAN_INFO_OPT_TOPICLOCK), ci, u->Account());
+ CheckOptStr(optbuf, CI_XOP, getstring(u, CHAN_INFO_OPT_XOP), ci, u->Account());
CheckOptStr(optbuf, CI_PERSIST, getstring(u, CHAN_INFO_OPT_PERSIST), ci, u->Account());
- notice_lang(Config.s_ChanServ, u, CHAN_INFO_OPTIONS, optbuf.empty() ? getstring(u, CHAN_INFO_OPT_NONE) : optbuf.c_str());
- notice_lang(Config.s_ChanServ, u, CHAN_INFO_MODE_LOCK, get_mlock_modes(ci, 1));
+ notice_lang(Config.s_ChanServ, u, CHAN_INFO_OPTIONS, optbuf.empty() ? getstring(u, CHAN_INFO_OPT_NONE) : optbuf.c_str());
+ notice_lang(Config.s_ChanServ, u, CHAN_INFO_MODE_LOCK, get_mlock_modes(ci, 1).c_str());
// XXX: we could just as easily (and tidily) merge this in with the flags display above.
if (ci->HasFlag(CI_NO_EXPIRE))
@@ -119,21 +119,21 @@ class CommandCSInfo : public Command
}
}
if (ci->HasFlag(CI_SUSPENDED))
- notice_lang(Config.s_ChanServ, u, CHAN_X_SUSPENDED, ci->forbidby, (ci->forbidreason ? ci->forbidreason : getstring(u, NO_REASON)));
+ notice_lang(Config.s_ChanServ, u, CHAN_X_SUSPENDED, ci->forbidby.c_str(), !ci->forbidreason.empty() ? ci->forbidreason.c_str() : getstring(u, NO_REASON));
FOREACH_MOD(I_OnChanInfo, OnChanInfo(u, ci, show_all));
return MOD_CONT;
}
- bool OnHelp(User *u, const ci::string &subcommand)
+ bool OnHelp(User *u, const Anope::string &subcommand)
{
notice_lang(Config.s_ChanServ, u, CHAN_HELP_INFO);
return true;
}
- void OnSyntaxError(User *u, const ci::string &subcommand)
+ void OnSyntaxError(User *u, const Anope::string &subcommand)
{
syntax_error(Config.s_ChanServ, u, "INFO", CHAN_INFO_SYNTAX);
}
@@ -147,10 +147,11 @@ class CommandCSInfo : public Command
class CSInfo : public Module
{
public:
- CSInfo(const std::string &modname, const std::string &creator) : Module(modname, creator)
+ CSInfo(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator)
{
this->SetAuthor("Anope");
this->SetType(CORE);
+
this->AddCommand(ChanServ, new CommandCSInfo());
}
};