SRL Archive - SRL Member Goodies

Autoresponder


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):
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!

Heavenguard

2010-08-11 11:10:38

Wow. This. Is. Amazing. Seriously, good job. Please do go on with this xD, because it is kinda invaluable if its a success. We definetly would use it. Once again, Great job.

marpis

2010-08-11 18:25:31

"Hello" -> "what?"
"Hi" -> "{ANSWER_[R]Thx~Thanx~Thank you~thanks~thank you very much[/R]}"

But awesome idea mate! :)

ShowerThoughts

2010-08-11 19:35:51

Yeah, finally released pretty cool!
However I am not going to use it though, but it will be doing something good for the community!

Frement

2010-08-12 07:24:33

From: marpis
"Hello" -> "what?"
"Hi" -> "{ANSWER_[R]Thx~Thanx~Thank you~thanks~thank you very much[/R]}"

But awesome idea mate! :)


That is the result of lack of answers in the final database, there are 10000+ messages waiting to be sorted in the first database :) Once the final database has enough messages and answers it will be good, currently there are like 25-35 answers, not even all the level questions etc. And the alias system is still under construction.

Home

2011-07-17 14:43:09

Hey mate. Is this still developed.

~Home

Frement

2011-07-17 14:48:40

Not recently. I might continue if people are interested in helping sort the messages.

euphemism

2012-01-18 21:57:20

From: Frement
Not recently. I might continue if people are interested in helping sort the messages.


I'll help on and off if you are still interested in moving this forward.

putonajonny

2012-01-20 21:56:47

grave dig much? :P I'm willing to help if this goes ahead

Frement

2012-04-09 21:49:46

If I continue this at some point in near future, I'll inform of updates in this thread: http://villavu.com/forum/showthread.php?t=65440

m34tcode

2012-04-12 21:37:23

If you do continue it, ill be more than happy to help you out.