Responses - GodDragoner/TeaseAIJava GitHub Wiki
What are responses?
Responses are registered in the system that trigger if the sub sends a specific message that matches the response pattern. If a response is triggered it will automatically run the corresponding lines of code.
How do I register a response?
There are two ways to register a response. The first one is to place a file into the "Responses" folder of your personality. The file must be a .js file and looks like this (FuckMe.js):
addResponseIndicator("fuck me", "lick me", "ShiT me");
function fuckMeResponse(message) {
sendMessage("Oh really?");
sendMessage("Nice try!");
return true;
}
What does this do? Well when the file is loaded it will execute everything in the file that is not inside a function body. This means the addResponseIndicator function is called. In this case this will add the pieces "fuck me", "lick me" and "ShiT me" to the list of strings that will trigger this response. Notice that the case of the letters is ignored. This means if the sub writes "fuck me please" or "fuck and lick me" into the chat, this response will be triggered. If the sub writes "lick fuck and me" it won't. You can add as many lines as you want to the response file. Another function that you can call is the "addResponseRegex" function. This allows you to add regex patterns to the response trigger pool. If you don't know what regex is, look it up here. An easy to use website to create such expression is https://regex101.com/. How would this look? For example like this:
addResponseRegex("hey([ ]|$)", "hello([ ]|$)", "hi([ ]|$)");
This will trigger the response if the sub starts his string with "hey", "hello", or "hi" however the string has to end behind these three words or a space has to follow. Which means "Hey" triggers the response, "Hey Mistress" does too but "shit" does not, even though it contains "hi". This can come in handy if you want to react to more complicated sentences or in this example if you want to ignore certain conditions where "hi" might be in the string but not used as a single word. There is no way you could check for this with a normal indicator, because you can only check for "hi" or "hi " but not for "hi + end of the sentence".
Regarding the function "fuckMeResponse(message)": This function is called with the corresponding message whenever your response is triggered. The method needs to be named as follows: fileName without the file extension + "Response". However the first letter must always be lower case! Which means FuckMe.js turns into fuckMe + "Response" = fuckMeResponse. This function also needs to return a boolean. Either true, if we successfully triggered the response, which means the message that the domme was going to send before will be cancelled or false if you want to continue normally.
The second method to register a response is a manual one and I will go into depth about this in a future detailed coding FAQ.