SRL Archive - Help and Support

My auto responder...


Drakan

2008-05-23 23:20:53

I need help improving my auto responder. i just made it so don't laugh but it works so far. I need some suggestions! It will find and respond so far. Also it won't respond to its self.

program AutoResponder;
{.include SRL/srl.scar}

var
author, LastResponded: string;

procedure DeclarePlayers;
begin
HowManyPlayers := 1;
NumberOfPlayers(HowManyPlayers);
CurrentPlayer := 0;

Players[0].Name :='wordupho';
end;

{*******************************************************************************
function GetChatAtLine(var chat: string; Line: integer): Boolean;
By: masquerader / Wizzup? / The[Cheese]
Description: Returns true if blue chat text was found
Edit by T[C]: Now looks at the line you specified.
*******************************************************************************}

function GetChatAt(var chat: string; Line: integer): Boolean;
var
x, y: Integer;
textP: TPoint;
begin
textP := TextCoords(Line);
if findcolor(x, y, 16711680, textp.x, textp.y, textp.x + 200, textp.y + 13) then
begin
chat := LowerCase(Trim(GetTextAtEx(x - 3, textp.y - 2, 0, SmallChars, False,
False, -1, 1, 16711680, 60, False, tr_allChars)));

Result := True;
end;
end;

{*******************************************************************************
function LastChatter(var name: String): Boolean;
By: masquerader
Description:Returns name and true if a person was talking, or false and the text
*******************************************************************************}

function LastChatterAt(var name: string; Line: integer): Boolean;
var
i: Integer;
textP: TPoint;
begin
textP := TextCoords(Line);
name := LowerCase(Trim(GetTextAtEx(textP.x - 2, textP.y - 2, 0, SmallChars, False, False, 0, 1,
0, 60, False, tr_allChars)))
i := Pos(':', name)
if (i <> 0) then
begin
Delete(name, i, i);
Result := True;
end;
end;

function GetLatestChat(text: TStringArray): boolean;
var
i, r: integer;
source: String;
begin
Result := false;
for i := 8 downto 5 do
if(GetChatAt(source, i))then
begin
Writeln('Found blue chat at line: '+inttostr(i)+': '+source);
for r := 0 to High(text) do
if((Pos(Lowercase(text[r]), source) > 0))then
begin
LastChatterAt(Author, i);
if not(Author = Lowercase(Players[CurrentPlayer].Name))then
begin
Result := true;
Writeln('Found question: '+text[r]+'. Author: '+Author);
Exit;
end else Writeln('That was our question!');
end else Writeln('Question is not: '+text[r]);
end;
end;

procedure AutoResponder(LookFor, RespondWith: TStringArray);
begin
if(GetLatestChat(LookFor))then
TypeSend(RespondWith[Random(High(RespondWith))]);
end;

begin
SetupSRL;
ActivateClient;
DeclarePlayers;
wait(2000);
AutoResponder(['hey', 'hello', 'whats up', 'sup', 'hi'],['hey', 'hello', 'hi', 'sup', 'hola']);
Writeln(author);
end.

Next thing i want to do is have it not respond to the same person until like 10 seconds have passed. How do i do this?

HyperSecret

2008-05-23 23:59:15

one thing ive noticed about you (a little thing) is that you need to get knowledgeable when you HAVE to have begin and ends…


function GetLatestChat(text: TStringArray): boolean;
var
i, r: integer;
source: String;
begin
Result := false;
for i := 8 downto 5 do
if(GetChatAt(source, i))then
begin
Writeln('Found blue chat at line: '+inttostr(i)+': '+source);
for r := 0 to High(text) do
if((Pos(Lowercase(text[r]), source) > 0))then
begin
LastChatterAt(Author, i);
if not(Author = Lowercase(Players[CurrentPlayer].Name))then
begin
Result := true;
Writeln('Found question: '+text[r]+'. Author: '+Author);
Exit;
end else Writeln('That was our question!');
end else Writeln('Question is not: '+text[r]);
end;
end;

procedure AutoResponder(LookFor, RespondWith: TStringArray);
begin
if(GetLatestChat(LookFor))then
TypeSend(RespondWith[Random(High(RespondWith))]);
end;

just to shorten it up a bit

Gu3st...

2008-05-24 02:24:12

And in the DeclarePlayers; this would not work, because SRL expect that your player is active and got a password, and you could add those global variables into your GetLatestChat

On the other side: Great work! :)

Drakan

2008-05-24 07:14:24

Yah declare players thing was just to find name :p
Anyone got ideas on how to not talk to someone it just talked to for 10 seconds?

Ashur2Good

2008-05-24 07:17:25

Idk about you, but i just use this :



/////////////////////////////Auto Talk1/////////////////////////////////////////
procedure AutoTalk1;
begin
if (InChat('noobs'))or
(InChat('noobz'))or
(InChat('noob'))or
(InChat('nub'))or
(InChat('nab'))or
(InChat('froob'))or
(InChat('loser'))or
(InChat('choob'))then
begin
Wait(500 + Random(500));
TypeSend('youre the noob');
end;
end;
/////////////////////////////Auto Talk1/////////////////////////////////////////


-Ashur

Drakan

2008-05-24 08:20:59

I would, but this is for my mining script. That only gets the last chat message, and when your mining you get a lot of black messages which keep you from seeing those. Thats why i make it find lines 8-5