# HG changeset patch # User Franck Deroche # Date 1179085764 -7200 # Node ID f9f6348eb8e9f575419ac0f2123e68676cee3487 # Parent 568c206089c164cb5a9323541b55a5a8eff7c35f Ajout d'une nouvelle classe de base. diff -r 568c206089c1 -r f9f6348eb8e9 org/defr/bots/Bot.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/org/defr/bots/Bot.java Sun May 13 21:49:24 2007 +0200 @@ -0,0 +1,47 @@ +package org.defr.bots; + +import java.io.IOException; +import java.io.UnsupportedEncodingException; + +import org.jibble.pircbot.IrcException; +import org.jibble.pircbot.NickAlreadyInUseException; +import org.jibble.pircbot.PircBot; + +/** + * Cette classe étend PircBot, en y intégrant le support des fichiers de + * configuration XML via la classe configuration. + * @author defr + */ +public class Bot extends PircBot { + protected Configuration conf; + + public Bot() { + super(); + } + + /** + * Lecture des paramètres à partir du fichier conf/botName.xml + * @param botName + */ + public Bot(String botName) { + conf = new Configuration("conf/" + botName + ".xml"); + setName(conf.getBotName()); + setLogin(conf.getBotName()); + try { + setEncoding(conf.getEncoding()); + } catch (UnsupportedEncodingException e) { + System.out.println("Cet encodage n'est pas supporté," + + " des caractères peuvent ressortir étrangement"); + } + } + + /** + * Connexion au serveur IRC défini dans le fichier de configuration + * @throws NickAlreadyInUseException + * @throws IOException + * @throws IrcException + */ + public void connect() throws NickAlreadyInUseException, IOException, IrcException { + connect(conf.getServerName()); + } +}