aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>2013-04-16 07:57:59 -0400
committerEric S. Raymond <esr@thyrsus.com>2013-04-16 07:57:59 -0400
commit81c44c0172dbb56b6e36915a6f87cdcec132addb (patch)
treee4cedc2d34bd9543683fc61503359f5af66dca12
parentAdded -p option. (diff)
downloadirker-81c44c0172dbb56b6e36915a6f87cdcec132addb.tar.xz
Prevent actually sending an empty privmsg.
-rwxr-xr-xirkerd30
-rw-r--r--irkerd.xml7
2 files changed, 21 insertions, 16 deletions
diff --git a/irkerd b/irkerd
index 3889cc7..cacd4bf 100755
--- 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()
diff --git a/irkerd.xml b/irkerd.xml
index 345c053..6102245 100644
--- a/irkerd.xml
+++ b/irkerd.xml
@@ -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>