### Installing Dependencies and Running Tests - Shell Source: https://github.com/slack-ruby/slack-ruby-bot-server-events/blob/master/CONTRIBUTING.md Installs project dependencies using Bundler and executes the project's test suite using Rake to verify build and test success. ```Shell bundle install bundle exec rake ``` -------------------------------- ### Running Tests (Rake) Source: https://github.com/slack-ruby/slack-ruby-bot-server-events/blob/master/RELEASING.md Executes bundle install to ensure dependencies are met, then runs the test suite using Rake to verify code correctness before releasing. ```Shell bundle install rake ``` -------------------------------- ### Implementing Slack Event Callbacks Source: https://github.com/slack-ruby/slack-ruby-bot-server-events/blob/master/README.md Configure SlackRubyBotServer Events to handle various Slack events by defining callbacks using `config.on`. This example shows handling `link_shared` events, a general `event_callback`, and any event type. ```Ruby 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 ``` -------------------------------- ### Cloning and Setting Up Remote Git Repository - Shell Source: https://github.com/slack-ruby/slack-ruby-bot-server-events/blob/master/CONTRIBUTING.md Clones the project repository from a fork, navigates into the directory, and adds the original repository as an 'upstream' remote for syncing. ```Shell git clone https://github.com/contributor/slack-ruby-bot-server-events.git cd slack-ruby-bot-server-events git remote add upstream https://github.com/slack-ruby/slack-ruby-bot-server-events.git ``` -------------------------------- ### Preparing CHANGELOG for Next Version (Text) Source: https://github.com/slack-ruby/slack-ruby-bot-server-events/blob/master/RELEASING.md Shows the format for adding the entry for the next development version in CHANGELOG.md, using "Next" as a placeholder for the date. ```Text ### 0.2.3 (Next) * Your contribution here. ``` -------------------------------- ### Running Release Command (Rake) Source: https://github.com/slack-ruby/slack-ruby-bot-server-events/blob/master/RELEASING.md Executes the Rake release task, which builds the gem, tags the release in Git, pushes commits and tags, and pushes the gem to rubygems.org. The output shows the successful steps. ```Shell $ rake release slack-ruby-bot-server-events 0.2.2 built to pkg/slack-ruby-bot-server-events-0.2.2.gem. Tagged v0.2.2. Pushed git commits and tags. Pushed slack-ruby-bot-server-events 0.2.2 to rubygems.org. ``` -------------------------------- ### Updating CHANGELOG for Release (Text) Source: https://github.com/slack-ruby/slack-ruby-bot-server-events/blob/master/RELEASING.md Shows the required format for updating the CHANGELOG.md file, changing "Next" to the specific release date and version number. ```Text ### 0.2.2 (7/10/2015) ``` -------------------------------- ### Staging and Committing Git Changes - Shell Source: https://github.com/slack-ruby/slack-ruby-bot-server-events/blob/master/CONTRIBUTING.md Stages changes for commit and then opens the default editor to write the commit message. ```Shell git add ... git commit ``` -------------------------------- ### Committing Release Changes (Git) Source: https://github.com/slack-ruby/slack-ruby-bot-server-events/blob/master/RELEASING.md Stages and commits the updated CHANGELOG.md file with a message indicating preparation for the release, then pushes the changes to the remote master branch. ```Shell git add CHANGELOG.md git commit -m "Preparing for release, 0.2.2." git push origin master ``` -------------------------------- ### Committing Next Version Changes (Git) Source: https://github.com/slack-ruby/slack-ruby-bot-server-events/blob/master/RELEASING.md Stages and commits the updated CHANGELOG.md and version.rb files with a message indicating preparation for the next development iteration, then pushes the changes to the remote master branch. ```Shell git add CHANGELOG.md lib/slack-ruby-bot-server-events/version.rb git commit -m "Preparing for next development iteration, 0.2.3." git push origin master ``` -------------------------------- ### Creating a Topic Branch for Development - Shell Source: https://github.com/slack-ruby/slack-ruby-bot-server-events/blob/master/CONTRIBUTING.md Ensures the local master branch is up-to-date with the upstream repository and creates a new branch for implementing features or bug fixes. ```Shell git checkout master git pull upstream master git checkout -b my-feature-branch ``` -------------------------------- ### Handling Slack Slash Command (Ruby) Source: https://github.com/slack-ruby/slack-ruby-bot-server-events/blob/master/README.md Configures a handler for the specific Slack slash command '/ping'. It simply returns the text 'pong' as the response. Includes a generic handler for any other slash commands. ```ruby 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 ``` -------------------------------- ### Pushing Local Git Branch to Origin - Shell Source: https://github.com/slack-ruby/slack-ruby-bot-server-events/blob/master/CONTRIBUTING.md Pushes the local topic branch to the remote repository named 'origin' (typically the user's fork). ```Shell git push origin my-feature-branch ``` -------------------------------- ### Adding Gem to Gemfile Source: https://github.com/slack-ruby/slack-ruby-bot-server-events/blob/master/README.md Add the 'slack-ruby-bot-server-events' gem to your Gemfile to include it in your project dependencies. ```Ruby gem 'slack-ruby-bot-server-events' ``` -------------------------------- ### Configuring SlackRubyBotServer OAuth Source: https://github.com/slack-ruby/slack-ruby-bot-server-events/blob/master/README.md Configure the main SlackRubyBotServer settings, including the OAuth version and required scopes for your application. ```Ruby SlackRubyBotServer.configure do |config| config.oauth_version = :v2 config.oauth_scope = ['users:read', 'channels:read', 'groups:read', 'chat:write', 'commands', 'incoming-webhook'] end ``` -------------------------------- ### Configuring Git User Identity - Shell Source: https://github.com/slack-ruby/slack-ruby-bot-server-events/blob/master/CONTRIBUTING.md Sets the global Git user name and email address, which will be used in commit messages. ```Shell git config --global user.name "Your Name" git config --global user.email "contributor@example.com" ``` -------------------------------- ### Handling Slack Interactive Message Action (Ruby) Source: https://github.com/slack-ruby/slack-ruby-bot-server-events/blob/master/README.md Configures a handler for a specific Slack action ('interactive_message' with 'action_id'). It extracts the message text from the payload, calculates its size, and posts an ephemeral response back to Slack using Faraday. Includes a generic handler for other actions. ```ruby 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 ``` -------------------------------- ### Configuring SlackRubyBotServer Events Signing Secret Source: https://github.com/slack-ruby/slack-ruby-bot-server-events/blob/master/README.md Configure events-specific settings for SlackRubyBotServer, primarily setting the signing secret required to verify incoming requests from Slack. ```Ruby SlackRubyBotServer::Events.configure do |config| config.signing_secret = 'secret' end ``` -------------------------------- ### Rebasing Local Branch with Upstream - Shell Source: https://github.com/slack-ruby/slack-ruby-bot-server-events/blob/master/CONTRIBUTING.md Fetches updates from the upstream repository, reapplies local commits on top of the updated upstream branch, and force pushes the rebased branch to origin. ```Shell git fetch upstream git rebase upstream/master git push origin my-feature-branch -f ``` -------------------------------- ### Handling Slack Block Action (Ruby) Source: https://github.com/slack-ruby/slack-ruby-bot-server-events/blob/master/README.md Configures a handler for a specific Slack block action ('block_actions' with 'your_action_id'). It extracts the payload and posts an ephemeral response back to Slack using Faraday, confirming the action was invoked. ```ruby 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 ``` -------------------------------- ### Amending Last Commit and Force Pushing - Shell Source: https://github.com/slack-ruby/slack-ruby-bot-server-events/blob/master/CONTRIBUTING.md Amends the most recent commit (e.g., to add changes or update the message) and force pushes the updated commit to the remote branch. ```Shell git commit --amend git push origin my-feature-branch -f ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.