You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CHANGELOG.md
+3-2Lines changed: 3 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,11 +1,12 @@
1
1
### Changelog
2
2
3
-
#### 0.11.2 (Next)
3
+
#### 0.12.0 (Next)
4
4
5
5
* Your contribution here.
6
+
*[#113](https://github.com/slack-ruby/slack-ruby-bot-server/pull/113): Added support for intervals with `.every` - [@dblock](https://github.com/dblock).
7
+
*[#112](https://github.com/slack-ruby/slack-ruby-bot-server/pull/112): Added support for multiple `.on` events as an argument - [@dblock](https://github.com/dblock).
6
8
*[#111](https://github.com/slack-ruby/slack-ruby-bot-server/pull/111): Removed dependency on Virtus - [@dblock](https://github.com/dblock).
*[#112](https://github.com/slack-ruby/slack-ruby-bot-server/pull/112): Added support for multiple `.on` events as an argument - [@dblock](https://github.com/dblock).
Copy file name to clipboardExpand all lines: README.md
+37-2Lines changed: 37 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -133,6 +133,8 @@ MyApp.instance.prepare!
133
133
134
134
#### Service Manager
135
135
136
+
##### Lifecycle Callbacks
137
+
136
138
You can introduce custom behavior into the service lifecycle via callbacks. This can be useful when new team has been registered via the API or a team has been deactivated from Slack.
137
139
138
140
```ruby
@@ -171,7 +173,6 @@ The following callbacks are supported. All callbacks receive a `team`, except `e
171
173
| deactivating | a team is being deactivated |
172
174
| deactivated | a team has been deactivated |
173
175
174
-
175
176
The [Add to Slack button](https://api.slack.com/docs/slack-button) also allows for an optional `state` parameter that will be returned on completion of the request. The `creating` and `created` callbacks include an options hash where this value can be accessed (to check for forgery attacks for instance).
@@ -186,9 +187,43 @@ instance.on :creating do |team, error, options|
186
187
end
187
188
```
188
189
189
-
A number of extensions use service manager callbacks to implement useful functionality.
190
+
##### Service Timers
191
+
192
+
You can introduce custom behavior into the service lifecycle on a timer. For example, check whether a team's trial has expired, or periodically cleanup data.
193
+
194
+
Note that unlike callbacks, timers are global for the entire service.
195
+
196
+
```ruby
197
+
instance =SlackRubyBotServer::Service.instance
198
+
199
+
instance.every :hourdo
200
+
Team.each do |team|
201
+
begin
202
+
# do something with every team once an hour
203
+
rescueStandardError
204
+
end
205
+
end
206
+
end
207
+
208
+
instance.every :minutedo
209
+
# called every minute
210
+
end
211
+
212
+
instance.every :seconddo
213
+
# called every second
214
+
end
215
+
216
+
instance.every 30do
217
+
# called every 30 seconds
218
+
end
219
+
```
220
+
221
+
##### Extensions
222
+
223
+
A number of extensions use service manager callbacks and service timers to implement useful functionality.
190
224
191
225
*[slack-ruby-bot-server-mailchimp](https://github.com/slack-ruby/slack-ruby-bot-server-mailchimp): Subscribes new bot users to a Mailchimp mailing list.
226
+
*[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.
0 commit comments