Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
slack-ruby-bot-server-events
Advanced tools
An extension to slack-ruby-bot-server that makes it easy to handle Slack slash commands, interactive buttons and events.
See slack-ruby/slack-ruby-bot-server-events-sample for a working sample.
Add 'slack-ruby-bot-server-events' to Gemfile.
gem 'slack-ruby-bot-server-events'
Configure your app's OAuth version and scopes as needed by your application.
SlackRubyBotServer.configure do |config|
config.oauth_version = :v2
config.oauth_scope = ['users:read', 'channels:read', 'groups:read', 'chat:write', 'commands', 'incoming-webhook']
end
Configure events-specific settings.
SlackRubyBotServer::Events.configure do |config|
config.signing_secret = 'secret'
end
The following settings are supported.
setting | description |
---|---|
signing_secret | Slack signing secret, defaults is ENV['SLACK_SIGNING_SECRET'] . |
signature_expires_in | Signature expiration window in seconds, default is 300 . |
Get the signing secret from your app's Basic Information settings.
This library supports events, actions and commands. When implementing multiple callbacks for each type, the response from the first callback to return a non nil
value will be used and no further callbacks will be invoked. Callbacks receive subclasses of SlackRubyBotServer::Events::Requests::Request.
Respond to Slack Events by implementing SlackRubyBotServer::Events::Config#on :event
.
The following example unfurls URLs.
SlackRubyBotServer::Events.configure do |config|
config.on :event, 'event_callback', 'link_shared' do |event|
event[:event][:links].each do |link|
Slack::Web::Client.new(token: ...).chat_unfurl(
channel: event[:event][:channel],
ts: event[:event][:message_ts],
unfurls: {
link[:url] => { text: 'Unfurled URL.' }
}.to_json
)
end
true # return true to avoid invoking further callbacks
end
config.on :event, 'event_callback' do |event|
# handle any event callback
false
end
config.on :event do |event|
# handle any event[:event][:type]
false
end
end
Respond to Shortcuts and Interactive Messages as well as Attached Interactive Message Buttons(Outmoded) by implementing SlackRubyBotServer::Events::Config#on :action
.
The following example posts an ephemeral message that counts the letters in a message shortcut.
SlackRubyBotServer::Events.configure do |config|
config.on :action, 'interactive_message', 'action_id' do |action|
payload = action[:payload]
message = payload[:message]
Faraday.post(payload[:response_url], {
text: "The text \"#{message[:text]}\" has #{message[:text].size} letter(s).",
response_type: 'ephemeral'
}.to_json, 'Content-Type' => 'application/json')
{ ok: true }
end
config.on :action do |action|
# handle any other action
false
end
end
The following example responds to an interactive message.
You can compose rich message layouts using Block Kit Builder.
SlackRubyBotServer::Events.configure do |config|
config.on :action, 'block_actions', 'your_action_id' do |action|
payload = action[:payload]
Faraday.post(payload[:response_url], {
text: "The action \"your_action_id\" has been invoked.",
response_type: 'ephemeral'
}.to_json, 'Content-Type' => 'application/json')
{ ok: true }
end
end
Respond to Slash Commands by implementing SlackRubyBotServer::Events::Config#on :command
.
The following example responds to /ping
with pong
.
SlackRubyBotServer::Events.configure do |config|
config.on :command, '/ping' do
{ text: 'pong' }
end
config.on :command do |command|
# handle any other command
false
end
end
Copyright Daniel Doubrovkine and Contributors, 2020
FAQs
Unknown package
We found that slack-ruby-bot-server-events demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.