An example of working with ICQ unit

Example of using the ICQ module. When bot starts, it will go into one ICQ and make a request to another, if it receives answer "Y", it will start logging about actions/state (in fact, anything can happen - spawn of RB\drop of valuable items, etc.)

uses SysUtils, ICQ;

const
  ICQ_UIN = 123456;         // ICQ on which the bot will go
  ICQ_PASSW = 'passw';      // password for login
  ICQ_CONTACT = 11223344;   // ICQ who needs to write

type
  TMyICQ = class(TICQ)  // Declare the class inherited from TICQ
  public
    procedure OnMessageRecv(Sender: TObject; Msg, UIN: string); override;  // redesignate the event to incoming messages
  end;

var
  MyICQ: TMyICQ;
  IcqLog: boolean = false;

procedure TMyICQ.OnMessageRecv(Sender: tobject; Msg, UIN: string);
begin
  if (UpperCase(Msg) = 'Y') then begin                                       // if we got answer "yes" then 
    MyICQ.SendMessage(ICQ_CONTACT, 'ОК! Start logging...');                  // write a message in response
    IcqLog:= true;                                                           // and enable logging      
  end;
end;

procedure Log(S: string);
begin
  if IcqLog then MyICQ.SendMessage(ICQ_CONTACT, S);
end;

procedure OnFree; // Called before stopping the script, to cleanup resources
begin
  Log('Disconnect');
  IcqLog:= false;
  MyICQ.Free;
end;

procedure Fight;
begin
  Log('Going to kill him: ' + User.Target.Name);  
  if User.DistTo(User.Target) > 100 then Engine.MoveToTarget(-50);
  while (not User.Target.Dead) do Engine.Attack();
  Log('Killed mob. My HP: ' + IntToStr(User.HP) + '%');
end;

begin
  MyICQ := TMyICQ.create;
  if MyICQ.Connect(ICQ_UIN, ICQ_PASSW) then begin
    MyICQ.SendMessage(ICQ_CONTACT, 'Hello! This is your bot ' + User.Name);
    MyICQ.SendMessage(ICQ_CONTACT, 'Do you wanna get logs in ICQ: Y / N ?');
  end;
  Delay(-1);
end.