1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88
|
void bot_manager_item::on_push_event(bot_exchange_format f)
{
switch (f.pid)
{
case BOT_EVENT_IM:
{
std::string nickname = std::string(f[0x01]);
int feedback = (int)f[0x02];
u_char age = (u_char)f[0x03];
std::string text = std::string(f[0x04]);
u_char attributes = (u_char)f[0x05];
u_char size = (u_char)f[0x06];
u_long color = (u_long)f[0x07];
u_long effects = (u_long)f[0x08];
u_char charset = (u_char)f[0x09];
u_char pitch = (u_char)f[0x0A];
std::string font = (std::string)f[0x0B];
if (!text.empty())
{
transform(text.begin(), text.end(), text.begin(), toupper);
if (!strcmp(text.c_str(), "/VER"))
{
bot_exchange_format p(PLUGIN_EVENT_IM);
p << bot_value(0x01, nickname);
std::string text = ("James' Camfrog Bot 5.1 Sample Plugin");
p << bot_value(0x02, text.c_str() );
p << bot_value(0x03, attributes);
p << bot_value(0x04, size);
p << bot_value(0x05, color);
p << bot_value(0x06, effects);
p << bot_value(0x07, charset);
p << bot_value(0x08, pitch);
p << bot_value(0x09, font);
std::string d = p.data();
_mngr->deliver_event(_name.c_str(), d.c_str(), (int)d.size());
}
}
} break;
case BOT_EVENT_ROOM_TEXT:
{
std::string nickname = std::string(f[0x01]);
std::string text = std::string(f[0x02]);
u_char attributes = (u_char)f[0x03];
u_char size = (u_char)f[0x04];
u_long color = (u_long)f[0x05];
u_long effects = (u_long)f[0x06];
u_char charset = (u_char)f[0x07];
u_char pitch = (u_char)f[0x08];
std::string font = (std::string)f[0x09];
if (!text.empty())
{
transform(text.begin(), text.end(), text.begin(), toupper);
if (!strcmp(text.c_str(), ".&trigg[0]."))
{
bot_exchange_format p(PLUGIN_EVENT_ROOM_TEXT);
p << bot_value(0x01, ".&alert[0].");
p << bot_value(0x02, attributes);
p << bot_value(0x03, size);
p << bot_value(0x04, color);
p << bot_value(0x05, effects);
p << bot_value(0x06, charset);
p << bot_value(0x07, pitch);
p << bot_value(0x08, font);
std::string d = p.data();
_mngr->deliver_event(_name.c_str(), d.c_str(), (int)d.size());
}
}
} break;
|