~hippos/jhippo/JHippo-0.1

« back to all changes in this revision

Viewing changes to src/jhippo/functions/Join.java

  • Committer: tak
  • Date: 2009-11-05 06:29:12 UTC
  • Revision ID: tak.31337@gmail.com-20091105062912-voqt6fy8b9qpd2of
Fastest release yet, fixed all those odd bugs, registration and login system work fine. I think we finally hit the first milestone.

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
 
24
24
package jhippo.functions;
25
25
 
26
 
import java.util.StringTokenizer;
27
26
import jhippo.Main;
28
27
 
29
28
/**
30
29
 *
31
30
 * @author tak <tak.31337@gmail.com>
32
31
 */
33
 
public class Join implements Function, Runnable {
 
32
public class Join extends Function {
34
33
    private String message;
35
34
    private String channel;
36
35
    private String sendMessage = "";
37
 
    private StringTokenizer parameters;
38
36
 
39
37
    @Override
40
38
    public void run() {
43
41
            message = bot.getMessage();
44
42
        }
45
43
        if ( message.startsWith("!join") ) {
46
 
            tokenize(message);
47
 
            channel = (String) parameters.nextElement(); 
 
44
            tokenize(true, 5, message);
 
45
            channel = (String) tokenParameters.nextElement();
48
46
            
49
47
            /*if !join #example password, join with a key, else just join*/
50
 
            if ( parameters.hasMoreElements() ) {
51
 
                Main.bot.joinChannel( channel,(String) parameters.nextElement());
 
48
            if ( tokenParameters.hasMoreElements() ) {
 
49
                Main.bot.joinChannel( channel,(String) tokenParameters.nextElement());
52
50
            }
53
51
            else {
54
52
                Main.bot.joinChannel(channel);
55
53
            }
56
54
        }
57
55
    }
58
 
    /*method that stores everything after !join  into a StringTokenizer
59
 
     * seperated by spaces " "
60
 
     */
61
 
    @Override
62
 
    public void tokenize(String message) {
63
 
        parameters = new StringTokenizer( message.substring(5) );
64
 
    }
65
56
}