How can I have stable nick in Irssi?

580 Views Asked by At

Every time I'm connecting to the server due to the screen irssi command, I gain new nick with underline (like: nick_ and now it's already nick____).

I don't have to say how annoying it is. I tried to use command screen -Ur irssi, but then "There is no screen to be resumed matching irssi." appeared.

2

There are 2 best solutions below

1
On

Start irssi and enter these lines:

/network add -autosendcmd "/nick {your nick}" {server name}
/save

In these lines you might notice two "variables":

  1. {your nick} - change to your nick;
  2. {server name} - server's name (i.e. Freenode).

This sets Irssi to change your nick automatically (it runs a command after connection).

Also, you might like checking out Irssi documentation related to the subject: documentation

alternate_nick
An alternate nickname to use if your preferred one is already taken.

nick $IRCNICK
Your main, preferred nick.

Related: resource

0
On

I was also bothered by having my nickname sometimes changed into nickname_, but I wanted to observe that in the irssi's status window and act manually, instead of setting up some automated nickname updates.

Thus, I implemented new /NICKALL alias that lists the current nicknames on all servers that are currently configured, displaying the good nicknames in green, and the bad, unexpected nicknames in red. With this alias in place, observing the current nickname statuses becomes quite comfortable.

Here's the long, single line of code that needs to be added to the ~/.irssi/config file, into the aliases = { ... }; section:

NICKALL = "SCRIPT EXEC my \\$expected = Irssi::settings_get_str(\"nick\")\\; foreach my \\$server (Irssi::servers()) { Irssi::print(\"Your nickname on \\$server->{tag} server \\$server->{address} is \" . ( (\\$server->{nick} eq \\$expected) ? \"\\\\033[1\\;32m\" : \"\\\\033[1\\;31m\" ) . \"\\$server->{nick}\\\\033[0m with user mode \\$server->{usermode}\")\\; }";

Just to clarify, all of the code above goes into a single line. Below is an example of the status window contents produced by executing the newly created /NICKALL alias, minus the already described green/red coloring of the nicknames that indicates their correctness.

Irssi: Your nickname on <network #1> server <server #1> is <nickname> with user mode irwxz
Irssi: Your nickname on <network #2> server <server #2> is <nickname> with user mode Ziw
Irssi: Your nickname on <network #3> server <server #3> is <nickname> with user mode Ri

Surprisingly, implementing this alias took me quite a lot of time, because I went first with a much simpler alias that didn't use Perl code. Alas, there are some bugs in irssi that caused wrong nicknames to be displayed that way, which needed time to be debugged and tested. Eventually, I had to whip up this Perl code, which I've tested to work as expected.

By the way, it's quite sad and annoying to see many minor bugs present in irssi. The one mentioned above is just an example, unfortunately.


Here's an improved version of the /NICKALL alias, which handles currently disconnected servers properly, by emitting appropriate messages:

NICKALL = "SCRIPT EXEC my \\$expected = Irssi::settings_get_str(\"nick\")\\; foreach my \\$server (Irssi::servers()) { if (\\$server->{connected}) { Irssi::print(\"Your nickname on \\$server->{tag} server \\$server->{address} is \" . ( (\\$server->{nick} eq \\$expected) ? \"\\\\033[1\\;32m\" : \"\\\\033[1\\;31m\" ) . \"\\$server->{nick}\\\\033[0m with user mode \\$server->{usermode}\")\\; } else { Irssi::print(\"You are currently \\\\033[1\\;31mnot connected\\\\033[0m to \\$server->{tag} server \\$server->{address}\")\\; } }";

As a quick reminder, all of the code above must go into a single line in the aliases = { ... }; section of the ~/.irssi/config file.