Sha256: a293325ead5fce81ead3e051253b8ba9b6e22caaa7dbd9c457458f13854b8fad
Contents?: true
Size: 1.04 KB
Versions: 2
Compression:
Stored size: 1.04 KB
Contents
# frozen_string_literal: true require 'roko/report_event' require 'time' module Roko module Source module Slack # event adapter from slack to report event module EventAdapter MAX_SUMMARY_TEXT_LENGTH = 20 class << self # @param event [Slack::Messages::Message] # @return [Roko::ReportEvent] def to_report_event(event) source = 'slack' event_type = 'comment' created_at = Time.at(event.ts.to_i) url = event.permalink text = event.text summary_text = summarize(text) summary = "in ##{event.channel.name} \"#{summary_text}\"" detail = text Roko::ReportEvent.new(source, event_type, created_at, url, summary, detail) end private def summarize(text) if text.length > MAX_SUMMARY_TEXT_LENGTH text[0, MAX_SUMMARY_TEXT_LENGTH] + '...' else text end end end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
roko-0.2.1 | lib/roko/source/slack/event_adapter.rb |
roko-0.2.0 | lib/roko/source/slack/event_adapter.rb |