Example #1
0
void qdbbot::onMessage(ircMessage& msg)
{
	std::string text = msg.message();

	std::cout << "qdb: message is: " << text << std::endl;

	std::string cmd = text.substr(0,4);

	if(!cmd.compare("!qdb") || !cmd.compare("!qdb") || !cmd.compare("!qdb"))
	{
		if(text.size() == 4)
		{
			qdbbot::bashQuote* q = nextBash();
			if(!msg.isPrivateMsg())
			{
				printQuote(q, msg.channel());
				delete q;
			}
		}
		else
		{
			std::string arg = text.substr(5);
			int i  = ::atoi(arg.c_str());
			std::cout << "qdbbot: the bash arg was: " << arg << " i = " << i << std::endl;
			if(i == 0)
			{
				if(!msg.isPrivateMsg())
				{
					utils->sendMessage(msg.channel(), search(arg));
				}
			}
			else
			{
				qdbbot::bashQuote* q = bashNum(arg);
				if(!msg.isPrivateMsg())
				{
					printQuote(q, msg.channel());
					delete q;
				}
			}	
		}
	}
}