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, :text 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) # Text @text = @message.text end class << self def SetWebhook(url) uri = URI("https://api.telegram.org/bot#{ENV['telegram_bot_token']}/setWebhook?url=#{url}") Net::HTTP.get(uri) end end end end