# HG changeset patch # User Franck Deroche # Date 1179589637 -7200 # Node ID c7972ff66484e368cb583a9abfb4cc3076849d5d # Parent 31b594967cf23d27d6abaf707189867b818a8998 Connexion du bot et longueur de chaine. - le bot ne se connectait pas au lancement... - les commandes ne sont plus prefixes par un @, il y a donc un caractere de moins a supprimer quand on s'interesse aux sous-chaines. diff -r 31b594967cf2 -r c7972ff66484 org/defr/bots/Rusard.java --- a/org/defr/bots/Rusard.java Sun May 13 21:57:46 2007 +0200 +++ b/org/defr/bots/Rusard.java Sat May 19 17:47:17 2007 +0200 @@ -2,9 +2,13 @@ import java.util.Random; import java.util.Calendar; +import java.io.IOException; import java.text.DateFormat; import java.util.Locale; +import org.jibble.pircbot.IrcException; +import org.jibble.pircbot.NickAlreadyInUseException; + public class Rusard extends Bot { Random random; @@ -14,10 +18,19 @@ random = new Random(); } - public static void main(String arg[]) throws Exception { + public static void main(String arg[]) { Locale.setDefault(Locale.FRANCE); Rusard b = new Rusard(); - b.setVerbose(false); + try { + b.connect(); + } catch (NickAlreadyInUseException e) { + System.out.println("Ce pseudo est utilisé sur le chat."); + } catch (IOException e) { + e.printStackTrace(); + } catch (IrcException e) { + e.printStackTrace(); + } + b.setVerbose(true); b.joinChannel("#quidditch"); } @@ -51,12 +64,12 @@ sendMessage(replyTo, "De : " + v); } else if(message.matches("d\\d+")) { - int t = Integer.parseInt(message.substring(2)); + int t = Integer.parseInt(message.substring(1)); int v = random.nextInt(t) + 1; sendMessage(replyTo, "d" + t + " : " + v); } else if(message.matches("dd\\d")) { - int t = Integer.parseInt(message.substring(3)); + int t = Integer.parseInt(message.substring(2)); int limite = 0, score = random.nextInt(100) + 1; switch(t) { case 0: