Coder Social home page Coder Social logo

bqv / weechat-slack Goto Github PK

View Code? Open in Web Editor NEW
5.0 4.0 0.0 485 KB

Weechat plugin for Slack | Fork at your own risk

Home Page: https://github.com/weechat/weechat

License: Mozilla Public License 2.0

Makefile 0.67% C 98.08% Emacs Lisp 0.19% Python 0.46% Perl 0.61%
weechat slack api c irc

weechat-slack's Introduction

weechat-slack

https://api.travis-ci.org/bqv/weechat-slack.svg?branch=master https://coveralls.io/repos/github/bqv/weechat-slack/badge.svg?branch=master https://img.shields.io/github/issues/bqv/weechat-slack.svg https://img.shields.io/github/issues-closed/bqv/weechat-slack.svg https://img.shields.io/github/license/bqv/weechat-slack.svg https://img.shields.io/badge/weechat--extras-slack-blue.svg

Status:Aaaaaaaaaaaaaaaaa
Location:http://github.com/bqv/weechat-slack
Version:0.1.5
Disclaimer:Slack’s API is a thing of horror

Description

A weechat plugin in C to extend the chat client to support Slack workspaces via the RTM and Web APIs.

Usage

  1. Start with /slack register for instructions on how to obtain a token, or if you already have a token, use /slack register <token>.
  2. Use /slack connect <workspace-name> with the name returned by register

Installing

See http://github.com/bqv/weechat-extras for the suite this is part of and a repository/package for your distribution.

Dependencies

  • libwebsockets (static, submodule)
  • json-c (static, submodule)
  • weechat (>= v1.7)

Building

git clone git://github.com/bqv/weechat-slack.git
cd weechat-slack
make
make install

Do NOT run make install as root, it installs the plugin to your local weechat plugins directory

Development

I use emacs for development of this, although I am also a fan of vim. My debug build process involves static analysis with clang and cppcheck, and dynamic analysis with address-sanitizer and leak-sanitizer. My debug evaluation process involves gdb/mi run with the arguments -ex "handle SIGPIPE nostop noprint pass" --args weechat -a 2>asan.log since part of weechat and it’s default plugins use SIGPIPE as control.

I have no real requests for style of pull requests besides a wish that you keep vaguely to the style I have adopted for this project.

Happy coding!

Tasks

DONE [#A] Implement basic functionality (milestone v0.1)

TODO [#A] Implement essential api endpoints and events (milestone v0.2)

  • [X] Implement handling api message =message.me_message= (see #5)
  • [X] Implement sending request =chat.meMessage= (see #5)
  • [X] Implement handling api message =message.bot_message= (see #2)
  • [ ] Implement handling api message message.message_changed
  • [ ] Implement handling api message message.message_deleted
  • [ ] Implement handling api message message.message_replied
  • [ ] Implement handling api message message.file_share
  • [ ] Implement sending websocket typing message

TODO [#B] Implement completion engine (milestone v0.3)

  • [X] Tab completion for slack emoji (see #3)
    • [X] Support Slack Emoji
    • [X] Support Custom Emoji
  • [ ] Tab completion for display/user names (see #1)
  • [ ] Sort nick-completion by recent speakers (see #4)

TODO [#B] Implement websocket ping and pong (milestone v0.4)

  • [ ] Add ping timer and pong handler (see #9)

TODO [#B] Implement thread handling (milestone v0.5)

  • [ ] Implement handling api message message.thread_broadcast

TODO [#C] Implement remaining api endpoints and events (milestone v0.6)

  • [ ] Support all channel types
    • [X] Channels
    • [ ] Groups
    • [ ] MPIMs
    • [ ] IMs
  • [ ] Complete api endpoint set
  • [ ] Complete api event set

TODO [#C] Implement full weechat functionality (milestone v0.7)

  • [ ] Hook buffer closes
  • [ ] Relay compatibility
  • [ ] Config Options
    • [ ] Emoji translation options (see #11)

TODO [#D] Close all issues (milestone v1.0)

Contributing

Your contributions are always welcome! Please submit a pull request or create an issue to add a new or missing feature.

Appropriating

As there is no C library for Slack at the time of writing, this project implements the APIs from scratch, and as such one could butcher this repository to create a minimal Slack C library. Up to you.

License

weechat-slack is licensed under the Mozilla Public License Version 2.0 available here and in LICENSE.

weechat-slack's People

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

weechat-slack's Issues

Prioritise most recent senders when tab-completing nicks for reply

If there are two users joel and joseph, jo tab-completes to joel, as it is alphabetically closer. However, if joseph sent a message more recently than joel, then the user is more likely to be replying to joseph than joel, so joseph should be preferred for completion. (Perhaps this scope should be limited to the last n messages or only those within m pages of backlog)

Emoji translation config options

Add options which defines emoji translation behaviour with options {"text", "unicode", "shortname"} with sample buffer outputs {":)", "😄", ":smile:"}.

Options would define behaviour on

  • Incoming messages (not nullable, emoji representation must be chosen)
  • Outgoing messages (nullable, text can be left verbatim)
  • Input Completion (null = "shortname", since we only complete shortnames)

Depends: #3

Slackbot doesn't stick to the slack api

Example message.bot_message:

{
	"text": "Your file was uploaded \u2014 it\u2019s safe and sound in Slack. Unfortunately your workspace doesn\u2019t have any storage space left. To get more space, you can <https:\/\/hacksoc-y ork.slack.com\/pricing?ui_element=5&amp;ui_step=70|upgrade to a paid account> or delete some of your older files.",
	"is_ephemeral": true,
	"username": "slackbot",
	"type": "message",
	"subtype": "bot_message",
	"user": "USLACKBOT",
	"channel": "C501C2XU6",
	"ts": "1525883688.000000",
	"event_ts": "1525883688.000225"
}

Expected format:

{
    "type": "message",
    "subtype": "bot_message",
    "ts": "1358877455.000010",
    "text": "Pushing is the answer",
    "bot_id": "BB12033",
    "username": "github",
    "icons": {}
}

(Thank you for this thoroughly well designed api, slack.)

Tab completion for Slack emoji

Since there are no emoji rendering on Weechat's side (although plugins exist to remedy this), it would be useful to have tab completion when starting an emoji name like :think -> :thinking-face:. Even more useful (and unique to a Slack setup) would be completion to nonstandard emoji names, like aliases or custom emoji created through Slack.

Message shares not implemented

Not even documented in the API. Seems to follow this as syntax:

{
	"type": "message",
	"user": "U564YE3LH",
	"text": "test",
	"team": "T4YM0ADL1",
	"attachments": [{
		"fallback": "[May 16th, 2018 9:15 PM] slackbot: 2",
		"ts": "1526501729.000255",
		"msg_subtype": "slackbot_response",
		"author_id": "USLACKBOT",
		"author_subname": "slackbot",
		"channel_id": "C7CRW8C1F",
		"channel_name": "bot-testing",
		"is_msg_unfurl": true,
		"text": "2",
		"author_name": "slackbot",
		"author_link": "https:\/\/hacksoc-york.slack.com\/team\/USLACKBOT",
		"author_icon": "https:\/\/a.slack-edge.com\/7f1a0\/plugins\/slackbot\/assets\/service_48.png",
		"mrkdwn_in": ["text"],
		"color": "D0D0D0",
		"from_url": "https:\/\/hacksoc-york.slack.com\/archives\/C7CRW8C1F\/p1526501729000255",
		"is_share": true,
		"footer": "Posted in #bot-testing"
	}],
	"channel": "C7CRW8C1F",
	"event_ts": "1526552623.000458",
	"ts": "1526552623.000458"
}

Tab-complete nicknames into mentions

Taking an example user rms with the display name richards, if you start typing ric and press tab, it will complete to richards: in plain text. Either when the message is sent, or when the tab completion happens, if this was instead changed to @rms, this would correctly turn it into a mention on Slack

Channel mentions render strangely in buffer

If a message is sent mentioning the channel #general, then it renders as #C409D2WU7|general (for example) in the buffer - simply a (possibly bolded) #general would break up the text flow less

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.