Skip to content

Commit

Permalink
Update CHANGELOG.md and README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
Michal Dudzinski committed Mar 6, 2018
1 parent c326620 commit 3be83f4
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
### 0.10.6 (Next)

* Your contribution here.
* [#180](https://github.com/slack-ruby/slack-ruby-bot/pull/180): Allow to respond to text in attachments #177 - [@mdudzinski](https://github.com/mdudzinski).
* [#173](https://github.com/slack-ruby/slack-ruby-bot/pull/173): Exposing SlackRubyBot::CommandsHelper.find_command_help_attrs - [@alexagranov](https://github.com/alexagranov).
* [#179](https://github.com/slack-ruby/slack-ruby-bot/pull/179): Allow multiline expression - [@tiagotex](https://github.com/tiagotex).

Expand Down
40 changes: 40 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,46 @@ end

See [examples/market](examples/market/marketbot.rb) for a working example.

### Matching text in message attachments

You can respond to text in [attachments](https://api.slack.com/docs/message-attachments) with
`attachment`. It will scan `text`, `pretext` and `title` fields in each attachment until a first
match is found.

For example you can match [this example attachment](http://goo.gl/K0cLkH)
by its `title` with the following bot:

```ruby
class Attachment < SlackRubyBot::Bot
attachment 'Slack API Documentation' do |client, data, match|
client.say(channel: data.channel, text: "Matched by #{match.attachment_field}.")
client.say(channel: data.channel, text: "The attachment's text: #{match.attachment.text}.")
end
end
```

You can also define which fields in attachment object should be scanned.

Scan only a single field:

```ruby
class Attachment < SlackRubyBot::Bot
attachment 'Slack API Documentation', :title do |client, data, match|
# implementation details
end
end
```

Scan multiple fields:

```ruby
class Attachment < SlackRubyBot::Bot
attachment 'Slack API Documentation', %i[text pretext author_name] do |client, data, match|
# implementation details
end
end
```

### Providing description for your bot and commands

You can specify help information for bot or commands with `help` block, for example:
Expand Down

0 comments on commit 3be83f4

Please sign in to comment.