Ejemplo n.º 1
0
LemonHandler::ProcessingResult RSSWatcher::HandleMessage(const ChatMessage &msg)
{
	std::string args;
	if (getCommandArguments(msg._body, "!addrss", args)
			&& msg._isAdmin)
	{
		RegisterFeed(args);
		UpdateFeeds();
		return ProcessingResult::StopProcessing;
	} else if (getCommandArguments(msg._body, "!delrss", args)
			   && msg._isAdmin) {
		UnregisterFeed(args);
		return ProcessingResult::StopProcessing;
	} else if (msg._body == "!listrss") {
		SendMessage(ListRSSFeeds());
	} else if (msg._body == "!updaterss"
			   && msg._isAdmin) {
		UpdateFeeds();
		return ProcessingResult::StopProcessing;
	} else if (getCommandArguments(msg._body, "!readrss", args)) {
		auto item = GetLatestItem(args);
		SendMessage(item.Format());
		return ProcessingResult::StopProcessing;
	}

	return ProcessingResult::KeepGoing;
}
Ejemplo n.º 2
0
TEST(StringOps, getArguments)
{
	std::string output;
	EXPECT_FALSE(getCommandArguments("!toost this", "!test", output));
	EXPECT_TRUE(output.empty());

	EXPECT_TRUE(getCommandArguments("!test", "!test", output));
	EXPECT_TRUE(output.empty());

	EXPECT_FALSE(getCommandArguments("!testfail", "!test", output));

	EXPECT_TRUE(getCommandArguments("!test ", "!test", output));
	EXPECT_TRUE(output.empty());

	EXPECT_TRUE(getCommandArguments("!test args", "!test", output));
	EXPECT_EQ("args", output);
}
Ejemplo n.º 3
0
LemonHandler::ProcessingResult TS3::HandleMessage(const ChatMessage &msg)
{
	std::string message;
	if (getCommandArguments(msg._body, "!tsay", message))
	{
		SendTS3Message(msg._nick, msg._jid, message);
		return ProcessingResult::StopProcessing;
	}

	if (msg._body != "!ts")
		return ProcessingResult::KeepGoing;

	if (_clients.empty())
		SendMessage("TeamSpeak server is empty");
	else
	{
		std::string online;
		for (auto &user : _clients)
			online.append(" " + user.second);

		SendMessage("Current TeamSpeak users online:" + online);
	}
	return ProcessingResult::StopProcessing;
}