Sha256: fb1881b23d59c37a434a5aa1f19a17da4844ef4a3c60e086cf299b19683820c3

Contents?: true

Size: 742 Bytes

Versions: 25

Compression:

Stored size: 742 Bytes

Contents

# frozen_string_literal: true

require 'eac_ruby_utils/core_ext'
require 'eac_ruby_utils/immutable'
require 'telegram/bot'

module Ehbrs
  module Telegram
    class MessageSending
      include ::EacRubyUtils::Immutable
      immutable_accessor :bot_token, :message
      immutable_accessor :recipient_id, type: :array

      def run
        ::Telegram::Bot::Client.run(prop(:bot_token)) do |bot|
          prop(:recipient_ids).each do |recipient_id|
            bot.api.sendMessage(chat_id: recipient_id, text: prop(:message))
          end
        end
      end

      private

      def prop(attribute)
        r = send(attribute)
        return r if r.present?

        raise "Attribute #{attribute} is blank"
      end
    end
  end
end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
ehbrs-tools-0.35.1 lib/ehbrs/telegram/message_sending.rb
ehbrs-tools-0.35.0 lib/ehbrs/telegram/message_sending.rb
ehbrs-tools-0.34.0 lib/ehbrs/telegram/message_sending.rb
ehbrs-tools-0.33.0 lib/ehbrs/telegram/message_sending.rb
ehbrs-tools-0.32.0 lib/ehbrs/telegram/message_sending.rb
ehbrs-tools-0.31.1 lib/ehbrs/telegram/message_sending.rb
ehbrs-tools-0.31.0 lib/ehbrs/telegram/message_sending.rb
ehbrs-tools-0.30.0 lib/ehbrs/telegram/message_sending.rb
ehbrs-tools-0.29.0 lib/ehbrs/telegram/message_sending.rb
ehbrs-tools-0.28.3 lib/ehbrs/telegram/message_sending.rb
ehbrs-tools-0.28.2 lib/ehbrs/telegram/message_sending.rb
ehbrs-tools-0.28.1 lib/ehbrs/telegram/message_sending.rb
ehbrs-tools-0.28.0 lib/ehbrs/telegram/message_sending.rb
ehbrs-tools-0.27.0 lib/ehbrs/telegram/message_sending.rb
ehbrs-tools-0.26.0 lib/ehbrs/telegram/message_sending.rb
ehbrs-tools-0.25.1 lib/ehbrs/telegram/message_sending.rb
ehbrs-tools-0.25.0 lib/ehbrs/telegram/message_sending.rb
ehbrs-tools-0.24.0 lib/ehbrs/telegram/message_sending.rb
ehbrs-tools-0.23.1 lib/ehbrs/telegram/message_sending.rb
ehbrs-tools-0.23.0 lib/ehbrs/telegram/message_sending.rb