Skip to content
This repository was archived by the owner on Jan 13, 2018. It is now read-only.

Pull chat history into newly opened buffers

Notifications You must be signed in to change notification settings

thoughtbot/weechat-slacklog

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

65 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ARCHIVED: This project has been archived. The original authors no longer use it and Slack is currently phasing out the API it relies on.

Slacklog

Pull Slack chat history in when opening a new buffer.

shot

Installation

This script is not yet released, please install manually:

% curl -o ~/.weechat/ruby/slacklog.rb \
  "https://raw.githubusercontent.com/thoughtbot/weechat-slacklog/master/slacklog.rb"

Optionally set the script to autoload when WeeChat starts:

% cd ~/.weechat/ruby/autoload && ln -s ../slacklog.rb .

Restart WeeChat or load the script manually:

/script load slacklog.rb

Required Settings

Note: You can generate an API token here.

/set plugins.var.ruby.slacklog.servers "thoughtbot"
/set plugins.var.ruby.slacklog.thoughtbot.api_token "abc-123"

These variables can also be modified via the /slacklog command:

/slacklog add thoughtbot abc-123

Optional Settings

By default, the Slack API returns 100 messages when no count is specified. You can change this by setting a value between 1 and 1000:

/set plugins.var.ruby.slacklog.count 500

To change the color of Slacklog lines, change the following WeeChat setting:

/set logger.color.backlog_line darkgray

Usage

Whenever you open a buffer for a server in your servers list (and which has a token defined), 100 messages of history will be fetched via the Slack API and printed into the buffer.

The /slacklog command can be used without arguments to actively fetch and print history for an already open buffer.

Implementation Details

The script can be used outside of WeeChat like so:

% ruby ./slacklog.rb fetch API-TOKEN CHANNEL

This prints history messages on stdout and has no dependencies on the Weechat module. The implementation is contained in a normal SlackAPI class which is well tested.

Global functions wire this up as a WeeChat plugin in the following way:

  • Whenever a channel is joined or the /slacklog command is invoked, we determine the token and channel then ask Weechat to asynchronously execute our script as above with a callback.
  • The callback will receive the lines output by our script, and print them into the buffer.

About

Pull chat history into newly opened buffers

Resources

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

 

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages