diff options
Diffstat (limited to 'src/command.cpp')
-rw-r--r-- | src/command.cpp | 32 |
1 files changed, 22 insertions, 10 deletions
diff --git a/src/command.cpp b/src/command.cpp index 91e4507db..d71685f4f 100644 --- a/src/command.cpp +++ b/src/command.cpp @@ -8,6 +8,26 @@ #include "services.h" #include "modules.h" +CommandSource::~CommandSource() +{ + for (std::list<Anope::string>::iterator it = this->reply.begin(), it_end = this->reply.end(); it != it_end; ++it) + { + const Anope::string &message = *it; + + // Send to the user if the reply is more than one line + if (!this->fantasy || !this->ci || this->reply.size() > 1) + u->SendMessage(this->service->nick, message); + else if (this->ci->botflags.HasFlag(BS_MSG_PRIVMSG)) + ircdproto->SendPrivmsg(this->service, this->ci->name, message.c_str()); + else if (this->ci->botflags.HasFlag(BS_MSG_NOTICE)) + ircdproto->SendNotice(this->service, this->ci->name, message.c_str()); + else if (this->ci->botflags.HasFlag(BS_MSG_NOTICEOPS)) + ircdproto->SendNoticeChanops(this->service, this->ci->c, message.c_str()); + else + u->SendMessage(this->service->nick, message); + } +} + void CommandSource::Reply(LanguageString message, ...) { Anope::string m = GetString(this->u, message); @@ -27,7 +47,7 @@ void CommandSource::Reply(LanguageString message, ...) Anope::string line; while (sep.GetToken(line)) - this->Reply(line.empty() ? " " : line); + this->Reply(line.empty() ? " " : line.c_str()); } void CommandSource::Reply(const char *message, ...) @@ -40,20 +60,12 @@ void CommandSource::Reply(const char *message, ...) va_start(args, message); vsnprintf(buf, BUFSIZE - 1, message, args); - this->Reply(Anope::string(buf)); + this->reply.push_back(message); va_end(args); } } -void CommandSource::Reply(const Anope::string &message) -{ - if (this->fantasy && this->ci) - ircdproto->SendPrivmsg(this->service, this->ci->name, message.c_str()); - else - u->SendMessage(this->service->nick, message); -} - Command::Command(const Anope::string &sname, size_t min_params, size_t max_params, const Anope::string &spermission) : MaxParams(max_params), MinParams(min_params), name(sname), permission(spermission) { this->module = NULL; |