💾 Archived View for gemini.susa.net › telnet_znc_to_irc.gmi captured on 2022-04-28 at 17:37:27. Gemini links have been rewritten to link to archived content

View Raw

More Information

⬅️ Previous capture (2021-11-30)

-=-=-=-=-=-=-

Post to IRC using telnet via ZNC

I wanted a way to send an IRC message via a Gemini client. I use a ZNC bouncer on the same box, and it turns out really simple, with ideas from the Freenode users MetaNova and DarthGandalf on the #znc channel.

Essentially, IRC is just a text based protocol like SMTP, FTP, etc. All I need to do is authenticate to my ZNC bouncer and I can start pushing messages. This could also be done directly to an IRC server, though extra commands would likely be needed to authenticate with a nickserv and such things that I have already done while configuring the bouncer.

The first thing I did was configure ZNC to also open a non-ssl socket, but bound only to 127.0.0.1. This means I can locally telnet into ZNC. I could almost certainly have used OpenSSL s_client, or similar, if I'd wanted to use the existing SSL socket.

And the top and bottom of my endeavours is the following:

echo -e "pass mypasswd\nuser mynick/thenet\nnick mynick\nprivmsg #mychannel :hi from telnet" | \
    telnet 127.0.0.1 6799

That's it. I can use that command to send a message to a channel on IRC!

Further suggestions

If ZNC is running on a different host, perhaps SSL could be used with something like this?

socat -v tcp-listen:6799,reuseaddr,fork,bind=127.0.0.1 ssl:myznc.example.com:6799,verify=0

# A quick test with the kirc client shows socat works ok for this

./kirc -s 127.0.0.1 -p 6799 -n kevinsan -u kevinsan/tilde -k ******** -c kevintest

Useful links

List of Internet Relay Chat Commands

KISS IRC - a very simply IRC client in C