Image of the glider from the Game of Life by John Conway
Skip to content

Irssi ChanServ and NickServ Helper Aliases

I spend my irc time in the single greatest IRC client around- irssi. Coupled with screen, IRC is a whole new world. There are those who connect and disconnect constantly, coming in for a question or to chat, spending a little time in the channels of their choice, then leaving. While this doesn't bother me any, I would bet that if these users could get shell access via SSH and run irssi inside screen, they would discover a completely different way to IRC.

So, because I'm connected 24/7, I find that IRC can be demanding. There are several channels that I have operator access to, so every once in a while, operator access is needed. I've been aware of Seveas' chanserv.py helper script for XChat users, but being an irssi user, and not having python scripting support, it doesn't help me much. Today, I found that Seveas based his script on auto_bleh.pl, a irssi script that has much of the same functionality.

However, what disappointed me about auto_bleh.pl, is the fact that it creates a number of aliases to automate chanserv functionality, where Seveas' script uses one alias that takes a number of different arguments. While eventually I may get around to writing a perl script for irssi that is much more powerful and flexible, I decided to write a number of quick aliases for the time being, both for chanserv and nickserv.

NOTE: these aliases are far from what Sevas' chanserv.py helper script, or the auto_bleh.pl script provide. I'm aware of that. However, being a user that only needs these functions on rare occasion, I don't see the need to make them too powerful yet. I provide them here, in case another irssi user could find them helpful. Naturally, if you can extend these aliases, please provide me a link to the page, or put them in the comments below.

At any event, here they are in their full glory:

/alias CS /msg chanserv
/alias CSINFO /msg chanserv info $0
/alias CSIDENTIFY /msg chanserv identify $0 $1
/alias CSACCESS /msg chanserv access $0 list
/alias CSOP /msg chanserv op $C $0
/alias CSDEOP /msg chanserv op $C -$0
/alias CSKICK /msg chanserv op $C $N;/wait 50;/kick $0 $1-;/msg chanserv op $C -$N
/alias CSBAN /msg chanserv op $C $N;/wait 50;/ban $0;/msg chanserv op $C -$N
/alias CSMUTE /msg chanserv op $C $N;/wait 50;/mode +q $0;/msg chanserv op $C -$N
/alias CSKICKBAN /msg chanserv op $C $N;/wait 50;/kb $0 $1-;/msg chanserv op $C -$N
/alias CSUNBAN /msg chanserv op $C $N;/wait 50;/unban $0;/msg chanserv op $C -$N
/alias CSTOPIC /msg chanserv op $C $N;/wait 50;/topic $0-;/msg chanserv op $C -$N
/alias CSMODE /msg chanserv op $C $N;/wait 50;/mode $0;/msg chanserv op $C -$N
/alias CSINVITE /msg chanserv op $C $N;/wait 50;/invite $0;/msg chanserv op $C -$N

/alias NS /msg nickserv
/alias NSIDENTIFY /msg nickserv identify $0
/alias NSGHOST /msg nickserv ghost $0 $1
/alias NSRECOVER /msg nickserv recover $0 $1
/alias NSRELEASE /msg nickserv release $0 $1
/alias NSINFO /msg nickserv info $0
/alias NSLINK /msg nickserv link $0 $1

Let me give a bit of commentary on what's going on in those aliases. First, irssi gives perl-style argument functionality to /alias (probably other commands as well, but I'm not sure). As such, there are 10 arguments that you can pass to your alias in order from $0 to $9. To illustrate:

/ALIAS send echo Sending file $1 to $0;dcc send $0-

In the alias 'send' here that is created, $0 is the nick that you are sending file $1 to. Also, as you can see in that example, you can separate multiple irssi commands with the semicolon. Finally, the dash following $0 in that example, means taking all arguments following the first.

Now, let's look at my aliases. There are special variables that are extended throughout the irssi interface. You can find a list of these at the irssi documentation page. The variables that I am using are $C and $N. $C will return the current channel that you are executing the script in, and $N will return your nickname. Finally, I need to take advantage of the built-in /wait command in irssi, as the chanserv operator script doesn't get the chance to op you before the rest of the alias continues. It's less than optimal, as the alias should wait for a return on each command before continuing, but after all, this is an alias, and not a script. Also, as you'll probably notice, there is no error checking. Some aliases take arguments, some don't. Here's a break down of what arguments are required (options in square brackets are optimal. See services documentation for more info):

/CS
/CSINFO <channel>
/CSIDENTIFY <channel> <password>
/CSACCESS <channel>
/CSOP <channel> [<nick>]
/CSDEOP <channel> <nick>
/CSKICK <nick> [<reason>]
/CSBAN <nick | mask>
/CSMUTE <nick>
/CSKICKBAN <nick | mask> [<reason>] 
/CSUNBAN <nick | mask>
/CSTOPIC <message>
/CSMODE <mode>
/CSINVITE <nick>
/NS
/NSIDENTIFY <password>
/NSGHOST <nick> [<password>]
/NSRECOVER <nick> [<password>]
/NSRELEASE <nick> [<password>]
/NSINFO <nick>
/NSLINK <nick> <password>

Of course, if you have any questions, let me know. You'll need to run "/SAVE" in irssi, if you want to keep them between sessions. Thanks to #freenode and #irssi for helping me get these up and running.

{ 6 } Comments