Code
unit bot;
interface
uses
SysUtils, Classes, Windows;
type
tSendMessage = function(msgid: Integer; objid: PWideChar; param: Pointer; paramsize: integer): boolean; stdcall;
tRecvMessage = function(msgid: Integer; objid: PWideChar; param: Pointer; paramsize: integer): boolean; stdcall;
tQueryInfo = procedure(queryid: integer; objid: PWideChar; param: Pointer; paramsize: integer); stdcall;
tFreeInfo = procedure(info: Variant); stdcall;
type
TBotInit = record
apiVersion: DWORD;
appName: PWideChar;
appVersion: PWideChar;
SendMessage: tSendMessage;
QueryInfo: tQueryInfo;
FreeInfo: tFreeInfo;
botApiVersion: DWORD;
botId: PWideChar;
botVersion: PWideChar;
botCopyright: PWideChar;
RecvMessage: tRecvMessage;
eventMask: DWORD;
end;
SearchParams = record
searchContent: integer; // enum SearchTypeModes
sizeMode: integer; // enum SearchSizeModes
size: TLargeInteger;
end;
DlFileListParams = record
flags: integer; // enum DlFileListFlags
end;
const
SEND_PM = 0;
SEND_SIM_PM = 1;
SEND_CM = 2;
SEND_SIM_CM = 3;
SEND_CLOSE = 4;
SEND_PRIVMODE = 5;
SEND_BAN = 6;
SEND_SLOT = 7;
SEND_DL_MAGNET = 8;
SEND_SEARCH = 9; // v3
SEND_SYSLOG_MSG = 10; // v3
SEND_DL_FILELIST= 11; // v4
SEND_DL_PING = 12; // v4
SET_RECV_EVENTS = 20; // v3
RECV_COMMAND = 40;
RECV_PM = 41;
RECV_CM = 42;
RECV_USER_UPDATE = 43;
RECV_USER_PART = 44;
RECV_HUB_CONNECT = 45;
RECV_HUB_DISCONNECT = 46;
RECV_PM_DROPPED = 47;
RECV_SEARCH_QUERY = 48; // v3
RECV_SEARCH_RESULT = 49; // v3
RECV_DL_FINISHED = 50; // v4
QUERY_USER_BY_UID = 80;
QUERY_HUB_BY_URL = 81;
QUERY_CONNECTED_HUBS = 82;
QUERY_HUB_USERS = 83;
QUERY_RUNNING_UPLOADS = 84;
QUERY_QUEUED_UPLOADS = 85;
QUERY_DOWNLOADS = 86;
QUERY_SELF = 87;
PM_NORMAL = 0;
PM_SKIPPASSWORD = 1;
PM_IGNORE = 2;
PM_HARDIGNORE = 3;
TYPE_ANY = 0;
TYPE_AUDIO = 1;
TYPE_COMPRESSED = 2;
TYPE_DOCUMENT = 3;
TYPE_EXECUTABLE = 4;
TYPE_PICTURE = 5;
TYPE_VIDEO = 6;
TYPE_DIRECTORY = 7;
TYPE_TTH = 8;
TYPE_CD_IMAGE = 9;
SIZE_DONTCARE = $00;
SIZE_ATLEAST = $01;
SIZE_ATMOST = $02;
SIZE_EXACT = $03;
// for SET_RECV_EVENTS
F_RECV_COMMAND = 1 shl 0;
F_RECV_PM = 1 shl 1;
F_RECV_CM = 1 shl 2;
F_RECV_USER_UPDATE = 1 shl 3;
F_RECV_USER_PART = 1 shl 4;
F_RECV_HUB_CONNECT = 1 shl 5;
F_RECV_HUB_DISCONNECT = 1 shl 6;
F_RECV_PM_DROPPED = 1 shl 7;
F_RECV_SEARCH_QUERY = 1 shl 8;
F_RECV_SEARCH_RESULT = 1 shl 9;
F_RECV_DL_FINISHED = 1 shl 10;
F_DL_FILELIST_OPEN = 1;
F_DL_FILELIST_MATCH = 2;
F_DL_FILELIST_CHECK = 4;
var
SendProc: tSendMessage;
function RecvMessage(msgid: Integer; objid: PWideChar; param: Pointer; paramsize: integer): boolean; stdcall;
function init(var _init: TBotInit): boolean; stdcall;
exports init;
implementation
function RecvMessage(msgid: Integer; objid: PWideChar; param: Pointer; paramsize: integer): boolean; stdcall;
begin
SendProc(SEND_SYSLOG_MSG, 'I Am Here!', nil, 0);
result := false;
end;
function init(var _init: TBotInit): boolean; stdcall;
begin
Randomize;
result := true;
_init.botApiVersion := 5;
_init.botId := 'simple bot';
_init.botVersion := '1.0';
_init.botCopyright := 'Enyby (c) 2011';
_init.RecvMessage := RecvMessage;
_init.eventMask := F_RECV_COMMAND and F_RECV_PM;
SendProc := _init.SendMessage;
end;
end.
Есть подозрение что привел к делфи как-то не так. Помогите, кто знает, пожалуйста.
Из текущих успехов - greylink читает библиотеку, загружает ее, но видимого эффекта нет.