diff options
Diffstat (limited to 'contrib/mblow')
-rwxr-xr-x | contrib/mblow | 36 |
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 / |