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