Of course I have a backup!

Random blobs of wisdom about software development

Using Slack with Weechat, through ZNC

Wednesday, February 08, 2017

I set this up 2 years ago, but today I had to add another Slack network to add, and it took me an hour to figure out. The connection to ZNC was working fine, but when ZNC was trying to connect to the Slack server, I always got "Invalid user name or password" from slackbot. Slack doesn't explicitly tell you, but the username it gives you is supposed to be your nickname, and your ident, and you have to set this up before making a connection attempt.

If you go to your gateway settings page, you get the following information:

Host: myteam.irc.slack.com
User: MySlackUser
Pass: MySlackPassword

So what you have to do is, message your bouncer to add a new network:

/msg *status addnetwork myteam

Then connect to the newly added network in ZNC, and add the Slack server to it:

/server add myteam myznc.com +ssl -password=ZNCUsername/myteam:ZNCPassword
/connect myteam
/msg *status addserver myteam.irc.slack.com +6667 MySlackPassword

At this point ZNC will automatically try to connect, and it will blocked by slackbot, saying "Invalid user name or password". Now comes the magic sauce:

/msg *status disconnect
/msg *status saveconfig

The saveconfig is important, ZNC keeps your settings in memory, and only flushes it to disk when instructed. Now you SSH into your server where ZNC is running (or you can use the web interface), and you change your nickname, and your ident for the server to match the username that you got on the Slack gateway page. Open ~/.znc/config, and find your network:

<Network myteam>
    Ident = MySlackUser
    Nick = MySlackUser

After saving the file, reload the ZNC config:

/msg *status rehash
/msg *status connect

It should connect now.

This was written by Norbert Kéri, posted on Wednesday, February 08, 2017, at 23:18

Tagged as:
Ian wrote
Hi i am having a bit of trouble as I followed your tutorial and still am having issues with incorrect password. I feel like its because of this section here:

/server add myteam myznc.com +ssl -password=ZNCUsername/myteam:ZNCPassword

Is the password actually suppose to be in that form? Assuming ZNCUsername = ian , myteam = team , ZNCpassword = testing123:

-password =ian/team:testing123

2017-02-27 23:48:41

Norbert Kéri wrote
Yeah, that seems correct. To be specific, the format of the password field is username/network:password. ZNC doesn't read the config file, unless you tell it to (with rehash), make sure not to forget that.

2017-03-03 21:46:26

Post a comment

Providing your email is optional, it is never published or shared, it is only used for auto approval purposes. If you already have at least 1 approved comment(s) tied to your email, you don't have to wait for moderation, otherwise the author must approve your comment.

Please solve this totally random captcha