Log in

View Full Version : An Autoresponder...



final_result
07-01-2009, 09:36 AM
I've been using several scripts for sometime and I'm having a hard time editing them.. I'm trying to set up a auto responder for some of the scripts I have... I'm not too quite sure how to do that as I've looked at some other autoresponders (such as Zephyr's tree one) but they are at least 100 lines and I have no idea how to write an autoresponder like that. The only tut I could fine was 8 months old and I doubt that's really useful

Could someone show me how to make a simple autoresponder and where to insert it into a script?

ian.
07-01-2009, 09:59 AM
Just do what Zephypoo does in his script? You can take his and use it how it how he does. :]

final_result
07-01-2009, 10:33 AM
Just do what Zephypoo does in his script?

ZEPHYPOO?

Anyways, I have no idea how the autoresponder works, I don't have any idea what those hundreds of lines of code mean. I tried :o

TRiLeZ
07-01-2009, 10:36 AM
procedure AutoRespond;
begin
case lowercase(GetChatBoxText(8, clChat)) of
'hey': TypeSend('Hey man');
end;
end;

Its as simple as that.
Made by myself :)

final_result
07-01-2009, 11:12 AM
I'll try putting that in my script.. Not sure how it works though.

TRiLeZ
07-01-2009, 11:32 AM
My procedure gets the blue chat in the 8th line and the case is like if the chat is 'hey' then it will type and send 'Hey man'.

Call that procedure everytime you want the script to auto respond to anything said.

ZephyrsFury
07-01-2009, 11:55 AM
Basically what an autoresponder is:

Check for other players' chat.
Cross reference the players' chat with what you're looking for.
If players' chat matches what you're looking for then respond.


Step 1, usually pretty simple. You just need some place to find what other people are saying. Its easiest to use the chatbox as it shows all the text in a small area. (I've seen people trying to use the mainscreen too though). Try having a look at Chat.scar for functions that Get the ChatBox Text or Find the chat box text.

Step 2, I'd say this is the hardest part as it can get very complicated. For small autoresponders this is isn't too hard but as you try to add lots of triggers and responses it can get very inefficient and slow. A simple method is to get the chat box text in the last line then just checking if your deserved trigger words are in that line.

Step 3. You have to be careful here too. You must have a variety of responses so that you don't look like a bot and respond to everything with the same phrase. In a simple responder you could just randomly choose the phrases. Then use TypeSend() to type the text into the game.

So final result: Simple autoresponder (that you probably shouldn't use without major modifications).

procedure AutoRespond;
var
RandomNum: Integer;
LastLineText: string;
begin
LastLineText := Lowercase(GetChatBoxText(8, clBlue)); //Step 1
if (Pos('hi', LastLineText) > 0) or (Pos('hello', LastLineText) > 0) or (Pos('hey', LastLineText) > 0) then //Step 2
begin
WriteLn('Found autoresponder text');
RandomNum := Random(3);
case RandomNum of //Step 3
0: TypeSend('hello');
1: TypeSend('hi');
2: TypeSend('hey');
end;
Exit;
end;
if (Pos('wc lvl', LastLineText) > 0) or (Pos('wc level', LastLineText) > 0) or (Pos('cutting lvl', LastLineText) > 0) then //Step 2
begin
WriteLn('Found autoresponder text');
RandomNum := Random(3);
case RandomNum of //Step 3
0: TypeSend(IntToStr(YourWCLevel));
1: TypeSend('my wc is ' + IntToStr(YourWCLevel));
2: TypeSend('my wc level is ' + IntToStr(YourWCLevel));
end;
Exit;
end;
end;

TRiLeZ
07-01-2009, 01:06 PM
Basically what an autoresponder is:

Check for other players' chat.
Cross reference the players' chat with what you're looking for.
If players' chat matches what you're looking for then respond.


Step 1, usually pretty simple. You just need some place to find what other people are saying. Its easiest to use the chatbox as it shows all the text in a small area. (I've seen people trying to use the mainscreen too though). Try having a look at Chat.scar for functions that Get the ChatBox Text or Find the chat box text.

Step 2, I'd say this is the hardest part as it can get very complicated. For small autoresponders this is isn't too hard but as you try to add lots of triggers and responses it can get very inefficient and slow. A simple method is to get the chat box text in the last line then just checking if your deserved trigger words are in that line.

Step 3. You have to be careful here too. You must have a variety of responses so that you don't look like a bot and respond to everything with the same phrase. In a simple responder you could just randomly choose the phrases. Then use TypeSend() to type the text into the game.

So final result: Simple autoresponder (that you probably shouldn't use without major modifications).

procedure AutoRespond;
var
RandomNum: Integer;
LastLineText: string;
begin
LastLineText := Lowercase(GetChatBoxText(8, clBlue)); //Step 1
if (Pos('hi', LastLineText) > 0) or (Pos('hello', LastLineText) > 0) or (Pos('hey', LastLineText) > 0) then //Step 2
begin
WriteLn('Found autoresponder text');
RandomNum := Random(3);
case RandomNum of //Step 3
0: TypeSend('hello');
1: TypeSend('hi');
2: TypeSend('hey');
end;
Exit;
end;
if (Pos('wc lvl', LastLineText) > 0) or (Pos('wc level', LastLineText) > 0) or (Pos('cutting lvl', LastLineText) > 0) then //Step 2
begin
WriteLn('Found autoresponder text');
RandomNum := Random(3);
case RandomNum of //Step 3
0: TypeSend(IntToStr(YourWCLevel));
1: TypeSend('my wc is ' + IntToStr(YourWCLevel));
2: TypeSend('my wc level is ' + IntToStr(YourWCLevel));
end;
Exit;
end;
end;


Using "if"s for the responder is slow when you have like 5+ "if"s. Use a case and it will go a lot faster. Change that ^ into a case and it will basically look like my responder I gave.

Ill show you my full autoresponder that Im still adding to.


procedure AutoRespond;
var
MyLevel: integer;
begin
MyLevel:= GetMySkill(14,true);
case lowercase(GetChatBoxText(8, clChat)) of
'lvl?':
begin
case Random(3) of
0: TypeSend(IntToStr(MyLevel));
1: TypeSend(AddMistakes('I have ',25)+IntToStr(MyLevel)+AddMistakes('mining',25));
2: QCSayLevel('mining');
end;
Wait(RandomRange(500,750));
end;
'lvl':
begin
case Random(3) of
0: TypeSend(IntToStr(MyLevel));
1: TypeSend(AddMistakes('I have ',25)+IntToStr(MyLevel)+AddMistakes('mining',25));
2: QCSayLevel('mining');
end;
Wait(RandomRange(500,750));
end;
'lvls?':
begin
case Random(3) of
0: TypeSend(IntToStr(MyLevel));
1: TypeSend(AddMistakes('I have ',25)+IntToStr(MyLevel)+AddMistakes('mining',25));
2: QCSayLevel('mining');
end;
Wait(RandomRange(500,750));
end;
'lvls':
begin
case Random(3) of
0: TypeSend(IntToStr(MyLevel));
1: TypeSend(AddMistakes('I have ',25)+IntToStr(MyLevel)+AddMistakes('mining',25));
2: QCSayLevel('mining');
end;
Wait(RandomRange(500,750));
end;
'level?':
begin
case Random(3) of
0: TypeSend(IntToStr(MyLevel));
1: TypeSend(AddMistakes('I have ',25)+IntToStr(MyLevel)+AddMistakes('mining',25));
2: QCSayLevel('mining');
end;
Wait(RandomRange(500,750));
end;
'level':
begin
case Random(3) of
0: TypeSend(IntToStr(MyLevel));
1: TypeSend(AddMistakes('I have ',25)+IntToStr(MyLevel)+AddMistakes('mining',25));
2: QCSayLevel('mining');
end;
Wait(RandomRange(500,750));
end;
'levels?':
begin
case Random(3) of
0: TypeSend(IntToStr(MyLevel));
1: TypeSend(AddMistakes('I have ',25)+IntToStr(MyLevel)+AddMistakes('mining',25));
2: QCSayLevel('mining');
end;
Wait(RandomRange(500,750));
end;
'levels':
begin
case Random(3) of
0: TypeSend(IntToStr(MyLevel));
1: TypeSend(AddMistakes('I have ',25)+IntToStr(MyLevel)+AddMistakes('mining',25));
2: QCSayLevel('mining');
end;
Wait(RandomRange(500,750));
end;
'mining lvl?':
begin
case Random(3) of
0: TypeSend(IntToStr(MyLevel));
1: TypeSend(AddMistakes('I have ',25)+IntToStr(MyLevel)+AddMistakes('mining',25));
2: QCSayLevel('mining');
end;
Wait(RandomRange(500,750));
end;
'mining lvl':
begin
case Random(3) of
0: TypeSend(IntToStr(MyLevel));
1: TypeSend(AddMistakes('I have ',25)+IntToStr(MyLevel)+AddMistakes('mining',25));
2: QCSayLevel('mining');
end;
Wait(RandomRange(500,750));
end;
'mining lvls?':
begin
case Random(3) of
0: TypeSend(IntToStr(MyLevel));
1: TypeSend(AddMistakes('I have ',25)+IntToStr(MyLevel)+AddMistakes('mining',25));
2: QCSayLevel('mining');
end;
Wait(RandomRange(500,750));
end;
'mining lvls':
begin
case Random(3) of
0: TypeSend(IntToStr(MyLevel));
1: TypeSend(AddMistakes('I have ',25)+IntToStr(MyLevel)+AddMistakes('mining',25));
2: QCSayLevel('mining');
end;
Wait(RandomRange(500,750));
end;
'mining level?':
begin
case Random(3) of
0: TypeSend(IntToStr(MyLevel));
1: TypeSend(AddMistakes('I have ',25)+IntToStr(MyLevel)+AddMistakes('mining',25));
2: QCSayLevel('mining');
end;
Wait(RandomRange(500,750));
end;
'mining level':
begin
case Random(3) of
0: TypeSend(IntToStr(MyLevel));
1: TypeSend(AddMistakes('I have ',25)+IntToStr(MyLevel)+AddMistakes('mining',25));
2: QCSayLevel('mining');
end;
Wait(RandomRange(500,750));
end;
'mining levels?':
begin
case Random(3) of
0: TypeSend(IntToStr(MyLevel));
1: TypeSend(AddMistakes('I have ',25)+IntToStr(MyLevel)+AddMistakes('mining',25));
2: QCSayLevel('mining');
end;
Wait(RandomRange(500,750));
end;
'mining levels':
begin
case Random(3) of
0: TypeSend(IntToStr(MyLevel));
1: TypeSend(AddMistakes('I have ',25)+IntToStr(MyLevel)+AddMistakes('mining',25));
2: QCSayLevel('mining');
end;
Wait(RandomRange(500,750));
end;
'mine lvl?':
begin
case Random(3) of
0: TypeSend(IntToStr(MyLevel));
1: TypeSend(AddMistakes('I have ',25)+IntToStr(MyLevel)+AddMistakes('mining',25));
2: QCSayLevel('mining');
end;
Wait(RandomRange(500,750));
end;
'mine lvl':
begin
case Random(3) of
0: TypeSend(IntToStr(MyLevel));
1: TypeSend(AddMistakes('I have ',25)+IntToStr(MyLevel)+AddMistakes('mining',25));
2: QCSayLevel('mining');
end;
Wait(RandomRange(500,750));
end;
'mine lvls?':
begin
case Random(3) of
0: TypeSend(IntToStr(MyLevel));
1: TypeSend(AddMistakes('I have ',25)+IntToStr(MyLevel)+AddMistakes('mining',25));
2: QCSayLevel('mining');
end;
Wait(RandomRange(500,750));
end;
'mine lvls':
begin
case Random(3) of
0: TypeSend(IntToStr(MyLevel));
1: TypeSend(AddMistakes('I have ',25)+IntToStr(MyLevel)+AddMistakes('mining',25));
2: QCSayLevel('mining');
end;
Wait(RandomRange(500,750));
end;
'mine level?':
begin
case Random(3) of
0: TypeSend(IntToStr(MyLevel));
1: TypeSend(AddMistakes('I have ',25)+IntToStr(MyLevel)+AddMistakes('mining',25));
2: QCSayLevel('mining');
end;
Wait(RandomRange(500,750));
end;
'mine level':
begin
case Random(3) of
0: TypeSend(IntToStr(MyLevel));
1: TypeSend(AddMistakes('I have ',25)+IntToStr(MyLevel)+AddMistakes('mining',25));
2: QCSayLevel('mining');
end;
Wait(RandomRange(500,750));
end;
'mine levels?':
begin
case Random(3) of
0: TypeSend(IntToStr(MyLevel));
1: TypeSend(AddMistakes('I have ',25)+IntToStr(MyLevel)+AddMistakes('mining',25));
2: QCSayLevel('mining');
end;
Wait(RandomRange(500,750));
end;
'mine levels':
begin
case Random(3) of
0: TypeSend(IntToStr(MyLevel));
1: TypeSend(AddMistakes('I have ',25)+IntToStr(MyLevel)+AddMistakes('mining',25));
2: QCSayLevel('mining');
end;
Wait(RandomRange(500,750));
end;
'hi':
begin
case Random(3) of
0: TypeSend('Hi');
1: TypeSend('Hey');
2: QCSayLevel('Hello');
end;
Wait(RandomRange(500,750));
end;
'hey':
begin
case Random(3) of
0: TypeSend('Hi');
1: TypeSend('Hey');
2: QCSayLevel('Hello');
end;
Wait(RandomRange(500,750));
end;
'hello':
begin
case Random(3) of
0: TypeSend('Hi');
1: TypeSend('Hey');
2: QCSayLevel('Hello');
end;
Wait(RandomRange(500,750));
end;
'what is your level in mining?': QCSayLevel('mining');
'what pickaxe are you using?':
begin
case Random(4) of
0: TypeSend(AddMistakes(MyPick,20));
1: TypeSend(AddMistakes('I am using a ',25)+MyPick+AddMistakes('pickaxe',25));
1: TypeSend(AddMistakes('Im using a ',25)+MyPick+AddMistakes('pickaxe',25));
2:
begin
QCOpenMenu('Skill',['i',4]);
case MyPick of
'bronze': Mouse(22, 400, 6, 2, true);
'iron': Mouse(22, 414, 6, 2, true);
'steel': Mouse(22, 455, 6, 2, true);
'mithril': Mouse(22, 427, 6, 2, true);
'adamant': Mouse(22, 386, 6, 2, true);
'rune': Mouse(22, 442, 6, 2, true);
end;
end;
end;
end;
'what ore are you mining?':
begin
case Random(2) of
0: TypeSend(AddMistakes('Im mining ',25)+Players[CurrentPlayer].Strings[0]+'ore');
1: TypeSend(Players[CurrentPlayer].Strings[0]);
end;
Wait(RandomRange(500,750));
end;
end;
end;

Responds in less than a second.

ZephyrsFury
07-01-2009, 01:45 PM
It isn't slow and your example doesn't do what mine does exactly. With your example the last line has to equal your text exactly, I just check if the trigger is part of it.

TRiLeZ
07-01-2009, 03:22 PM
Oh sorry I thought that it reads the text everytime scar checks for re-occurance.
I read that wrong

DeSnob
07-01-2009, 07:03 PM
It isn't slow and your example doesn't do what mine does exactly. With your example the last line has to equal your text exactly, I just check if the trigger is part of it.

That's the issue i've been having, never knew how to search in the phrase. Thanks for explaining it!

Zyt3x
07-01-2009, 09:22 PM
One extra note:
When using "case ... of" then it is possible to do
case I of
0, 1, 2 : WriteLn('I is either 0, 1 or 2');
3..5: WriteLn('I is inbetween 3 and 5.');
6: WriteLn('I is 6');
7..10: WriteLn('I is higher than 6 but lower than 11.');
end;
Instead of
case I of
0: WriteLn('I is either 0, 1 or 2');
1: WriteLn('I is either 0, 1 or 2');
2: WriteLn('I is either 0, 1 or 2');
3: WriteLn('I is inbetween 3 and 5.');
4: WriteLn('I is inbetween 3 and 5.');
5: WriteLn('I is inbetween 3 and 5.');
6: WriteLn('I is 6');
7: WriteLn('I is higher than 6 but lower than 11.');
8: WriteLn('I is higher than 6 but lower than 11.');
9: WriteLn('I is higher than 6 but lower than 11.');
10: WriteLn('I is higher than 6 but lower than 11.');
end;

:)

final_result
07-02-2009, 06:04 AM
Ok so I believe to use a autoresponder correctly I should just insert this into the script somewhere as a procedure and then put it into the Main Loop somewhere?

Blumblebee
07-02-2009, 08:11 AM
yes you can. Frankly i think an autoresponder is somewhat dangerous, remember to not add it to everything you do right. And if you do use it, customize the responses as much as possible.

TRiLeZ
07-02-2009, 08:20 AM
One extra note:
When using "case ... of" then it is possible to do
case I of
0, 1, 2 : WriteLn('I is either 0, 1 or 2');
3..5: WriteLn('I is inbetween 3 and 5.');
6: WriteLn('I is 6');
7..10: WriteLn('I is higher than 6 but lower than 11.');
end;
Instead of
case I of
0: WriteLn('I is either 0, 1 or 2');
1: WriteLn('I is either 0, 1 or 2');
2: WriteLn('I is either 0, 1 or 2');
3: WriteLn('I is inbetween 3 and 5.');
4: WriteLn('I is inbetween 3 and 5.');
5: WriteLn('I is inbetween 3 and 5.');
6: WriteLn('I is 6');
7: WriteLn('I is higher than 6 but lower than 11.');
8: WriteLn('I is higher than 6 but lower than 11.');
9: WriteLn('I is higher than 6 but lower than 11.');
10: WriteLn('I is higher than 6 but lower than 11.');
end;

:)

I forgot that I could do that in cases, thanks.
final_result, make sure the auto responder dosnt respond to yourself
if LastChatter(Players[CurrentPlayer].Name) then Exit;
And wait like 500 ms after response or else it will respond twice.

Camaro'
07-02-2009, 12:55 PM
here is a good one i just made.


Procedure responda;
var
LastLineText,s,t,u: string;
tsa,k :tstringarray;
i,m:integer;
bool:boolean;
begin
if not loggedin then exit;
if LastChatter(Players[CurrentPlayer].Name) then Exit;
LastLineText := Lowercase(GetChatBoxText(8, clBlue)); //Step 1
TSA := ['hey','hi','yo','hello','ut','uthere','you there', 'u there'];
for i := 0 to high(tsa) do
begin
if (Pos(TSA[i], LastLineText) > 0) then
bool:= true;
wait(3);
end;
if bool then
begin
writeln('Found some text');
case random(3) of
0:
begin
s := 'h';
case random(7) of
0: t:='i';
1: t:='ey';
2: t:='iya';
3: t:='owdy';
4: t:='ay';
5: t:='ay dair';
6: t:='ello';
end;
k := [s,t];
u := implode(u,k);
typesend(u);
end;
1:
begin
s := 'y';
case random(7) of
0: t:='o';
1: t:='yoooo';
2: t:='ooo';
3: t:='ya?';
4: t:='a?';
5: t:='es?';
6: t:='yes?';
end;
k := [s,t];
u := implode(u,k);
typesend(u);
end;
2:
begin
s := 'u';
case random(7) of
0: t:='ughh';
1: t:='ghh';
2: t:='gh..';
3: t:='uhhhhh';
4: t:='hhhhh';
5: t:='h';
6: t:='ughhh.....';

end;
k := [s,t];
u := implode(u,k);
typesend(u);
end;
end;
end;
end;


that just responds to anything like hey.

final_result
07-05-2009, 11:17 PM
Ok I'll try using these. Thanks for guiding me. It's just that when you are chopping trees in the same place for 2 hours and you don't say a word when they ask you your wc level or say hi., I can almost see the cogs turning in the noobs heads, "is he a bot?"

It's ok if I say somewhat irrelevant things to their questions, that just makes me look stupid and thats ok :D

EDIT: How often should I have it check for autoresponding text?

Rich
07-06-2009, 12:38 AM
As often as you like.