require 'net/http' require 'telegram/replies' require 'telegram/params' module Telegram class Bot include Telegram::Reply attr_reader :user, :forward_from, :chat, :forward_from_chat, :message def initialize(params) # User @user = Telegram::Params::From.new(params) @forward_from = Telegram::Params::ForwardFrom.new(params) # Chat @chat = Telegram::Params::Chat.new(params) @forward_from_chat = Telegram::Params::ForwardChat.new(params) # Message @message = Telegram::Params::Message.new(params) end class << self def SetWebhook(url) uri = URI("https://api.telegram.org/bot#{ENV['telegram_token']}/setWebhook?url=#{url}") Net::HTTP.get(uri) end end end end