# HG changeset patch
# User defr@localhost.localdomain
# Date 1175353918 -7200
# Node ID 4348c80b039a00ed2c2fa1cb282e7e539bf3f9f9
Import initial
diff -r 000000000000 -r 4348c80b039a .classpath
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/.classpath Sat Mar 31 17:11:58 2007 +0200
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
diff -r 000000000000 -r 4348c80b039a .hgignore
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/.hgignore Sat Mar 31 17:11:58 2007 +0200
@@ -0,0 +1,2 @@
+.class$
+MissTeigne.xml
diff -r 000000000000 -r 4348c80b039a .project
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/.project Sat Mar 31 17:11:58 2007 +0200
@@ -0,0 +1,17 @@
+
+
+ MissTeigne
+
+
+
+
+
+ org.eclipse.jdt.core.javabuilder
+
+
+
+
+
+ org.eclipse.jdt.core.javanature
+
+
diff -r 000000000000 -r 4348c80b039a org/defr/bots/Configuration.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/org/defr/bots/Configuration.java Sat Mar 31 17:11:58 2007 +0200
@@ -0,0 +1,55 @@
+package org.defr.bots;
+
+import java.io.File;
+import java.io.IOException;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.w3c.dom.Document;
+import org.xml.sax.SAXException;
+
+public class Configuration {
+ protected String botName = "Foo";
+ protected String botPassword = null;
+ protected String serverName;
+ protected String services;
+
+ public Configuration(File configFile) {
+ try {
+ DocumentBuilder db = DocumentBuilderFactory.newInstance().newDocumentBuilder();
+ Document document = db.parse(configFile);
+ botName = document.getElementsByTagName("name").item(0).getTextContent();
+ botPassword = document.getElementsByTagName("password").item(0).getTextContent();
+ serverName = document.getElementsByTagName("server").item(0).getTextContent();
+ services = document.getElementsByTagName("services").item(0).getTextContent();
+ } catch (ParserConfigurationException e) {
+ System.err.println("Erreur de configuration du DocumentBuilderFactory");
+ } catch (SAXException e) {
+ System.err.println("Fichier de configuration mal-formé");
+ } catch (IOException e) {
+ System.err.println("Fichier de configuration absent - " + configFile.getAbsolutePath());
+
+ }
+ }
+
+ public Configuration(String uri) {
+ this(new File(uri));
+ }
+
+ public String getBotName() {
+ return botName;
+ }
+ public String getBotPassword() {
+ return botPassword;
+ }
+ public String getServerName() {
+ return serverName;
+ }
+ public String getServices() {
+ return services;
+ }
+
+
+}
diff -r 000000000000 -r 4348c80b039a org/defr/bots/MissTeigne/MissTeigne.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/org/defr/bots/MissTeigne/MissTeigne.java Sat Mar 31 17:11:58 2007 +0200
@@ -0,0 +1,47 @@
+package org.defr.bots.MissTeigne;
+
+import java.io.File;
+import java.io.IOException;
+
+import org.defr.bots.Configuration;
+import org.jibble.pircbot.IrcException;
+import org.jibble.pircbot.NickAlreadyInUseException;
+
+public class MissTeigne extends org.jibble.pircbot.PircBot {
+
+ Configuration conf;
+
+ public MissTeigne() {
+ super();
+ conf = new Configuration(new File("MissTeigne.xml"));
+ setName(conf.getBotName());
+ }
+
+ public void onNotice(String sourceNick,
+ String sourceLogin,
+ String sourceHostname,
+ String target,
+ String notice) {
+ if(target.equalsIgnoreCase(getNick()) && sourceHostname.equals(conf.getServices())) {
+ // We're re-actign on a notice sent by a service :-)
+ if(sourceLogin.equals("NickServ") && notice.indexOf("IDENTIFY") > -1) {
+ this.sendMessage(sourceLogin, "IDENTIFY " + conf.getBotPassword());
+ }
+ }
+ }
+
+ public static void main(String[] arg) {
+ MissTeigne mt = new MissTeigne();
+ mt.setVerbose(true);
+ try {
+ mt.connect("home.defr.org");
+ } catch (NickAlreadyInUseException e) {
+ e.printStackTrace();
+ } catch (IOException e) {
+ e.printStackTrace();
+ } catch (IrcException e) {
+ e.printStackTrace();
+ }
+ mt.joinChannel("#test");
+ }
+}