Frement
2010-08-11 11:02:25
Ok, so this is still under developement, but basicly the idea is simple.
Gather conversations from RS and transfer them to a database. Then through an interface sort them out and give them answers (or delete if stupid message).
After that the final database has some messages and answers.
Then a simba script will query a webpage which searches the most accurate answer from the final database, and outputs the answer.
Answer defines (or normal text):
Here is a picture of the interface which is used to sort the messages, you can also add custom messages and answers if you like.

Here is a test script to retrieve messages:
http://www.frement.net/srl/autoresponder/test.php
I have done the script for simba to sort the messages that are retrieved from the database, but it needs some more work, but I'll paste it too.
I am still making this so nothing is perfect or nearly as good as it will be when its done, but I was just hoping to hear your thoughts and ideas.
I am currently (when I find the inspiration again) doing an alias system for the words that it matches, like "att/attack/attk" "str/strength" etc.
So yeah, I first started with i luffs yeww, but I mainly had to do everything by myself because he didn't know PHP or anything.
So here it is, post your thoughts!
Gather conversations from RS and transfer them to a database. Then through an interface sort them out and give them answers (or delete if stupid message).
After that the final database has some messages and answers.
Then a simba script will query a webpage which searches the most accurate answer from the final database, and outputs the answer.
Answer defines (or normal text):
Level Answers
{LVL_ATTACK}
{LVL_STRENGTH}
{LVL_DEFENCE}
{LVL_RANGED}
{LVL_PRAYER}
{LVL_MAGIC}
{LVL_RUNECRAFTING}
{LVL_CONSTRUCTIONS}
{LVL_DUNGEONEERING}
{LVL_CONSTITUTION}
{LVL_AGILITY}
{LVL_HERBLORE}
{LVL_THIEVING}
{LVL_CRAFTING}
{LVL_FLETCHING}
{LVL_SLAYER}
{LVL_HUNTER}
{LVL_MINING}
{LVL_SMITHING}
{LVL_FISHING}
{LVL_COOKING}
{LVL_FIREMAKING}
{LVL_WOODCUTTING}
{LVL_FARMING}
{LVL_SUMMONING}
QuickChat Answers
{QC_S-R-2}
Advanced Answers
Seperator is "+". Outputs all levels.
{LVL_[SKILL1+SKILL2+SKILL3]}
Seperator is "-". Outputs a random level.
{LVL_[R]SKILL1-SKILL2-SKILL3[/R]}
Seperator is "~". Outputs a random text.
{ANSWER_[R]Hi~Hello there!~Well hi:)~Heya~Hey[/R]}Here is a picture of the interface which is used to sort the messages, you can also add custom messages and answers if you like.

Here is a test script to retrieve messages:
http://www.frement.net/srl/autoresponder/test.php
I have done the script for simba to sort the messages that are retrieved from the database, but it needs some more work, but I'll paste it too.
program New;
{$I SRL/SRL.scar}
var TheMsg: String;
{*******************************************************************************
function AR_GetResponse(Msg: String): String;
By: Frement
Description: Gets a response for given message.
*******************************************************************************}
function AR_GetResponse(Msg: String): String;
var Page: Integer;
begin
Page := InitializeHTTPClient(False, False);
ClearPostData(Page);
AddPostVariable(Page, 'message', Msg);
Result := PostHTTPPageEx(Page, 'http://www.frement.net/srl/autoresponder/response.php');
end;
{*******************************************************************************
function AR_ParseResponse(Text: String; var Mode: Integer): TStringArray;
By: Frement & mixster
Description: Parses the response to be used in respond function.
*******************************************************************************}
function AR_ParseResponse(Text: String; var Mode: Integer): TStringArray;
var RArray: TStringArray;
begin
Mode := 0;
if (Pos('ANSWER_[R', Text) > 0) then begin
RArray := Explode('~', Between('[R]', '[/R]', Between('{ANSWER_', '}', Text)));
Mode := 1;
end else if (Pos('LVL_[', Text) > 0) then begin
RArray := Explode('+', Between('[', ']', Between('{LVL_', '}', Text)));
Mode := 2;
end else if (Pos('LVL_[R', Text) > 0) then begin
RArray := Explode('-', Between('[R]', '[/R]', Between('{LVL_', '}', Text)));
Mode := 3;
end else if (Pos('QC_', Text) > 0) then begin
RArray := Explode('-', Between('{QC_', '}', Text));
Mode := 4;
end else if (Pos('LVL_', Text) > 0) then begin
RArray := Explode('', Between('{LVL_', '}', Text));
Mode := 5;
end else begin
SetArrayLength(RArray, 1);
RArray[0] := Text;
Mode := 6;
end;
Result := RArray;
end;
{*******************************************************************************
function KeyToChar(Key: String): Char;
By: Frement
Description: Converts a key to character.
*******************************************************************************}
function KeyToChar(Key: String): Char;
begin
Result := Key[1];
end;
{*******************************************************************************
procedure AR_TypeQC(Keys: TStringArray);
By: Frement
Description: Sends a QuickChat message.
*******************************************************************************}
procedure AR_TypeQC(Keys: TStringArray);
var I: Integer;
begin
for I := 0 to High(Keys) do begin
TypeByte(GetKeyCode(KeyToChar(LowerCase(Keys[I]))));
Wait(823+Random(59));
end;
end;
{*******************************************************************************
procedure AR_Respond(Text: String);
By: Frement
Description: Responds to a message from RS.
*******************************************************************************}
procedure AR_Respond(Text: String);
var Response: String;
ResponseArray: TStringArray;
ARMode, I: Integer;
begin
Response := AR_GetResponse(Text);
ResponseArray := AR_ParseResponse(Response, ARMode);
case ARMode of
1: begin
TypeSend(ResponseArray[Random(High(ResponseArray))]);
end;
2: begin
for I := 0 to High(ResponseArray) do begin
TypeSend(IntToStr(GetSkillLevel(ResponseArray[I])));
end;
end;
3: begin
TypeSend(IntToStr(GetSkillLevel(ResponseArray[Random(High(ResponseArray))])));
end;
4: begin
AR_TypeQC(ResponseArray);
end;
5: begin
TypeSend(IntToStr(GetSkillLevel(ResponseArray[0])));
end;
6: begin
for I := 0 to High(ResponseArray) do begin
TypeSend(ResponseArray[I]);
end;
end;
end;
end;
begin
SetupSRL;
repeat
TheMsg := GetChatBoxText(8, clChat);
AR_Respond(TheMsg);
Wait(7000);
until(False);
end.I am still making this so nothing is perfect or nearly as good as it will be when its done, but I was just hoping to hear your thoughts and ideas.
I am currently (when I find the inspiration again) doing an alias system for the words that it matches, like "att/attack/attk" "str/strength" etc.
So yeah, I first started with i luffs yeww, but I mainly had to do everything by myself because he didn't know PHP or anything.
So here it is, post your thoughts!