Sha256: b7959e703949c719987a1436b1d98e280e778921481f9643044f48ecd2e8757a

Contents?: true

Size: 1.25 KB

Versions: 2

Compression:

Stored size: 1.25 KB

Contents

require_relative "./wire"
require "json"

TeBot::Wire.class_eval do
  sender :text do |conn, chat_id, message|
    conn.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 |conn, chat_id, message|
    conn.make_request("sendMessage", body: {chat_id: chat_id, text: message, parse_mode: "MarkdownV2"}.to_json)
  end

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

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

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

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

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

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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
te_bot-0.3.0 lib/te_bot/sender_options.rb
te_bot-0.2.0 lib/te_bot/sender_options.rb