Trying out Java. I am not good at Java at all. Just want a bot that responds to commands like "!r1" to then output "Rule 1, No spam"
Need multiple lines but me being not so good I made this:
The first command works but anything after does not. It also can be used by anyone and should be op only.
Hope someone can give me a bit of advise :)
asked Jun 18 '12 at 10:08
Its just a generic programming mistake. You have the second if inside the first if, meaning that you only check if the message is equal to "lol" if the message is equal to "hi", this just doesn't seem right ;) The right code would be:
So you don't check the string again even after you already found your match.
You really think it's that easy to detect spamm? What your script can do for you without any problems is censoring curse words. But if you actually try to take away spam via this method then you will have a massive class with way to many if-else statements which will be extremely slow.
You can use regex to check for links and E-Mail address for spam at best but actually checking the message itself on everything in it is insane! You've added 'hi' to your list for 'Hello'. What if I were to say hey or 'what's up?' or even 'whats up' ? There are to many possibilities and after that you've got intended grammar mistakes like 'wahts up?' as if you've typed to fast.
As you said you have very little experience with Java yet you are trying to write a script that is a intermediate task even for the professional developers. My suggestion would be to talk to a developer you know and get some help on this.
answered Jun 18 '12 at 15:14