267 |
|
|
268 |
|
// put these details into the bot |
269 |
|
this.setLogin(user); |
270 |
< |
this.setVersion(comment); |
270 |
> |
this.setVersion("[" + getRevision() + "] " + comment); |
271 |
|
this.setFinger(finger); |
272 |
|
|
273 |
|
// attempt to connect, trying each nickname |
410 |
|
public void onNickChange(String oldNick, String login, String hostname, String newNick) { |
411 |
|
if(oldNick.equals(_nickname)) { |
412 |
|
_nickname = newNick; |
413 |
+ |
// tell the underlying pircbot that our nick has changed too :) |
414 |
+ |
setName(newNick); |
415 |
|
} |
416 |
|
} |
417 |
|
|
450 |
|
* This method handles input directed to us, and |
451 |
|
* responds accordingly if required. |
452 |
|
* |
451 |
– |
* nb. matching user input is quite bad right now, |
452 |
– |
* and should be improved one day. |
453 |
– |
* |
453 |
|
* @param message the message from someone |
454 |
|
* @param source where the message came from, so we know where to send the response |
455 |
|
*/ |
478 |
|
return; |
479 |
|
} |
480 |
|
|
482 |
– |
// see if the message matches (loosely!) any |
483 |
– |
// of our known commands |
481 |
|
if(message.equalsIgnoreCase(stopCommand)) { |
482 |
|
_active = false; |
483 |
|
sendMessage(source, "alerts have been stopped"); |
508 |
|
} |
509 |
|
|
510 |
|
} |
511 |
< |
else if(message.equalsIgnoreCase(joinCommand)) { |
511 |
> |
else if(message.toLowerCase().startsWith(joinCommand.toLowerCase())) { |
512 |
|
String joinCmd = joinCommand; |
513 |
|
String newChan = message.substring(message.indexOf(joinCmd) + joinCmd.length() + 1); |
514 |
|
int endOfChan = newChan.indexOf(" "); |
524 |
|
_channel = newChan; |
525 |
|
} |
526 |
|
} |
527 |
< |
else if(message.equalsIgnoreCase(nickChangeCommand)) { |
527 |
> |
else if(message.toLowerCase().startsWith(nickChangeCommand.toLowerCase())) { |
528 |
|
String nickChangeCmd = nickChangeCommand; |
529 |
|
String newNick = message.substring(message.indexOf(nickChangeCmd) + nickChangeCmd.length() + 1); |
530 |
|
int endOfNick = newNick.indexOf(" "); |
535 |
|
changeNick(newNick); |
536 |
|
} |
537 |
|
else if(message.equalsIgnoreCase(versionCommand)) { |
538 |
< |
sendMessage(source, "I am version "+REVISION.substring(11, REVISION.length()-2)+" of the i-scream alerting bot"); |
538 |
> |
sendMessage(source, "I am version " + getRevision() + " of the i-scream alerting bot"); |
539 |
|
} |
540 |
|
else if(message.equalsIgnoreCase(helpCommand)) { |
541 |
|
sendMessage(source, "Hello, I am the i-scream alerting bot version "+REVISION.substring(11, REVISION.length() -2)); |
624 |
|
try { |
625 |
|
Thread.sleep(delayTime * 1000); |
626 |
|
} catch (InterruptedException e) {} |
627 |
+ |
} |
628 |
+ |
|
629 |
+ |
/** |
630 |
+ |
* Returns the revision of the bot. |
631 |
+ |
* |
632 |
+ |
* @return the revision of this bot |
633 |
+ |
*/ |
634 |
+ |
private String getRevision() { |
635 |
+ |
return REVISION.substring(11, REVISION.length()-2); |
636 |
|
} |
637 |
|
|
638 |
|
/** |