Sha256: 21fa69c61c07005cd1aeb2bca869bd3b479e5e410fae55102bdf9e093d99cecd
Contents?: true
Size: 1.25 KB
Versions: 21
Compression:
Stored size: 1.25 KB
Contents
class SlackSmartBot # list of available emojis: https://www.webfx.com/tools/emoji-cheat-sheet/ # react(:thumbsup) # ts: can be true, false or a specific ts def react(emoji, ts=false, channel='') result = true channel = Thread.current[:dest] if channel == '' if ts.is_a?(TrueClass) or ts.is_a?(FalseClass) parent = ts ts = nil else parent = false end if ts.nil? if parent or Thread.current[:ts].to_s == '' ts = Thread.current[:thread_ts] else ts = Thread.current[:ts] end else if ts.to_s.match?(/^\d+\.\d+$/) #thread id elsif ts.to_s.match?(/^p\d\d\d\d\d+$/) #a thread id taken from url fex: p1622549264010700 ts = ts.scan(/(\d+)/).join ts = "#{ts[0..9]}.#{ts[10..-1]}" else ts = Thread.current[:thread_ts] if ts == '' end end if ts.nil? @logger.warn 'react method no ts supplied' result = false else emoji.gsub!(':','') if emoji.is_a?(String) begin client.web_client.reactions_add(channel: channel, name: emoji.to_sym, timestamp: ts) unless config.simulate rescue Exception => stack @logger.warn stack result = false end end return result end end
Version data entries
21 entries across 21 versions & 1 rubygems