LoginSignup
4
2

More than 5 years have passed since last update.

Ruboty を slack の Reminder: に反応させる

Posted at

slack には cron のようなリマインダー機能がある。こいつを登録しておく事で、定期的に slackbot が

Reminder: @name 登録メッセージ...

といった発言をさせることが出来る。

Ruboty に反応させたい

Ruboty は標準の正規表現では、上記メッセージに反応しない。

実装は固定で

module Ruboty
  class Action
    def self.prefix_pattern(robot_name)
      /\A@?#{Regexp.escape(robot_name)}:?\s+/
    end

となっているので、それらを変えてしまう。(-l でロード時のスクリプトに追加等々)

require 'ruboty/action'

module Ruboty
  class Action
    def self.prefix_pattern(robot_name)
      /(?:\A|\s)@?#{Regexp.escape(robot_name)}:?\s+/
    end
  end
end

これで Reminder: @name xxx に反応する。

綺麗なやり方

場当たり的な方法じゃ無く、ちゃんとしたAPIを作ってPRを送ろう!

4
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
2