Sha256: 350f6628d85d0e7033862dd3eceaf93afca2937aa008f91740ce4be733dac871

Contents?: true

Size: 727 Bytes

Versions: 5

Compression:

Stored size: 727 Bytes

Contents

class Telegram

  require 'uri'
  require 'net/http'

  def sendMessage(message, channel)

    uri = URI "#{CONFIG[:telegram][:bot_path]}#{CONFIG[:telegram][:bot_token]}/sendMessage"
    params = {
        chat_id: CONFIG[:telegram][:chat_ids][channel],
        text: message
    }
    uri.query = URI.encode_www_form params

    res = Net::HTTP.get_response(uri)

  end

  def sendSticker(sticker, channel)

    uri = URI "#{CONFIG[:telegram][:bot_path]}#{CONFIG[:telegram][:bot_token]}/sendSticker"

    params = {
        chat_id: CONFIG[:telegram][:chat_ids][channel],
        sticker: CONFIG[:telegram][:stickers][sticker]
    }
    uri.query = URI.encode_www_form params

    res = Net::HTTP.get_response(uri)

  end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
digital_heroes_startkit-0.1.1.4 lib/telegram.rb
digital_heroes_startkit-0.1.1.3 lib/telegram.rb
digital_heroes_startkit-0.1.1.2 lib/telegram.rb
digital_heroes_startkit-0.1.1.1 lib/telegram.rb
digital_heroes_startkit-0.1.1 lib/telegram.rb