• retrieve usenet article by message ID in terminal

    From Marco Moock@mm+usenet-es@dorfdsl.de to news.misc on Sun Feb 4 15:23:29 2024
    From Newsgroup: news.misc

    Hello!

    Some weeks ago somebody posted a way to retrieve a complete message in
    the terminal by the msg id.

    Does somebody know where that has been posted?
    --
    kind regards
    Marco

    Spam und Werbung bitte an ichwillgesperrtwerden@nirvana.admins.ws

    --- Synchronet 3.21d-Linux NewsLink 1.2
  • From yeti@yeti@tilde.institute to news.misc on Sun Feb 4 18:47:11 2024
    From Newsgroup: news.misc

    Marco Moock <mm+usenet-es@dorfdsl.de> writes:

    Hello!

    Some weeks ago somebody posted a way to retrieve a complete message in
    the terminal by the msg id.

    Does somebody know where that has been posted?

    No. I don't know.

    ...but this is one way that kind of does the trick:

    ------------------------------------------------------------------------
    $ printf '%s\r\n' 'article <upo6l1$3k6a0$1@dont-email.me>' quit . | nc news.uni-stuttgart.de nntp
    ------------------------------------------------------------------------
    --
    I do not bite, I just want to play.
    --- Synchronet 3.21d-Linux NewsLink 1.2
  • From Olive S@oliversimmo@gmail.com to news.misc on Mon Feb 5 16:54:33 2024
    From Newsgroup: news.misc

    yeti <yeti@tilde.institute> writes:

    Marco Moock <mm+usenet-es@dorfdsl.de> writes:

    Some weeks ago somebody posted a way to retrieve a complete message in the terminal by the msg id.

    ...but this is one way that kind of does the trick:

    $ printf '%s\r\n' 'article <upo6l1$3k6a0$1@dont-email.me>' quit . | nc news.uni-stuttgart.de nntp

    Note that this includes dot-stuffing, meaning lines beginning with a '.' are prefixed with one extra '.'.
    My nc requires a port number, can't take a service name. It's 119 if others' nc are the same.

    For example with your article:
    ....but this is one way that kind of does the trick:

    Easily undone with a little script like:
    for line in io.stdin:lines() do
    if line == "." then break end
    if line:sub(1,1) == "." then
    io.write(line:sub(2,-1).."\n")
    else
    io.write(line.."\n")
    end
    end

    Wrote a little Lua script below, tested with LuaJIT.
    If the stream errors out then it just throws a Lua assertion error.
    I may make this into a more full-blast "newsget" for the fun of it.

    One thing you highlighted I hadn't thought of before is pre-sending QUIT, pipelining it, before reading.
    That feels like a very polite thing to do :)

    local function nerr(s) io.stderr:write(s.."\n") os.exit(1) end
    local function recvresp(stream)
    return assert(stream:receive("*l")):match("^([0-9]+)[ \t]*(.-)[ \t]*$") end

    local msgid, host, port = ...
    port = not port and 119 or tonumber(port)
    if not (msgid and host and port) then
    nerr("Usage: message-id host [port]")
    end

    local socket = require("socket") -- Lua Socket Library
    local stream = assert(socket.connect(host, port))

    local resp, line = recvresp(stream)
    if resp ~= "200" and resp ~= "201" then
    nerr("Fail: Server gave unhandled welcome: "..resp.." "..line)
    end

    assert(stream:send("ARTICLE "..msgid.."\r\n"))
    stream:send("QUIT\r\n") stream:shutdown("send") -- don't care if this fails

    local resp, line = recvresp(stream)
    if resp == "220" then -- all good
    elseif resp == "430" then
    nerr("Fail: Message not found.")
    else
    -- Servers give a human-redable error description
    -- which may be more specific than a client can come up with,
    -- so it's best to just print it unless we can deal with it.
    nerr("Fail: Server gave unhandled response: "..resp.." "..line)
    end
    -- 480: Authentication needed
    -- Feel free to implement this yourself from RFC 4643
    -- Easier is to pick a host that allows reading without auth.
    -- 500: Server does not support ARTICLE
    -- 501: Likely malformed message-id

    for line in function() return assert(stream:receive("*l")) end do
    if line == "." then break end
    if line:sub(1,1) == "." then line = line:sub(2,-1) end
    io.write(line.."\n")
    end

    stream:close()
    --- Synchronet 3.21d-Linux NewsLink 1.2
  • From Marco Moock@mm+usenet-es@dorfdsl.de to news.misc on Tue Feb 6 10:02:53 2024
    From Newsgroup: news.misc

    On 04.02.2024 um 18:47 Uhr yeti wrote:

    $ printf '%s\r\n' 'article <upo6l1$3k6a0$1@dont-email.me>' quit . |
    nc news.uni-stuttgart.de nntp

    That has the disadvantage that it includes the NNTP responses which
    causes problem when parsed to other applications that expect only the
    message.
    --
    kind regards
    Marco

    Send spam to muell456@cartoonies.org

    --- Synchronet 3.21d-Linux NewsLink 1.2
  • From Marco Moock@mm+usenet-es@dorfdsl.de to news.misc on Tue Feb 6 10:34:15 2024
    From Newsgroup: news.misc

    On 04.02.2024 um 15:23 Uhr Marco Moock wrote:

    Some weeks ago somebody posted a way to retrieve a complete message in
    the terminal by the msg id.

    Does somebody know where that has been posted?

    lynx -source "nntp://news.i2pn2.org/<msgid>"
    is nearly that what I need.
    It places an <XMP>/</XMP> line at the beginning and at the end, but
    sed can remove that.
    --
    kind regards
    Marco

    Send spam to muell456@cartoonies.org

    --- Synchronet 3.21d-Linux NewsLink 1.2
  • From gof-cut-this-news@gof-cut-this-news@cut-this-chmurka.net.invalid (Adam W.) to news.misc on Fri Feb 23 15:47:34 2024
    From Newsgroup: news.misc

    Marco Moock <mm+usenet-es@dorfdsl.de> wrote:

    lynx -source "nntp://news.i2pn2.org/<msgid>"

    Use '', otherwise $ in msgids will be treated as variables. At least in
    bash.

    Like in your msgid:

    upsuen$qne4$1@dont-email.me

    It's decoded to upsuen@dont-email.me, because there's no variable $qne4
    and $1.
    --- Synchronet 3.21d-Linux NewsLink 1.2
  • From morena@morena@morena.rip to news.misc on Tue Oct 22 23:38:48 2024
    From Newsgroup: news.misc

    On 2/4/24 3:23 PM, Marco Moock wrote:

    Some weeks ago somebody posted a way to retrieve a complete message in
    the terminal by the msg id.

    Similar to yeti's line, in one line shell script, but like a pro
    interactively asking for message id, shows message in less viewer.

    ------------------------------------------------------------------------

    #!/bin/sh
    function nsearch { read ID?"Message ID: "; printf "%s\r\n" "article
    \$ID" quit . | nc news.blueworldhosting.com nntp | less; }; nsearch

    ------------------------------------------------------------------------
    --
    morena
    gopher://morena.rip/
    --- Synchronet 3.21d-Linux NewsLink 1.2
  • From morena@morena@morena.rip to news.misc on Tue Oct 22 23:57:28 2024
    From Newsgroup: news.misc

    A bit broken as somehow I expected newsreader client will respect my
    newline ;/

    You can see it at gopher://morena.rip/0ns or ideally get it as binary
    with gopher://morena.rip/9ns as text can be always mangled over network
    with newlines and things.
    --
    morena
    gopher://morena.rip/
    --- Synchronet 3.21d-Linux NewsLink 1.2