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.
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?
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?