diff options
author | Adam <Adam@anope.org> | 2011-02-11 03:12:39 -0500 |
---|---|---|
committer | Adam <Adam@anope.org> | 2011-02-11 03:12:39 -0500 |
commit | 2529ff6daef7eb387d2fce4c6df5a31029fd5bb2 (patch) | |
tree | 25c4cf0c84bef8b47c3824ba827b3816b8f17221 /src | |
parent | 7bdf592f7ea2d527930ada96d8e07fae966239d4 (diff) |
Made the help command description code more sane
Diffstat (limited to 'src')
-rw-r--r-- | src/command.cpp | 10 | ||||
-rw-r--r-- | src/language.cpp | 16 | ||||
-rw-r--r-- | src/users.cpp | 20 |
3 files changed, 26 insertions, 20 deletions
diff --git a/src/command.cpp b/src/command.cpp index 398f4249c..ddf9a6622 100644 --- a/src/command.cpp +++ b/src/command.cpp @@ -64,7 +64,15 @@ Command::~Command() this->module->DelCommand(this->service, this); } -void Command::OnServHelp(CommandSource &source) { } +void Command::SetDesc(const Anope::string &d) +{ + this->desc = d; +} + +void Command::OnServHelp(CommandSource &source) +{ + source.Reply(" %-14s %s", this->name.c_str(), _(this->desc.c_str())); +} bool Command::OnHelp(CommandSource &source, const Anope::string &subcommand) { return false; } diff --git a/src/language.cpp b/src/language.cpp index 7256ebbbf..01ff01f81 100644 --- a/src/language.cpp +++ b/src/language.cpp @@ -95,14 +95,7 @@ const char *anope_gettext(const char *string) setlocale(LC_ALL, ""); #endif - Anope::string translated = translated_string ? translated_string : ""; - - if (Config->UseStrictPrivMsg) - translated = translated.replace_all_cs("%R", "/"); - else - translated = translated.replace_all_cs("%R", "/msg "); - - return translated.c_str(); + return translated_string != NULL ? translated_string : ""; } #else void PushLanguage(const Anope::string &, Anope::string) @@ -115,12 +108,7 @@ void PopLanguage() const char *anope_gettext(const char *string) { - Anope::string translated = string ? string : ""; - if (Config->UseStrictPrivMsg) - translated = translated.replace_all_cs("%R", "/"); - else - translated = translated.replace_all_cs("%R", "/msg "); - return translated.c_str(); + return string != NULL ? string : ""; } #endif diff --git a/src/users.cpp b/src/users.cpp index 9f1cc8404..fa69b928a 100644 --- a/src/users.cpp +++ b/src/users.cpp @@ -234,17 +234,27 @@ void User::SendMessage(BotInfo *source, const char *fmt, ...) } } -void User::SendMessage(BotInfo *source, const Anope::string &msg) +void User::SendMessage(BotInfo *source, Anope::string msg) { + if (Config->UseStrictPrivMsg) + msg = msg.replace_all_cs("%R", "/"); + else + msg = msg.replace_all_cs("%R", "/msg "); + /* Send privmsg instead of notice if: * - UsePrivmsg is enabled * - The user is not registered and NSDefMsg is enabled * - The user is registered and has set /ns set msg on */ - if (Config->UsePrivmsg && ((!this->nc && Config->NSDefFlags.HasFlag(NI_MSG)) || (this->nc && this->nc->HasFlag(NI_MSG)))) - ircdproto->SendPrivmsg(source, this->nick, "%s", msg.c_str()); - else - ircdproto->SendNotice(source, this->nick, "%s", msg.c_str()); + sepstream sep(msg, '\n'); + Anope::string tok; + while (sep.GetToken(tok)) + { + if (Config->UsePrivmsg && ((!this->nc && Config->NSDefFlags.HasFlag(NI_MSG)) || (this->nc && this->nc->HasFlag(NI_MSG)))) + ircdproto->SendPrivmsg(source, this->nick, "%s", tok.c_str()); + else + ircdproto->SendNotice(source, this->nick, "%s", tok.c_str()); + } } /** Collides a nick. |