//
#include "stdafx.h"
#include "DDO_text_in.h"
#include <windows.h>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <fstream>
#include <strstream>
#include <stdio.h>
#include <iomanip>
#include <string>
#include <sstream>
#include <algorithm>
#include <time.h>
#include <sys/timeb.h>
#include <wchar.h>
#include <sstream>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <winsock.h>
//
using namespace std;
//
BEGIN_MESSAGE_MAP(CsampleApp, CWinApp)
END_MESSAGE_MAP()
//
#define PLUGIN_UNIQID "CSLLLYPS"
//
#define MAX_STRING 256
//
//char* prova;
extern int mia_var=10;
extern char* prova="";
//
CsampleApp::CsampleApp()
{
// construction
}
//
CsampleApp theApp;
//
void __cdecl cfbot_plugininformation(CFBOT_PLUGININFORMATION *info)
{
//
strcpy(info->uniqid, PLUGIN_UNIQID); // 8 chars UNIQUE ID + \0 as a line end
info->pluginversion = CF_BOT_VERSION(0, 4);
info->desired_botversion = CF_BOT_VERSION(3, 94);
//
_tcscpy(info->authors, _T("DARKRURIK plugin DDO_text_in"));
_tcscpy(info->email, _T("mailto:rurik@supereva.it"));
_tcscpy(info->http, _T("http://www.darkrurik.com"));
_tcscpy(info->plugindescription, _T("DARKRURIK version plugin DDO_text_in"));
//
}
int __cdecl cfbot_initialize(CFBOT_CALLBACKS *callbacks, char *path, void *context)
{
//
CopyMemory(&theApp.host, callbacks, sizeof(CFBOT_CALLBACKS));
theApp.context = context;
//
theApp.host.cfbot_subscribe(theApp.context, PLUGIN_UNIQID, CF_BOT_IM_EVENTS);
theApp.host.cfbot_subscribe(theApp.context, PLUGIN_UNIQID, CF_BOT_ROOM_EVENTS);
//
return 1;
//
}
//
const char* convertToAscii(const TCHAR *rawString)
{
const std::wstring ws(rawString);
std::string s(ws.begin(), ws.end());
s.assign(ws.begin(), ws.end());
return s.c_str();
}
//
wchar_t* ConvertToWideChar(char* p)// function which converts char to widechar
{
wchar_t *r;
r = new wchar_t[strlen(p)+1];
char *tempsour = p;
wchar_t *tempdest = r;
while(*tempdest++=*tempsour++);
return r;
}
//
void Testo_ROOM(_tstring t_data)
{
_bot_exchange_format f;
_tstring nickname = (_tstring)f[0x01];
_tstring text = (_tstring)f[0x02];
BYTE attributes = (BYTE)f[0x03];
BYTE size = (BYTE)f[0x04];
DWORD color = (DWORD)f[0x05];
DWORD effects = (DWORD)f[0x06];
BYTE charset = (BYTE)f[0x07];
BYTE pitch = (BYTE)f[0x08];
std::string font = (std::string)f[0x09];
_bot_exchange_format p(PLUGIN_EVENT_ROOM_TEXT); //PLUGIN_EVENT_ROOM_TEXT); //PLUGIN_EVENT_IM);
p << _bot_value(0x01, t_data);
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();
theApp.host.cfbot_pushevent(theApp.context, PLUGIN_UNIQID, (char *)d.data(), d.size());
}
//
void Comando_ROOM(char *event_data, int event_size)
{
_bot_exchange_format f;
if (f.receive(std::string(event_data, event_size)))
{
switch(f.pid)
{
case BOT_EVENT_ROOM_TEXT: //Comandi dentro la Box di Yesto Principale
{
_tstring nickname = (_tstring)f[0x01];
_tstring text = (_tstring)f[0x02];
BYTE attributes = (BYTE)f[0x03];
BYTE size = (BYTE)f[0x04];
DWORD color = (DWORD)f[0x05];
DWORD effects = (DWORD)f[0x06];
BYTE charset = (BYTE)f[0x07];
BYTE pitch = (BYTE)f[0x08];
std::string font = (std::string)f[0x09];
if (text.length() > 0)
{
_tcsupr((TCHAR *)text.c_str());
if (!_tcscmp(text.c_str(), _T("!V")))
{
}
}
} break;
}
}
}
//
/* Funzione Somma */
extern "C" __declspec(dllexport) short Somma(short a, short b)
{
return a+b;
}
//
extern "C" __declspec(dllexport) char* Testo(char* c, char* r)
{
//
return prova;
//
}
//
void __cdecl cfbot_pushevent(char *event_data, int event_size)
{
//
_bot_exchange_format f;
if (f.receive(std::string(event_data, event_size)))
{
switch(f.pid)
{
case BOT_EVENT_ROOM_IN:
{
//
//
} break;
case BOT_EVENT_ROOM_TEXT:
{
//
_tstring nickname = (_tstring)f[0x01];
_tstring text = (_tstring)f[0x02];
BYTE attributes = (BYTE)f[0x03];
BYTE size = (BYTE)f[0x04];
DWORD color = (DWORD)f[0x05];
DWORD effects = (DWORD)f[0x06];
BYTE charset = (BYTE)f[0x07];
BYTE pitch = (BYTE)f[0x08];
std::string font = (std::string)f[0x09];
//
//
} break;
case BOT_EVENT_ROOM_OUT:
{
//
//
} break;
}
}
//
}
void __cdecl cfbot_finalize(void)
{
// finalize plugin
}
void __cdecl cfbot_display_settings(void)
{
//
AfxMessageBox(_T("Settings window is not available for this plugin"), MB_OK | MB_ICONINFORMATION);
//
}
//
BOOL CsampleApp::InitInstance()
{
//
CWinApp::InitInstance();
//
return TRUE;
//
}