camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject camel git commit: CAMEL-9755: Allow for nickserv identification. Thanks to Kevin Telford for the patch.
Date Fri, 25 Mar 2016 07:18:19 GMT
Repository: camel
Updated Branches:
  refs/heads/master 200ddf914 -> f929278b0


CAMEL-9755: Allow for nickserv identification. Thanks to Kevin Telford for the patch.


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/f929278b
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/f929278b
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/f929278b

Branch: refs/heads/master
Commit: f929278b0c5e02217e47bbe3b3f12f908f4f2913
Parents: 200ddf9
Author: Claus Ibsen <davsclaus@apache.org>
Authored: Fri Mar 25 08:17:55 2016 +0100
Committer: Claus Ibsen <davsclaus@apache.org>
Committed: Fri Mar 25 08:17:55 2016 +0100

----------------------------------------------------------------------
 .../camel/component/irc/IrcConfiguration.java      | 13 +++++++++++++
 .../apache/camel/component/irc/IrcConsumer.java    | 17 +++++++++++++++++
 2 files changed, 30 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/f929278b/components/camel-irc/src/main/java/org/apache/camel/component/irc/IrcConfiguration.java
----------------------------------------------------------------------
diff --git a/components/camel-irc/src/main/java/org/apache/camel/component/irc/IrcConfiguration.java
b/components/camel-irc/src/main/java/org/apache/camel/component/irc/IrcConfiguration.java
index 7a214d7..4536ba2 100644
--- a/components/camel-irc/src/main/java/org/apache/camel/component/irc/IrcConfiguration.java
+++ b/components/camel-irc/src/main/java/org/apache/camel/component/irc/IrcConfiguration.java
@@ -84,6 +84,8 @@ public class IrcConfiguration implements Cloneable {
     @UriParam(defaultValue = "true")
     private boolean autoRejoin = true;
     private SSLContextParameters sslContextParameters;
+    @UriParam
+    private String nickPassword;
 
     public IrcConfiguration() {
     }
@@ -440,6 +442,17 @@ public class IrcConfiguration implements Cloneable {
     public void setSslContextParameters(SSLContextParameters sslContextParameters) {
         this.sslContextParameters = sslContextParameters;
     }
+    
+    /**
+     * Your IRC server nickname password.
+     */
+    public String getNickPassword() {
+        return nickPassword;
+    }
+
+    public void setNickPassword(String nickPassword) {
+        this.nickPassword = nickPassword;
+    }
 
     public String toString() {
         return "IrcConfiguration[hostname: " + hostname + ", ports=" + Arrays.toString(ports)
+ ", username=" + username + "]";

http://git-wip-us.apache.org/repos/asf/camel/blob/f929278b/components/camel-irc/src/main/java/org/apache/camel/component/irc/IrcConsumer.java
----------------------------------------------------------------------
diff --git a/components/camel-irc/src/main/java/org/apache/camel/component/irc/IrcConsumer.java
b/components/camel-irc/src/main/java/org/apache/camel/component/irc/IrcConsumer.java
index b9c6efd..e132f1a 100644
--- a/components/camel-irc/src/main/java/org/apache/camel/component/irc/IrcConsumer.java
+++ b/components/camel-irc/src/main/java/org/apache/camel/component/irc/IrcConsumer.java
@@ -19,6 +19,7 @@ package org.apache.camel.component.irc;
 import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
 import org.apache.camel.impl.DefaultConsumer;
+import org.apache.camel.util.ObjectHelper;
 import org.schwering.irc.lib.IRCConnection;
 import org.schwering.irc.lib.IRCEventAdapter;
 import org.schwering.irc.lib.IRCModeParser;
@@ -58,6 +59,22 @@ public class IrcConsumer extends DefaultConsumer {
         super.doStart();
         listener = getListener();
         connection.addIRCEventListener(listener);
+
+        if (ObjectHelper.isNotEmpty(configuration.getNickPassword())) {
+            try {
+                // TODO : sleep before joinChannels() may be another useful config param
(even when not identifying)
+                // sleep for a few seconds as the server sometimes takes a moment to fully
connect, print banners, etc after connection established
+                LOG.debug("Sleeping for 5 seconds before identifying to NickServ.");
+                Thread.sleep(5000);
+            } catch (InterruptedException ex) {
+                // ignore
+            }
+            LOG.debug("Identifying and enforcing nick with NickServ.");
+            // Identify nick and enforce, https://meta.wikimedia.org/wiki/IRC/Instructions#Register_your_nickname.2C_identify.2C_and_enforce
+            connection.doPrivmsg("nickserv", "identify " + configuration.getNickPassword());
+            connection.doPrivmsg("nickserv", "set enforce on");
+        }
+        
         endpoint.joinChannels();
     }
 


Mime
View raw message