Prevent actually sending an empty privmsg.
authorEric S. Raymond <esr@thyrsus.com>
Tue, 16 Apr 2013 11:57:59 +0000 (07:57 -0400)
committerEric S. Raymond <esr@thyrsus.com>
Tue, 16 Apr 2013 11:57:59 +0000 (07:57 -0400)
irkerd
irkerd.xml

diff --git a/irkerd b/irkerd
index 3889cc7293bf802810eff17834a2f8f95b612f60..cacd4bfdcc9d8d616e248c0db03863eb3f940406 100755 (executable)
--- a/irkerd
+++ b/irkerd
@@ -252,19 +252,23 @@ class Connection:
                     if channel not in self.channels_joined:
                         self.connection.join(channel)
                         self.irker.debug(1, "joining %s on %s." % (channel, self.servername))
-                    for segment in message.split("\n"):
-                        # Truncate the message if it's too long,
-                        # but we're working with characters here,
-                        # not bytes, so we could be off.
-                        # 500 = 512 - CRLF - 'PRIVMSG ' - ' :'
-                        maxlength = 500 - len(channel)
-                        if len(segment) > maxlength:
-                            segment = segment[:maxlength]
-                        try:
-                            self.connection.privmsg(channel, segment)
-                        except ValueError as err:
-                            self.irker.debug(1, "irclib rejected a message to %s on %s because: %s" % (channel, self.servername, str(err)))
-                        time.sleep(ANTI_FLOOD_DELAY)
+                    # An empty message might be used as a keepalive or
+                    # to join a channel for logging, so suppress the
+                    # privmsg send unless there is actual traffic.
+                    if message:
+                        for segment in message.split("\n"):
+                            # Truncate the message if it's too long,
+                            # but we're working with characters here,
+                            # not bytes, so we could be off.
+                            # 500 = 512 - CRLF - 'PRIVMSG ' - ' :'
+                            maxlength = 500 - len(channel)
+                            if len(segment) > maxlength:
+                                segment = segment[:maxlength]
+                            try:
+                                self.connection.privmsg(channel, segment)
+                            except ValueError as err:
+                                self.irker.debug(1, "irclib rejected a message to %s on %s because: %s" % (channel, self.servername, str(err)))
+                            time.sleep(ANTI_FLOOD_DELAY)
                     self.last_xmit = self.channels_joined[channel] = time.time()
                     self.irker.debug(1, "XMIT_TTL bump (%s transmission) at %s" % (self.servername, time.asctime()))
                     self.queue.task_done()
index 345c05363a4b457d3e56a0f17642daa1abd7e6d2..61022454156d21a29c3f59885938c8a66cac0cce 100644 (file)
@@ -57,10 +57,11 @@ colon, as shown in the third example; otherwise
 <application>irkerd</application> sends messages to the the default 6667 IRC
 port of each server.</para>
 
-<para>An empty message is legal and will cause 
+<para>An empty message is legal and will cause
 <application>irkerd</application> to join the target channels without
 actually emitting a message.  This may be useful for advertising that
-an instance is up and running.</para>
+an instance is up and running, or for joining a channel to log its
+traffic.</para>
 </refsect1>
 
 <refsect1 id='options'><title>OPTIONS</title>
@@ -78,7 +79,7 @@ consult the source code for details.</para></listitem>
 <term>-l</term>
 <listitem><para>Takes a following filename, logs traffic to that file.
 Each log line consists of three |-separated fields; a numeric
-timestamp in Unix time, the fqdn of the sending server, and the
+timestamp in Unix time, the FQDN of the sending server, and the
 message data.</para></listitem>
 </varlistentry>
 <varlistentry>