Module: RegexpSlack
- Included in:
- BaezSlack
- Defined in:
- lib/modules/regex_slack.rb
Overview
Module for regular expressions that are common
Instance Method Summary collapse
Instance Method Details
#echo(data, _pattern = '\echo') ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/modules/regex_slack.rb', line 13 def echo(data, _pattern = '\echo') match = data.match(/^\\echo\s(\<[#@])?((.*)\|)?(.*?)(\>)? (.*?)$/i) unless match.nil? channel = match.captures[2] || match.captures[3] text = match.captures[5] check_ts = channel.match(/(.*)-(\d*\.\d*)/) # Useless... until someone find something channel = check_ts.captures[0] unless check_ts.nil? thread = check_ts.captures[1] unless check_ts.nil? end [text, channel, thread] end |
#get_values_from(text, type = 'user') ⇒ Object
3 4 5 6 7 8 9 10 11 |
# File 'lib/modules/regex_slack.rb', line 3 def get_values_from(text, type = 'user') pattern = case type when 'user' /<@(.*)>/ when 'channel' /<#(.*)\|(.*)>/ end text.match(pattern) end |