rendered paste body// BZFSbot.cpp : Defines the entry point for the DLL application.
//
#include "bzfsAPI.h"
#include <string>
BZ_GET_PLUGIN_VERSION
BZF_PLUGIN_CALL int bz_Load ( const char* commandLine )
{
bz_debugMessage(4,"BZFSBot plugin loaded. Party Time!");
return 0;
}
BZF_PLUGIN_CALL int bz_Unload ( void )
{
bz_debugMessage(4,"BZFSBot plugin unloaded");
return 0;
}
class BZFSBotHandler : public bz_EventHandler
{
public:
BZFSBotHandler();
virtual ~BZFSBotHandler();
virtual void process ( bz_EventData *eventData );
virtual bool autoDelete ( void ) { return false;} // this will be used for more then one event
};
BZFSBotHandler::BZFSBotHandler()
{
}
BZFSBotHandler::~BZFSBotHandler()
{
}
BZFSBotHandler bot;
void BZFSBotHandler::process ( bz_EventData *eventData )
{
switch (eventData->eventType)
{
default:
// really WTF!!!!
break;
case bz_eChatMessageEvent:
{
bz_ChatEventData *chat = (bz_ChatEventData*)eventData;
int sender = chat->from;
std::string message = chat->message.c_str();//convert bzAPI string to std::string for substr
std::string a = message.substr(1);
if(a==std::string('~'))
{
if(message.substr(3)==std::string("~hi")){
bz_sendTextMessage(BZ_SERVER, BZ_ALL_USERS, "Hello");
}
}
}
break;
}
}