The complete source code of IdealIRC
http://www.idealirc.org/
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
98 lines
3.0 KiB
98 lines
3.0 KiB
#include "ICommand/ICommandPriv.h"
|
|
#include "ICommand/Commands.h"
|
|
#include "IRCClient/IRCChannel.h"
|
|
|
|
using namespace Command::Internal;
|
|
|
|
void ICommandPriv::cmd_echo(const std::string& arg1, const std::string& arg2, const std::string& text)
|
|
{
|
|
PrintType color = PrintType::Normal;
|
|
std::string target; // Blank string -> active window
|
|
|
|
auto handleArgument = [this,&color,&target] (const std::string& arg) {
|
|
if (arg.substr(0, 2) == "--") {
|
|
target = arg.substr(2);
|
|
}
|
|
else {
|
|
char col = arg[1];
|
|
switch (col) {
|
|
case 'A':
|
|
color = PrintType::Action;
|
|
break;
|
|
case 'C':
|
|
color = PrintType::CTCP;
|
|
break;
|
|
case 'S':
|
|
color = PrintType::ServerInfo;
|
|
break;
|
|
case 'H':
|
|
color = PrintType::Highlight;
|
|
break;
|
|
case 'I':
|
|
color = PrintType::Invite;
|
|
break;
|
|
case 'J':
|
|
color = PrintType::Join;
|
|
break;
|
|
case 'K':
|
|
color = PrintType::Kick;
|
|
break;
|
|
case 'M':
|
|
color = PrintType::Mode;
|
|
break;
|
|
case 'N':
|
|
color = PrintType::Nick;
|
|
break;
|
|
case 'R':
|
|
color = PrintType::Normal;
|
|
break;
|
|
case 'E':
|
|
color = PrintType::Notice;
|
|
break;
|
|
case 'O':
|
|
color = PrintType::OwnText;
|
|
break;
|
|
case 'P':
|
|
color = PrintType::Part;
|
|
break;
|
|
case 'G':
|
|
color = PrintType::ProgramInfo;
|
|
break;
|
|
case 'Q':
|
|
color = PrintType::Quit;
|
|
break;
|
|
case 'T':
|
|
color = PrintType::Topic;
|
|
break;
|
|
case 'W':
|
|
color = PrintType::Wallops;
|
|
break;
|
|
default:
|
|
super.print_invalidCommandSwitch("echo");
|
|
return false;
|
|
}
|
|
}
|
|
return true;
|
|
};
|
|
|
|
if (!arg1.empty() && !handleArgument(arg1))
|
|
return;
|
|
|
|
if (!arg2.empty() && !handleArgument(arg2))
|
|
return;
|
|
|
|
if (target.empty()) {
|
|
auto* win = status.getActiveWindow();
|
|
win->print(color, QString::fromStdString(text));
|
|
}
|
|
else if (target == "-") {
|
|
status.print(color, QString::fromStdString(text));
|
|
}
|
|
else {
|
|
auto* win = MdiManager::instance().findWindow(&status, QString::fromStdString(target));
|
|
if (!win)
|
|
win = status.getActiveWindow();
|
|
|
|
win->print(color, QString::fromStdString(text));
|
|
}
|
|
}
|
|
|