bot.rb
# Takes Telegram API method and json hash

Takes Telegram API method and json hash
Takes Telegram API method and json hash
def send_message(api_method, message_data)
      uri = URI("#{@api_url + @token}/#{api_method}")
      req = Net::HTTP::Post.new(uri)
      req['Content-Type'] = 'application/json'
      req.body = message_data.to_json
      resp = Net::HTTP.start(uri.host, uri.port,
                             use_ssl: uri.scheme == 'https') do |http|
        http.request req
      end
      JSON.parse(resp.body, symbolize_names: true)
    end
def send_message ( api_method , message_data ) uri = URI ( "#{@api_url + @token}/#{api_method}" ) req = Net :: HTTP :: Post . new ( uri ) req [ 'Content-Type' ] = 'application/json' req . body = message_data . to_json resp = Net :: HTTP . start ( uri . host , uri . port , use_ssl : uri . scheme == 'https' ) do | http | http . request req end JSON . parse ( resp . body , symbolize_names : true ) end
Takes Telegram API method and json hash
Takes Telegram API method and json hash
api_method
<not_specific>
message_data
<not_specific>