GithubHelp home page GithubHelp logo

haskellcamargo / sclack Goto Github PK

View Code? Open in Web Editor NEW
2.4K 43.0 99.0 1.91 MB

The best CLI client for Slack, because everything is terrible!

License: GNU General Public License v3.0

Python 100.00%
slack slack-api cli cli-app terminal

sclack's Introduction

Sclack

The best CLI client for Slack, because everything is terrible!

Sclack

Disclaimer

The project is still under alpha, there are lots of things already done, but there is also a lot of work to do! If you want to help, please contact me under [email protected] or create an issue! Working in community, we can soon have a CLI client as complete as the web one!

Setup

Using legacy token

First of all get a Slack token here. Use, create or request a token for each workspace that you'll use on Sclack. Not all workspaces allow you to generate a legacy token, so sometimes you'll need to ask for the administrator to enable the feature.

Without a legacy token

Unfortunately some serious hoops need to be jumped through to use a non-legacy token.

  1. Go to https://api.slack.com/apps
  2. Click "Create new app"
  3. Give the app a name (maybe "Sclack") and select the server you'd like to use
  4. Go to "OAuth & Permissions" and add a new redirect URL: http://localhost:8080
  5. Go back to the previous page, you'll be able to see "Client ID" (you will also need the "Client Secret" later). Use this to fill in this url:
    https://slack.com/oauth/authorize?client_id=[Client ID here]&scope=client
  1. Go to that URL in your browser, and authorize the app
  2. The page will redirect to a blank page. Look at the URL and copy the code= parameter (http://localhost:8080?code=[code-will-be-here]&state=)
  3. Now using the copied code, as well as the "Client ID" and "Client Secret" from the app page, fill in and execute this command:
    curl -s "https://slack.com/api/oauth.access?client_id=[client id here]&client_secret=[client secret here]&code=[code here]"
  1. Finally, copy the access_token from the response (should start with xoxs-). This is your new auth token for Sclack

Optional Dependencies

Nerd Fonts

Sclack seems better when used with a Nerd Font. Using them is completely optional, but it is how some Sclack icons are possible. Personally, I use Fira Code Nerd Font. Download, install and set as the default font of your terminal emulator.

libcaca

Sclack uses caca-utils to create ANSI/VT100 + ASCII versions of pictures and render them. Images will only be rendered if both caca-utils is installed and features.pictures is configured to true. To install caca-utils, just run sudo apt-get install caca-utils on Debian and brew install libcaca --with-imlib2 on OS X.

Installation

From Source

Ensure you have Python 3.4 or superior version.

pip

git clone https://github.com/haskellcamargo/sclack.git
cd sclack
pip3 install -r requirements.txt
chmod +x ./app.py
./app.py

pipenv

git clone https://github.com/haskellcamargo/sclack.git
cd sclack
export PIPENV_VENV_IN_PROJECT=1
pipenv install # install deps
pipenv shell # enter virtualenv
python app.py # run app

From Binary

If you don't have Python installed, you can get the compiled binary for Sclack on releases page. Versions will be available for Linux x86/x64 and OS X.

Running

Run ./app.py after giving the correct permissions. If you don't have a ~/.sclack file, you can generate one here by providing your workspace token. You can change the theme, enable or disable images, emojis, markdown, configure keyboards and everything else on config.json. Important: use q to quit!

Your ~/.sclack file will look like:

{
    "workspaces": {
        "default": "wow-such-secret"
    }
}

Multiple workspaces

If you want to, you can use Sclack in multiple workspaces. You can have at most 9 workspaces defined inside workspaces:

{
    "workspaces": {
        "default": "wow-such-secret",
        "another": "wow-another-secret"
    }
}

You can use the keys from 1 up to 9 to switch workspaces or event right-click the indicator:

Multiple workspaces

Quick Switcher

You can use ctrl k (or your custom shortcut) to navigate in your DMs and channels.

Set snooze

You can use ctrl d (or your custom shortcut) to set snooze time.

Get permalink

Focus on message and press r (or your custom shortcut) to get permalink (Quote message) and it will be put into your chat box.

Default keybindings

{
  "keymap": {
    "cursor_down": "j",
    "cursor_left": "h",
    "cursor_right": "l",
    "cursor_up": "k",
    "delete_message": "d",
    "edit_message": "e",
    "go_to_chatbox": "c",
    "go_to_profile": "p",
    "go_to_sidebar": "esc",
    "open_quick_switcher": "ctrl k",
    "quit_application": "q",
    "set_edit_topic_mode": "t",
    "set_insert_mode": "i",
    "yank_message": "y",
    "get_permalink": "r",
    "set_snooze": "ctrl d"
  }
}

The mouse support also has been programmed. You can scroll the chatbox and the sidebar and double click the channels to select.

Sidebar

{
    "sidebar": {
        "width": 25,
        "max_users": 20
    }
}
  • max_users: Max users who are shown in the sidebar

Features

{
    "features": {
        "emoji": true,
        "markdown": true,
        "pictures": true,
        "browser": ""
    }
}
  • browser: Config your preferable browser to open the link, when ever you focus on chat box text which contains external link (http/https), press enter key, the link will be opened. Valid value. Example you can config "browser": "chrome"

Tested Terminals

Sclack has been tested with the following terminal emulators:

  • Gnome Terminal
  • iTerm2
  • QTerminal
  • Terminal (OS X)
  • Terminator
  • XTerm

Testing

To run the tests first install the development dependencies via:

pip3 install -r requirements-dev.txt

and then run pytest.

Contributing

Contributions are very welcome, and there is a lot of work to do! You can...

  • Check out our open issues
  • Provide bug reports
  • Create packages for pip, apt, dnf, rpm, pacman and brew
  • Improve documentation
  • Implement handler for new events
  • Refactor the workarounds in the code
  • Create new themes
  • Make things easier to configure

Screenshots

Made with ๐Ÿ˜ก by @haskellcamargo

sclack's People

Contributors

abhi-jha avatar andrepcg avatar arthurhenrique avatar budnik avatar coryshaw1 avatar dependabot[bot] avatar dill0wn avatar duynguyenhoang avatar fazzone avatar garethp avatar gingermusketeer avatar grubernaut avatar gsgben avatar haskellcamargo avatar jmoses avatar kitdarko avatar kyrofa avatar leschlogl avatar onlurking avatar philskents avatar pprkut avatar schellj avatar sergiusens avatar simonwjackson avatar thornjad avatar yuriploc avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sclack's Issues

Cannot see all users

Hello, it's me again!

So as you may understand from the title, I'm working in a big-ush company with 200+ employees, and from the sidebar, on the direct messages part, I can only see like 15 people, and I'm unable to scroll nor to move the cursor further down, which disallow me to find other users.

[GS]et Dynamically Colors from Themes

Get and set dynamically colors from themes pre stablished.

I have used the Dracula Theme(Zeno Rocha) a lot, and I already configured my slack desktop to use it.
Is this possible load from slack-api this colors theme and put as my default theme?

Documentation for install leads to errors

Hey there, this is small so I figured I would make an issue rather than a pull request. Your instructions for installation via pip can lead to some issues upon install. Specifically the line pip install -r requirements.txt should be pip3 install -r requirements.txt since Python 3.4+ is required. Otherwise, dependencies aren't properly installed.

Error on startup in mount_sidebar

Here's the error:

Task exception was never retrieved
future: <Task finished coro=<App.component_did_mount() done, defined at app.py:97> exception=KeyError('groups',)>
Traceback (most recent call last):
  File "app.py", line 100, in component_did_mount
    yield from self.mount_sidebar(executor)
  File "app.py", line 109, in mount_sidebar
    loop.run_in_executor(executor, self.store.load_users)
  File "/Users/roveo/.pyenv/versions/3.6.6/lib/python3.6/concurrent/futures/thread.py", line 56, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/Users/roveo/sclack/sclack/store.py", line 99, in load_groups
    self.state.groups = self.slack.api_call('mpim.list')['groups']
KeyError: 'groups'

Mark messages in channel as read

We have a busy Slack workspace sometimes multiple hundred messages accumulate in the matter of hours.
Is it possible to mark all messages in a certain channel as read?

Multiple workspaces?

Hi, first off, awesome app. I am using it through the Windows Subsystem for Linux, and it works spectacularly!

I was hoping to use this with multiple workspaces, so I was wondering if that is/will be supported. I took a quick poke at the code but didn't see anything indicating this would work.

Use display name when user posts

I am in a workspace that has an IRC bridge. The bot will change its display name to the user posting the message when it posts. Currently sclack seems to use the default name, and not the display name. It'd be great to support using display names.

This is great!

Sorry, I know this isn't a real issue but this is great. Thanks so much for you work, I like this more than other choices out there.

Support notification

Hi @haskellcamargo, it would be nice to have the notification.

I am working on it to support notification, the first version will be supported for MacOS only.

Default channel for workspace

For now, sclack goes to first channel which usually is not a most activated/important channel. It would be nice if we can configure this. Therefore, workspace configuration could be change to object to be more flexible and easy to extend.

If this configuration is not found, #general channel should be picked.

Support uploaded images

Render and show image link when message containes images. We should handle files in message format is defined below.

{'type': 'message', 'text': '', 'files': [{'id': 'FC714HEKX', 'created': 1533966033, 'timestamp': 1533966033, 'name': 'IMG_20180811_124011.jpg', 'title': 'Image from Android', 'mimetype': 'image/jpeg', 'filetype': 'jpg'.....}

Emojis rendering issues

I'm not sure if there is a pattern or if it is a coincidence but seems like all emojis starting with a special character or a number are not being rendered:

screen shot 2018-08-07 at 3 56 55 pm

While all the others seems to be rendered properly, even the ones with a digit at the end (clock9 for instance).

Error on startup: 'NoneType' object is not callable

When I try to start this application, it manages to load the list of channels and chats I have, but then crashed out with the following stacktrace:

Traceback (most recent call last):
  File "./app.py", line 532, in <module>
    app.start()
  File "./app.py", line 53, in start
    self.urwid_loop.run()
  File "/home/gareth/.local/lib/python3.6/site-packages/urwid/main_loop.py", line 286, in run
    self._run()
  File "/home/gareth/.local/lib/python3.6/site-packages/urwid/main_loop.py", line 384, in _run
    self.event_loop.run()
  File "/home/gareth/.local/lib/python3.6/site-packages/urwid/main_loop.py", line 1484, in run
    reraise(*exc_info)
  File "/home/gareth/.local/lib/python3.6/site-packages/urwid/compat.py", line 55, in reraise
    value = tp()
TypeError: 'NoneType' object is not callable

Up/Down key to switch between chatbox and message panel

It would be convenient if we can easily switch between chatbox and message panel

  1. Pressing "Up" in chatbox will move cursor to message pane at the last message
  2. Pressing "Down" from last message of message panel will move cursor to chatbox at the last char (insert mode)

New message is not updated

Each time I open sclack, it scrolls back to the old position of new message and doesn't sync new stage.

Image support in general

There is a project called ranger which has image support.

from readme:

w3m for the w3mimgdisplay program to preview images

Hope it will help you to implement image views.

Typing "q" while you write a message will close the app

Hi there, I found a bug while trying out your code, here is what I did in order to reproduce it:

  1. ./app.sh
  2. Setup my token
  3. Client is loading
  4. I select myself in the left column and type enter
  5. Type i to enter insert mode
  6. Type in order: ytrewq, the app closes right after I type q

I'm running Mac OsX with the default Terminal in a tmux session. Let me know if you need more info.

Homebrew formula?

Hi, it would be great to have this available in homebrew main tree or as a tap.

Don't receive new messages until I reopen a window

Hey,

I noticed that when if I have a chat window open, I won't receive any new messages in that chat until I reopen the chat (by going to the sidebar and using enter the same chat window). I'm on the latest from master (at the time of writing, 326ad0385104c34207ff73bdd88dea416790a303)

Support for xoxs tokens (or something other than legacy tokens)

First off, thanks so much for building this awesome app!

Not all workspaces allow legacy tokens (xoxp). Would it be possible to add support for newer API tokens (xoxs) or the oauth flow? xoxs tokens are relatively easy to grab, just load up Slack in a browser, log in, open up the dev console and search for "xoxs" (you may need to reload to see it). It should show up in a boot config section for the browser app.

Error while loading team

Hi there,

Sometimes I see this error when loading a team. I saw it two times, but couldn't find the way to repeat it constantly and didn't see any error log to see more info.

  • Fedora 27 4.17.17-100.fc27.x86_64
  • Python 3.6.6 [GCC 7.3.1 20180303 (Red Hat 7.3.1-5)]
  • Terminator

Edit: after a while, it loads normally.

screenshot_2018-09-06_09-58-14

env: python3: No such file or directory

Nice project! I tried to run it, but I ran into this error message: env: python3: No such file or directory

Any idea how to fix that? Seems like I cannot find proper resources online to help me out! :)

readline support in chat box

It would be nice if there was readline support in the chat box to provide convenient navigation/editing capabilities while using sclack.

Compilation fails (Linux)

Hi there,

thought I'd give this nifty looking piece of software a try .. but compilation fails.
As I'm not a crack in python, I don't know exactly what went wrong.
Whenever I try running app.py (permissions set correctly), it fails with the following backtrace error message:

Traceback (most recent call last):
  File "./app.py", line 14, in <module>
    from sclack.components import Attachment, Channel, ChannelHeader, ChatBox, Dm
  File "/home/fwolf/inst/sources/sclack/sclack/components.py", line 11, in <module>
    from .markdown import MarkdownText
  File "/home/fwolf/inst/sources/sclack/sclack/markdown.py", line 3, in <module>
    from .store import Store
  File "/home/fwolf/inst/sources/sclack/sclack/store.py", line 1, in <module>
    from slackclient import SlackClient
  File "/usr/local/lib/python3.4/dist-packages/slackclient/__init__.py", line 1, in <module>
    from .client import SlackClient # noqa
  File "/usr/local/lib/python3.4/dist-packages/slackclient/client.py", line 7, in <module>
    from .server import Server
  File "/usr/local/lib/python3.4/dist-packages/slackclient/server.py", line 12, in <module>
    from requests.packages.urllib3.util.url import parse_url
ImportError: No module named 'requests.packages'

Environment:

  • OS: Linux Mint 17.3 LTS (Ubuntu LTS support enabled)
  • Platform: x86_64
  • Python: 3.4

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.