From: Mark Wooding Date: Mon, 27 Mar 2006 14:11:24 +0000 (+0100) Subject: inject: Insert correct Lines header. X-Git-Url: https://git.distorted.org.uk/~mdw/newsgate/commitdiff_plain/79872e69b01029c7670255a216f5879df27b20ec inject: Insert correct Lines header. --- diff --git a/bin/inject b/bin/inject index 62a75fd..6dbfdb3 100755 --- a/bin/inject +++ b/bin/inject @@ -100,6 +100,7 @@ class NNTP (object): def send(): hdr = StringIO() + body = StringIO() hdr.write('Path: newsgate\r\n' 'Distribution: mail\r\n' 'Newsgroups: %s\r\n' @@ -135,7 +136,6 @@ def send(): % (T.strftime('%a, %d %b %Y %H:%M:%S %Z'))) if 'subject' not in seen: hdr.write('Subject: (no subject)\r\n') - hdr.write('\r\n') msgid = seen['message-id'] if not rx_msgid.match(msgid): @@ -145,7 +145,7 @@ def send(): nntp.cmd('IHAVE %s' % msgid) rc, msg = nntp.reply() if rc == '335': - nntp.write(hdr.getvalue()) + n = 0 for i in stdin: if i.startswith('.'): i = '.' + i @@ -155,7 +155,12 @@ def send(): i = i[:-1] + '\r\n' else: i = i + '\r\n' - nntp.write(i) + body.write(i) + n += 1 + hdr.write('Lines: %d\r\n' % n) + hdr.write('\r\n') + nntp.write(hdr.getvalue()) + nntp.write(body.getvalue()) nntp.write('.\r\n') nntp.flush() rc, msg = nntp.reply()