Skip to content

Commit f023da5

Browse files
committed
Removed RTM sample apps, updated documentation.
1 parent 5788b3b commit f023da5

39 files changed

+37
-955
lines changed

.travis.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,3 @@ before_install:
3131

3232
script:
3333
- bundle exec rake
34-
- BUNDLE_GEMFILE=Gemfile && cd sample_apps/sample_app_$DATABASE_ADAPTER && bundle && bundle exec rake

DEBUGGING.md

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,3 @@
33
### Locally
44

55
You can debug your instance of slack-ruby-bot-server with a built-in `script/console`.
6-
7-
### Silence Mongoid Logger
8-
9-
If Mongoid logging is annoying you.
10-
11-
```ruby
12-
Mongoid.logger.level = Logger::INFO
13-
Mongo::Logger.logger.level = Logger::INFO
14-
```
15-
16-
### Heroku
17-
18-
```
19-
heroku run script/console --app=...
20-
21-
Running `script/console` attached to terminal... up, run.7593
22-
23-
2.2.1 > Team.count
24-
=> 3
25-
```

README.md

Lines changed: 23 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,6 @@ Slack Ruby Bot Server
77

88
Build a complete Slack bot service with Slack button integration, in Ruby.
99

10-
If you are not familiar with Slack bots or Slack API concepts, you might want to watch [this video](http://code.dblock.org/2016/03/11/your-first-slack-bot-service-video.html).
11-
12-
A good [open-source demo](https://github.com/dblock/slack-strava) of a service built on top of this library is [Strava integration with Slack](https://slava.playplay.io).
13-
1410
# Table of Contents
1511

1612
- [What is this?](#what-is-this)
@@ -36,25 +32,19 @@ A good [open-source demo](https://github.com/dblock/slack-strava) of a service b
3632

3733
### What is this?
3834

39-
A library that contains a [Grape](http://github.com/ruby-grape/grape) API serving a [Slack Ruby Bot](https://github.com/slack-ruby/slack-ruby-bot) to multiple teams. This gem combines a web server, a RESTful API and multiple instances of [slack-ruby-bot](https://github.com/slack-ruby/slack-ruby-bot). It integrates with the [Slack Platform API](https://medium.com/slack-developer-blog/launch-platform-114754258b91#.od3y71dyo). Your customers can use a Slack button to install the bot.
35+
A library that contains a web server and a RESTful [Grape](http://github.com/ruby-grape/grape) API serving a Slack bot to multiple teams. Use in conjunction with [slack-ruby-bot-server-events](https://github.com/slack-ruby/slack-ruby-bot-server-events) to build a complete Slack bot service, or [slack-ruby-bot-server-rtm](https://github.com/slack-ruby/slack-ruby-bot-server-rtm) to build a Class RealTime Slack bot. Your customers can use a Slack button to install the bot.
4036

4137
### Stable Release
4238

4339
You're reading the documentation for the **next** release of slack-ruby-bot-server. Please see the documentation for the [last stable release, v0.12.3](https://github.com/slack-ruby/slack-ruby-bot-server/blob/v0.12.3/README.md) unless you're integrating with HEAD. See [UPGRADING](UPGRADING.md) when upgrading from an older version.
4440

45-
### Try Me
46-
47-
A demo version of the [sample app with mongoid](sample_apps/sample_app_mongoid) is running on Heroku at [slack-ruby-bot-server.herokuapp.com](https://slack-ruby-bot-server.herokuapp.com). Use the _Add to Slack_ button. The bot will join your team as _@slackbotserver_.
48-
49-
![](images/slackbutton.gif)
41+
### Make Your Own
5042

51-
Once a bot is registered, you can invite to a channel with `/invite @slackbotserver` interact with it. DM "hi" to it, or say "@slackbotserver hi".
43+
We recommend you get started from a [slack-ruby-bot-events-sample](https://github.com/slack-ruby/slack-ruby-bot-server-events-sample) app to bootstrap your project.
5244

53-
![](images/slackbotserver.gif)
45+
### Storage
5446

55-
### Run Your Own
56-
57-
You can use one of the [sample applications](sample_apps) to bootstrap your project and start adding slack command handlers on top of this code. A database is required to store teams.
47+
A database is required to store teams.
5848

5949
### MongoDB
6050

@@ -67,8 +57,6 @@ gem 'mongoid-scroll'
6757
gem 'slack-ruby-bot-server'
6858
```
6959

70-
See the [sample app using Mongoid](sample_apps/sample_app_mongoid) for more information.
71-
7260
### ActiveRecord
7361

7462
Use ActiveRecord with, for example, PostgreSQL via [pg](https://github.com/ged/ruby-pg). Configure the database connection in `postgresql.yml`. Add the `activerecord`, `pg`, `otr-activerecord` and `cursor_pagination` gems to your Gemfile.
@@ -81,11 +69,9 @@ gem 'otr-activerecord'
8169
gem 'cursor_pagination'
8270
```
8371

84-
See the [sample app using ActiveRecord](sample_apps/sample_app_activerecord) for more information.
85-
8672
### Usage
8773

88-
Start with one of the samples above, which contain a couple of custom commands, necessary dependencies and tests, then [create a new Slack App](https://api.slack.com/applications/new).
74+
Start with the [slack-ruby-bot-events-sample](https://github.com/slack-ruby/slack-ruby-bot-server-events-sample) sample, which contain a couple of custom commands, necessary dependencies and tests, then [create a new Slack App](https://api.slack.com/applications/new).
8975

9076
![](images/create-app.png)
9177

@@ -97,6 +83,13 @@ Run `bundle install` and `foreman start` to boot the app. Navigate to [localhost
9783

9884
### OAuth Code Grant
9985

86+
Configure your app's [OAuth scopes](https://api.slack.com/legacy/oauth-scopes) as needed by your application.
87+
88+
```ruby
89+
SlackRubyBotServer.configure do |config|
90+
config.oauth_scope = ['channels:read', 'chat:write:user']
91+
```
92+
10093
The "Add to Slack" button uses the standard OAuth code grant flow as described in the [Slack docs](https://api.slack.com/docs/oauth#flow).
10194

10295
The button itself contains a link that looks like this:
@@ -105,28 +98,11 @@ The button itself contains a link that looks like this:
10598
https://slack.com/oauth/authorize?scope=<%= SlackRubyBotServer::Config.oauth_scope_s %>&client_id=<%= ENV['SLACK_CLIENT_ID'] %>
10699
```
107100

108-
Once clicked, the user is taken through the authorization process at Slack's site. Upon successful completion, a callback containing a temporary code is sent to the redirect URL you specified. The endpoint at that URL contains code that looks like this:
109-
110-
```ruby
111-
# Instantiate a web client
112-
client = Slack::Web::Client.new
113-
114-
# Request a token using the temporary code
115-
rc = client.oauth_access(
116-
client_id: ENV['SLACK_CLIENT_ID'],
117-
client_secret: ENV['SLACK_CLIENT_SECRET'],
118-
code: params[:code]
119-
)
120-
121-
# Pluck the token from the response
122-
token = rc['bot']['bot_access_token']
123-
```
124-
125-
The token is stored in persistent storage and used each time a Slack client is instantiated for the specific team.
101+
Once clicked, the user is taken through the authorization process at Slack's site. Upon successful completion, a callback containing a temporary code is sent to the redirect URL you specified. The endpoint at that URL contains code that persists the bot token each time a Slack client is instantiated for the specific team.
126102

127103
### API
128104

129-
This library implements an app, [SlackRubyBotServer::App](lib/slack-ruby-bot-server/app.rb), a service manager, [SlackRubyBotServer::Service](lib/slack-ruby-bot-server/service.rb) that creates multiple instances of a bot server class, [SlackRubyBotServer::Server](lib/slack-ruby-bot-server/server.rb), one per team. It also provides [default HTML templates and JS scripts](public) for Slack integration.
105+
This library implements an app, [SlackRubyBotServer::App](lib/slack-ruby-bot-server/app.rb) and a service manager, [SlackRubyBotServer::Service](lib/slack-ruby-bot-server/service.rb). It also provides [default HTML templates and JS scripts](public) for Slack integration.
130106

131107
#### App
132108

@@ -248,26 +224,7 @@ A number of extensions use service manager callbacks and service timers to imple
248224
* [slack-ruby-bot-server-events](https://github.com/slack-ruby/slack-ruby-bot-server-events): Easily handle Slack slash commands, interactive buttons and events.
249225
* [slack-ruby-bot-server-mailchimp](https://github.com/slack-ruby/slack-ruby-bot-server-mailchimp): Subscribes new bot users to a Mailchimp mailing list.
250226
* [slack-ruby-bot-server-stripe](https://github.com/slack-ruby/slack-ruby-bot-server-stripe): Enables paid bots with trial periods and commerce through Stripe.
251-
252-
#### Server Class
253-
254-
You can override the server class to handle additional events, and configure the service to use it.
255-
256-
```ruby
257-
class MyServer < SlackRubyBotServer::Server
258-
on :hello do |client, data|
259-
# connected to Slack
260-
end
261-
262-
on :channel_joined do |client, data|
263-
# the bot joined a channel in data.channel['id']
264-
end
265-
end
266-
267-
SlackRubyBotServer.configure do |config|
268-
config.server_class = MyServer
269-
end
270-
```
227+
* [slack-ruby-bot-server-rtm](https://github.com/slack-ruby/slack-ruby-bot-server-rtm): Create RTM Slack bots.
271228

272229
#### Service Class
273230

@@ -302,15 +259,16 @@ end
302259

303260
### Access Tokens
304261

305-
By default the implementation of [Team](lib/slack-ruby-bot-server/models/team) stores a `bot_access_token` as `token` that grants a certain amount of privileges to the bot user as described in [Slack OAuth Docs](https://api.slack.com/docs/oauth) along with `activated_user_access_token` that represents the token of the installing user. You may not want a bot user at all, or may require different auth scopes, such as `users.profile:read` to access user profile information via `Slack::Web::Client#users_profile_get`. To change required scopes make the following changes.
262+
By default the implementation of [Team](lib/slack-ruby-bot-server/models/team) stores a `bot_access_token` as `token` (for backwards compatibility), and `activated_user_access_token` as the token with all the requested OAuth scopes.
263+
264+
### Sample Bots Using Slack Ruby Bot Server
306265

307-
1) Configure your app to require additional scopes in Slack API under _OAuth_, _Permissions_
308-
2) Change the _Add to Slack_ buttons to require the additional scope, eg. `https://slack.com/oauth/authorize?scope=bot,users.profile:read&client_id=...`
309-
3) The access token with the requested scopes will be stored as `activated_user_access_token`.
266+
#### Slack Bots with Granular Permissions
310267

311-
You can see a sample implementation in [slack-sup#3a497b](https://github.com/dblock/slack-sup/commit/3a497b436d25d3a7738562655cda64b180ae0096).
268+
* [slack-ruby-bot-server-events-sample](https://github.com/slack-ruby/slack-ruby-bot-server-events-sample), a generic sample
269+
* [slack-rails-bot-starter](https://github.com/CrazyOptimist/slack-rails-bot-starter), an all-in-one Rails starter kit
312270

313-
### Example Bots Using Slack Ruby Bot Server
271+
#### Legacy Slack Bots
314272

315273
* [slack-ruby-bot-server-sample](https://github.com/slack-ruby/slack-ruby-bot-server-sample), a generic sample
316274
* [slack-sup](https://github.com/dblock/slack-sup), see [sup.playplay.io](https://sup.playplay.io)
@@ -320,7 +278,6 @@ You can see a sample implementation in [slack-sup#3a497b](https://github.com/dbl
320278
* [slack-api-explorer](https://github.com/slack-ruby/slack-api-explorer), see [api-explorer.playplay.io](https://shell.playplay.io)
321279
* [slack-strava](https://github.com/dblock/slack-strava), see [slava.playplay.io](https://slava.playplay.io)
322280
* [slack-arena](https://github.com/dblock/slack-arena), see [arena.playplay.io](https://arena.playplay.io)
323-
* [slack-rails-bot-starter](https://github.com/CrazyOptimist/slack-rails-bot-starter), an all-in-one rails starter kit built on top of the slack-ruby-bot-server and the slack-ruby-bot-server-events
324281

325282
### Copyright & License
326283

UPGRADING.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,20 @@
11
Upgrading Slack-Ruby-Bot-Server
22
===============================
33

4+
### Upgrading to >= 1.0.0
5+
6+
#### Extracted RealTime (Legacy) Support
7+
8+
New slack apps may no longer access RTM. Classic Slack apps can no longer be submitted to the app directory as of December 4th, 2020. In preparation for these changes slack-ruby-bot-server no longer includes RTM components by default. These have been extracted to a new gem [slack-ruby-bot-server-rtm](https://github.com/slack-ruby/slack-ruby-bot-server-rtm).
9+
10+
To upgrade an existing classic Slack app that uses slack-ruby-bot-server do the following.
11+
12+
1. Add `slack-ruby-bot-server-rtm` as an additional dependency.
13+
2. Replace any reference to `SlackRubyBotServer::Server` to `SlackRubyBotServer::RealTime::Server`.
14+
3. Replace any `require 'slack-ruby-bot-server/rspec'` with `require 'slack-ruby-bot-server-rtm/rspec'`.
15+
16+
Existing RTM Slack bots will continue working and be listed in the Slack App Directory. On December 4th, 2020 Slack will no longer accept resubmissions from apps that are not using granular permissions. On November 18, 2021 Slack will start delisting apps that have not migrated to use granular permissions. Use [slack-ruby-bot-server-events](https://github.com/slack-ruby/slack-ruby-bot-server-events) to create a Slack bot with granular permissions. See [migration](https://api.slack.com/authentication/migration) for more details.
17+
418
### Upgrading to >= 0.11.0
519

620
#### Removed Legacy Migrations

sample_apps/README.md

Lines changed: 0 additions & 11 deletions
This file was deleted.

sample_apps/sample_app_activerecord/.rspec

Lines changed: 0 additions & 3 deletions
This file was deleted.

sample_apps/sample_app_activerecord/.standalone_migrations

Lines changed: 0 additions & 3 deletions
This file was deleted.

sample_apps/sample_app_activerecord/Gemfile

Lines changed: 0 additions & 25 deletions
This file was deleted.

sample_apps/sample_app_activerecord/Procfile

Lines changed: 0 additions & 1 deletion
This file was deleted.

sample_apps/sample_app_activerecord/README.md

Lines changed: 0 additions & 12 deletions
This file was deleted.

0 commit comments

Comments
 (0)