SRL Archive - SRL Archives

FindReply & FindReplyAnyLine


Rich

2009-05-11 22:26:16

These are two functions that will return true if they have found text, and replied to it.

//function FindReply(Finds : TStringArray; Replies : TStringArray) : Boolean;
//By R1ch
//Example: if FindReply(['hi', 'hey'], ['hello', 'wassup']) then
function FindReply(Finds : TStringArray; Replies : TStringArray) : Boolean;
var
F, R : Integer;

begin
for F:= 0 to High(Finds) do
if InChat(Finds[F]) then
begin
R:= Random(High(Replies));
TypeSend(Replies[R]);
Result:= True;
end else
Result:= False;
end;



//function FindReplyAnyLine(Finds, Replies : TStringArray; OnLine, TextColor : Integer;) : Boolean;
//By R1ch
//Example: if FindReplyAnyline(['hi', 'hey'], ['hello', 'wassup'], 8, clBlue) then
function FindReplyAnyLine(Finds, Replies : TStringArray; OnLine, TextColor : Integer;) : Boolean;
var
F, R : Integer;

begin
for F:= 0 to High(Finds) do
if FindChatBoxText(Finds[F], OnLine, TextColor) then
begin
R:= Random(High(Replies));
TypeSend(Replies[R]);
Result:= True;
end else
Result:= False;
end;

Of course they could be used like:
var
Text, Reply : TStringArray;

begin
Text:= ['hi', 'hey']
Reply:= ['hello', 'wassup']
if FindReply(Text, Reply) then...

Comments?

Richard

EvilChicken!

2009-05-11 23:12:06

I think Friends.scar in /misc/ has something like what you've done.

Rich

2009-05-11 23:23:32

Oh, ok then, I'll have a quick look at that, and see how similar the are.

Thanks,
Richard

EDIT: I've had a look and as far as I can see, the closest one is a function that messages a friend.