• Stars
    star
    107
  • Rank 316,664 (Top 7 %)
  • Language
    Python
  • License
    GNU General Publi...
  • Created about 6 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

IRC gateway for slack, running on localhost for one user

localslackirc

The idea of this project is to create a localhost IRC server that functions as a gateway for one user of slack, that can connect to it with whatever IRC client they prefer or a bouncer like ZNC and keep using slack from IRC even after they shut down their IRC gateway.

Why? Peace of mind!

Using slack from IRC instead of web app offers several advantages:

  • You do not see all the gifs other people post.
  • You can silence @here notifications for selected users and channels where they are abused.
  • You can /ignore users who bother you (can't do that on slack).
  • Leaving channels on slack is hard, normally I get invited back continuously on the off topic channels. With localslackirc you can leave them on the IRC client without people knowing that you won't be reading any of that.
  • IRC clients allow to customise notifications. For example I have set mine to just blink in the tray area and do no sounds or popups.
  • Any IRC client is faster than the web ui slack has, and it will respect your colour and style settings.
  • Power savings. Because that's a logical consequence of not doing something in the browser.

Running localslackirc

The preferred way is to have Debian Testing and install from the repository. You can grab the latest .deb and sources from: https://github.com/ltworf/localslackirc/releases

All the options are documented in the man page. Execute

man man/localslackirc.1

To read the page without installing localslackirc on the system.

There is alocalslackirc binary but the preferred way is to run it using systemd.

Systemd

When installed from the .deb you will find a configuration template file in /etc/localslackirc.d/example.

Create a copy of it in the same directory and edit the copy.

You can create several copies to use several slack workspaces.

Tell systemd to start localslackirc and make sure the ports do not collide.

instancename is the name of the file.

# To start the instance
sudo systemctl start [email protected]
# To start the instance at every boot
sudo systemctl enable [email protected]

Docker

Create a configuration file basing it on localslackirc.d/example

# Create the container
docker build -t localslackirc -f docker/Dockerfile .

# Run localslackirc
docker run -d -p 9007:9007 --name=mylocalslackirc --env-file configfile localslackirc

Sources

Requirements

  • At least Python 3.10
  • The modules indicated in requirements.txt

Check the manpage for the parameters.

./localslackirc

Obtain a token

Before localslackirc can do anything useful, you need to obtain a token.

Your token should be placed inside the configuration file.

Obtain a token from slack

Alternatively if this method fails you can get one from Slack's web client

  1. Instructions for Chromium and Firefox
  • In your browser, login to slack and then open the web console.
  • Run this javascript code: q=JSON.parse(localStorage.localConfig_v2)["teams"]; q[Object.keys(q)[0]]["token"]
  • Copy the result, without quotes.
  • Note: If you are signed in to multiple teams this will not work, run in a private window for the team you want to set up.

Obtain a Slack cookie

This step is only needed if your token starts with xoxc-. This option is available since release 1.7.

  • Run this javascript code:
q=JSON.parse(localStorage.localConfig_v2)["teams"];
var authToken=q[Object.keys(q)[0]]["token"];


// setup request
var formData = new FormData();
formData.append('token', authToken);

// make request
(async () => {
  const rawResponse = await fetch('/api/emoji.list', {
    method: 'POST',
    body: formData
  });

  const emojisApi = await rawResponse.json();

  // dump to console
})();
  • In the network tab inspect the request for "emoji.list".
  • From that request, copy the "Cookie" header.
  • The values in the field look like key1=value1; key2=value2; key3=value3;
  • Get the string d=XXXXXX; (where XXX is the secret) and that is your cookie value. It is important to copy the d= part and the final ;.
  • Save the string in its own file (different than the token file).

Using localslackirc

After installing localslackirc and obtaining the token, it is the time to connect to localslackirc with the IRC client.

  • Connect to the IRC server created by localslackirc (by default 127.0.0.1:9007)
  • Use your Slack username as your nickname
  • If you left autojoin on, your client will automatically join your slack channels.

Sending files

You can use /sendfile #destination filepath to send files. Destination can be a channel or a user.

Annoying people

You can use /annoy user to send typing notifications whenever the specified user sends a typing notification.

Discussion threads

There is some support for discussion threads. They are mapped as irc channels that get automatically joined when a message is received. The channel of origin is specified in the topic. Until a thread has some activity you can't write to it. They are only tested for channels, not private groups or chats.

Instructions for irssi

If you need to refresh your memory about connecting in general, this is a good guide: https://pthree.org/2010/02/02/irssis-channel-network-server-and-connect-what-it-means/

Here's a list of irssi commands to set up a network and a localhost server:

/network add -user <you> -realname "<your name>" -nick <your nick> <slackname>
/server add -auto -port 9007 -network <slackname> localhost
/save

Then, start localslackirc in your terminal if you haven't already. (Just type ./localslackirc).

After localslackirc is running, and you have seen the connection message seen above, you can just connect to the localhost IRC network in irssi. Like this:

/connect <slackname>

And you should see the following message in your irssi:

22:15:35 [<slackname>] -!- Irssi: Looking up localhost
22:15:35 [<slackname>] -!- Irssi: Connecting to localhost [127.0.0.1] port 9007
22:15:35 [<slackname>] -!- Irssi: Connection to localhost established
22:15:36 [<slackname>] -!- Hi, welcome to IRC
22:15:36 [<slackname>] -!- Your host is serenity, running version miniircd-1.2.1
22:15:36 [<slackname>] -!- This server was created sometime
22:15:36 [<slackname>] -!- serenity miniircd-1.2.1 o o
22:15:36 [<slackname>] -!- There are 1 users and 0 services on 1 server
...

IRC Channel

#localslackirc on oftc

More Repositories

1

typedload

Python library to load dynamically typed data into statically typed data structures
Python
192
star
2

relational

Educational tool for relational algebra
Python
86
star
3

weborf

Shares files using the HTTP protocol. Provides CLI and GUI. Allows using webdav.
C
54
star
4

funny-manpages

Funny unix manpages
Makefile
24
star
5

lapdog

Take actions when specific devices appear/disappear from your LAN
C++
17
star
6

vasttrafik-cli

Migrated to codeberg
Python
8
star
7

ultimateultimateguitar

CLI client to ultimate-guitar website
Python
8
star
8

python-acpi

Provides a python module to interface with ACPI things, and a script to listen to events and react to them by changing the frequency or locking the screen.
Python
5
star
9

ynew

Execute a script in a new yakuake tab
Shell
4
star
10

trabucco

Can launch your 90kg applications for 300m (It's a launcher, like katapult, but better).
C++
4
star
11

scurpiddu

Music player based on mpv and Qt
C++
4
star
12

DomainUserAgent

This extension changes the user agent depending on the hostname.
JavaScript
3
star
13

rtcsusp

Use the RTC to wake up at a given time
Python
2
star
14

InstagramPhotoLink

Browser extension to show the link to the images on instagram
JavaScript
2
star
15

ltdata

IRC bot in python
Python
2
star
16

rssagk

RSS aggregator for symbian
Python
1
star
17

cooja-dbus

Cooja plugin to control the simulation using dbus.
Java
1
star
18

leggero

Educational tool to improve music reading skills
C++
1
star
19

parolottero

Word game similar to Boggle and Ruzzle
C++
1
star
20

nitroxcalc

Nitrox calculations
QML
1
star
21

srtgen

Automatically generate .srt files from media files.
Python
1
star
22

DiveShare

Service to share divelogs online
Python
1
star
23

canary

Tool to check for memory overflows
C
1
star
24

rais

Yet another privacy oriented browser
C++
1
star
25

anairc

Anairc is a simple distributed chat written in java, usable in LAN enviroments without any server.
Java
1
star
26

international_code_of_conduct

Code of conduct for international projects with international contributors. Still a draft.
1
star