about summary refs log tree commit diff
path: root/contrib/mblow
diff options
context:
space:
mode:
authorChristian Neukirchen <chneukirchen@gmail.com>2016-09-25 21:04:58 +0200
committerChristian Neukirchen <chneukirchen@gmail.com>2016-09-25 21:04:58 +0200
commitc02a2878b2eaadaf779e02dec375c2f0db3adff7 (patch)
tree8271034d09a76554102f2038daed4b7798dadb5e /contrib/mblow
parentb9a26fa3b3845eda599cf35da2ec9d9cc95dd9a3 (diff)
downloadmblaze-c02a2878b2eaadaf779e02dec375c2f0db3adff7.tar.gz
mblaze-c02a2878b2eaadaf779e02dec375c2f0db3adff7.tar.xz
mblaze-c02a2878b2eaadaf779e02dec375c2f0db3adff7.zip
contrib: add msuck and mblow for NNTP support
Diffstat (limited to 'contrib/mblow')
-rwxr-xr-xcontrib/mblow36
1 files changed, 36 insertions, 0 deletions
diff --git a/contrib/mblow b/contrib/mblow
new file mode 100755
index 0000000..d151504
--- /dev/null
+++ b/contrib/mblow
@@ -0,0 +1,36 @@
+#!/usr/bin/ruby
+# mblow - post an article via NNTP
+
+require 'socket'
+require 'optparse'
+
+params = ARGV.getopts("s:")
+
+port = 119
+if params["s"] =~ /(.*):(.*)/
+  params["s"] = $1
+  port = Integer($2)
+end
+
+SERVER = params["s"] || ENV["NNTPSERVER"] || "news"
+
+nntp = TCPSocket.new SERVER, port
+
+msg = nntp.gets
+abort msg  unless msg =~ /^200 /
+
+nntp.write "POST\r\n"
+msg = nntp.gets
+
+abort msg  unless msg =~ /^340 /
+
+while line = gets
+  line.chomp!
+  line.sub!(/\A\./, '..')
+  nntp.write(line + "\r\n")
+end
+
+nntp.write(".\r\n")
+msg = nntp.gets
+
+abort msg  unless msg =~ /^240 /