Example #1
0
bool Callable(std::string command)
{
	Protocol::Message args = command;
	if (args.size() < 1) return false;

	string cmd = to_lower_case(args[0]);

	return !!Command::list.count(cmd);
}
Example #2
0
void Call(string command)
{
	Protocol::Message args = command;
	if (args.size() < 1) return;

	string cmd = to_lower_case(args[0]);
	args.erase(args.begin());

	if (!Command::list.count(cmd))
		Echo(string("Unknown command: ") + cmd);
	else
	{
		pair<Command::Func,size_t> func = Command::list[cmd];
		if (args.size() < func.second)
			Echo(string("To few arguments: ") + cmd);
		else
			func.first(args);
	}
}