Example #1
0
void eightBallBot::onMessage(ircMessage& msg)
{
	std::string cmd = msg.message().substr(0, 6);
	if(!cmd.compare("!8ball"))
	{
		_utils->sendMessage(msg.channel(), replys[getRandom()]);
	}
}
Example #2
0
void hURLbot::onMessage(ircMessage& msg){
	if(!msg.message().compare("!userList")){
		std::cout << "hURLbot: gonna hURL" << std::endl;
		ircUser* user = msg.user();

		utils->sendPM(user->nick(), "Here ya go:");

		std::vector<ircUser*>::iterator iter;
		std::vector<ircUser*> users = utils->getAllUsers();

		for(iter = users.begin(); iter != users.end(); iter++){
			utils->sendPM(user->nick(), (*iter));
		}

	}

}
/*std::string OmniJoinCmd::resultStr()
{
	return _results;
}
void OmniJoinCmd::clear()
{
	_results = "";
}*/
bool OmniJoinCmd::exec(ircMessage& msg)
{
	std::istringstream tokenizer(msg.message());
	std::string token;

	while(getline(tokenizer, token, ' '))
	{
		if(token.compare(name()) == 0)
		{
			continue;
		}
		else
		{
			_irc->join(token);
			break;
		}
	}

	return false;
}
Example #4
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;
				}
			}	
		}
	}
}
Example #5
0
/**
 * Omnibot ircInterface Callback.
 * This function is called by _irc when ever a new message arrives it processes it through the
 * command classes first to see if it is directed at the omnibot or not, then passes the messages
 * to plugins for evaluation
 * @parm msg an ircMessage structure containing the message from the server
 * @return void
 */
void omnibot::alertMessage(ircMessage& msg)
{
	//std::cout << "Omnibot received string: " + toParse <<  std::endl;
	ircLog::instance()->logf(FILENAME, "Omnibot received string: %s", msg.message().c_str());

	size_t i;
	
	ircLog::instance()->logf(FILENAME, "using commands at %x", _commands);
	ircLog::instance()->logf(FILENAME, "number of commands %u", _commands->size());

	//loop over command class to identify any commands
	for(i = 0; i < _commands->size(); ++i)
	{

		ircLog::instance()->logf(FILENAME, "trying command %s", (*_commands)[i]->name().c_str());

		if((*_commands)[i]->isCommandString(msg))
		{
			if((*_commands)[i]->exec(msg))
			{
				//TODO handle resultStrs;
				//probably by dumping them in the channel
			}

		}
	}

	//if we went all the way through the loop and nothing happend
	//send it to the plugins
	if(i >= _commands->size())
	{
		ircLog::instance()->logf(FILENAME, "sending message to plugin mananger");
		_manager.pushMessage(msg);
	}


}
Example #6
0
void testClass::alertMessage(ircMessage& m) {
	std::cout << "TestClass: " << m.user()->nick() << ": " << m.message()
			<< std::endl;
}
/*std::string OmniListCmd::resultStr()
{
	return _results; 
}
void OmniListCmd::clear()
{
	_results = "";
}*/
bool OmniListCmd::exec(ircMessage& msg){
	_irc->sendMessage(msg.channel(), "Loaded Plugins: " +_plugins->listLoadedPlugins());
	return false;
}