So, a few weeks ago I hacked together some logs for the #knownchat IRC channel.
I accomplished this by hacking together a very simple IRC logging bot. This bot will sit on an IRC channel and output logs in github friendly Markdown (so you can post them to a repo and give people an easy way to read them).
Since it was just as easy to write a flexible bot than a single use bot, I thought others might be interest in it.
The bot isn’t fancy, but it does the job.
It only supports logging of a single channel per instance, but it will interface with a nickserv server to identify itself, and will log each day’s activity in a separate file (in nicely sortable YYYY-MM-DD.md format) in a directory per channel.
Fire it up in a screen on an always on machine and you should start collecting logs straight away. To create the logs for #knownchat, I turned it’s channel dir into a git repo, and periodically push on a cronjob, but you might find other ways of doing things.
To keep things quiet, it’ll only log chat, not channel messages (leave/join etc).
Hopefully someone else’ll find this useful!
» Visit the project on Github...
The other week I wrote about a plugin I made that lets you syndicate content from a Known site to an IRC channel.
Since folk using other platforms expressed an interest, I thought I’d quickly write down how to do it for the other indieweb folk out there.
Writing content to an IRC channel is actually pretty straightforward, I’ll get onto the specifics of what you need to do in a moment, but your first step is to collect necessary information.
At the very least you’ll need:
- Server details: Server (e.g. irc.freenode.net), Port (e.g 6667, or better, 6697 for TLS)
- The channel you want to post to (e.g. #indiewebcamp)
- The nickname to use (and password if your nick is protected by nickserv)
Collect that information (or hard code it if it’s just for you), you’ll need it later.
Making a post
Posting some content to the channel after this is fairly straightforward. Obviously, if you want to persist on the channel you’ll need to start thinking about implementing a proper bot, but a single posting doesn’t need to get into that.
The basic protocol is:
- Connect to the server on the given port, and I strongly suggest you use TLS.
- Greet the server by sending the following:
USER *username* *username* bla :*username*\r\n
All the *username* bits in the first line are actually meant to be your username, fullname and nickname. For brevity, because I wasn’t writing a full client, I just used the same thing.
- Wait for response from server. At this point the server will spit back some information about the server, and may ask you some questions. You *should* parse that intelligently, but I couldn’t be bothered, so I just wait a few seconds.
- If you need to send a password to the nickserv, do so now:
PRIVMSG NickServ :IDENTIFY *username* *password*
Wait for response (or a few seconds) as before.
- Join your channel:
and wait for response.
- Post your message:
PRIVMSG *#channel* :*your message*
and close your connection.
If you want to experiment with this before you start coding, you can connect and do the whole exchange by hand via telnet/telnet-ssl, e.g:
marcus@dushka:~$ telnet-ssl irc.freenode.net 6697
USER example example bla :example
.... server response ....
PRIVMSG NickServ :IDENTIFY example somesecretpass
PRIVMSG #indiewebcamp :Hello folks!
All in all, posting to an IRC channel is pretty straightforward, however there are a few things that can trip you up.
- Don’t be too fast: The main issue is that if you just open the connection and splurt your commands, you likely won’t get anywhere. The server will respond, and will expect you to listen to what it says. As I said above, the best thing is to read and process this response intelligently, but you can of get away with just waiting a few seconds… obviously YMMV.
- Nickname collisions: The above code doesn’t handle a situation where the nickname is already active on the network. I sidestep this issue by using a different username than my regular IRC handle for my syndication user, and to use nickserv to guard it. If you don’t want to take that approach you’re going to need to do something else, like parse the server response to detect the problem and present alternate nicks.
On the Indiewebcamp wiki, there’s a page discussing HTTPS, the support for which is strongly recommended. As I’ve mentioned previously, at this stage all non-encrypted communication forms (including traditional port 80 HTTP) should be considered deprecated and dangerous.
Indieweb compatible sites are encouraged to get a higher level as possible, and thanks to some prodding, I’ve finally moved both this blog and my feed over to HTTPS only, with HSTS and forward secrecy.
This got me thinking, perhaps it would be worth adding a “Level 7” (or perhaps Level 6.5) to this, and to suggest that Indieweb sites should also be made available as
.onion hidden services on Tor?
- Anonymity. Would go a large way towards protecting communication metadata (who know’s whom), which is a goal we should move towards in a world of endemic selector based surveillance.
- Encryption. Traffic within the tor network is end to end encrypted, and there is some discussion of whether this renders HTTPS unnecessary.
- Tor has nothing to do with HTTPS, although it is encrypted. However, the HTTPS levels page seemed a good place to put the suggestion.
- Could be seen as endorsing one service. Tor is Free software and is pretty much the only game in town when it comes to anonymity networks, but does that constitute a silo? Probably not, but is a point for discussion.
- No certificates for .onion. There are currently no certificate providers available for .onion domains. But, this may not be a problem.
Anyway, just mooting this as a point for discussion.