Right, got bored and did this, then got more bored so I started logging stuff, then got even more bored and commented on it all.
Code:
public void save_strings(String text)
{
try
{
BufferedWriter out = new BufferedWriter(new FileWriter("magic ball.txt", true)); // setup file and append set to true
text.replaceAll("!magicball", ""); // Remove the '!magicball' from the string
out.write(text + "\n"); // write the string to the file, followed by a new line
out.close(); // close the file
} catch (IOException e) {}
}
/**
* function to return a string to answer a question?
*/
public String magic_reply()
{
String[] reply = { // There are 17
"As I see it, yes",
"It is certain",
"It is decidedly so",
"Most likely",
"Outlook good",
"Signs point to yes",
"Without a doubt",
"Yes",
"Yes - Definatly",
"You may rely on it",
"Better not tell you now",
"Concentrate and ask again",
"Don't count on it",
"My reply is no",
"My sources say no",
"The outlook is not so good",
"It is very doubtful"};
String text = "The answer to your question: ";
Random generator = new Random(); // Make an object-Random number
int r = generator.nextInt(17); // Set that object to be between 0 and 16
text += reply[r]; // Combine strings 'text' and the random string together
return text; // Return the newly combined string
}
/**
* Void function for handling a Channel message (handlesChanMessage() will
* be called first to determine if takeChanMessage(channel, user, message)
* should be called.)
* @param channel Channel that the message came from.
* @param user User that the message came from.
* @param message The message sent by the user.
*/
public void takeChanMessage(String channel, String user, String message)
{
boolean do_we_save_strings = true;
if(message.startsWith ("!magicball"))
{
Interactus.sendMessage(channel, magic_reply());
if (do_we_save_strings) // If set to true, it will write down strings
save_strings(message);
}
// Interactus.sendMessage(channel, getConfig("text1"));
}
@Si - Couldn't be bothered to figure out git
_________________
Skillers wrote:
Oh gawd no! Not the crazy frog! Arghhhhhh! $&^%&*^%*$^ %$(%^((% %$(O*%(#*%^ %)*#$&%)*@#% %_(#&%*%) frog