Sha256: 734472ca8fef7d11894813631440681ddb9b52146326722f3932c38f750e4d2d

Contents?: true

Size: 1.16 KB

Versions: 1

Compression:

Stored size: 1.16 KB

Contents

require_relative "./wire"
require "json"

TeBot::Wire.class_eval do
  sender :text do |chat_id, message|
    make_request("sendMessage", body: {chat_id: chat_id, text: message}.to_json)
  end

  # this is using MarkdownV2 https://core.telegram.org/bots/api#markdownv2-style
  sender :markdown do |chat_id, message|
    make_request("sendMessage", body: {chat_id: chat_id, text: message, parse_mode: "MarkdownV2"}.to_json)
  end

  sender :photo do |chat_id, message|
    make_request("sendPhoto", body: message.merge({chat_id: chat_id}).to_json)
  end

  sender :audio do |chat_id, message|
    make_request("sendAudio", body: message.merge({chat_id: chat_id}).to_json)
  end

  sender :document do |chat_id, message|
    make_request("sendDocument", body: message.merge({chat_id: chat_id}).to_json)
  end

  sender :video do |chat_id, message|
    make_request("sendVideo", body: message.merge({chat_id: chat_id}).to_json)
  end

  sender :animation do |chat_id, message|
    make_request("sendAnimation", body: message.merge({chat_id: chat_id}).to_json)
  end

  sender :voice do |chat_id, message|
    make_request("sendVoice", body: message.merge({chat_id: chat_id}).to_json)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
te_bot-0.4.0 lib/te_bot/sender_options.rb