Sha256: c6ff1c9503fb1f4ea7e234e79cb5687e5014e2a8f8e4dd2c70b615451e1a6987
Contents?: true
Size: 1.61 KB
Versions: 1
Compression:
Stored size: 1.61 KB
Contents
require 'rest-client' module Bot module Adapter class Kik < Base AUTH_URL = "https://auth.kik.com/verification/v1/check".freeze MESSAGING_URL = "https://engine.apikik.com/api/v1/message".freeze PROFILE_URL = 'https://api.kik.com/v1/user'.freeze def send_messages(messages, from) Rails.logger.error "\n\n\nSending:\n" Rails.logger.error messages.to_json Rails.logger.error "\n\n\n" RestClient::Request.execute({ method: :post, user: config(from)[:bot_user], password: config(from)[:bot_token], url: MESSAGING_URL, payload: { messages: messages }.to_json, headers: { content_type: :json } }) rescue Exception => e binding.pry Rails.logger.error "\n\n\nError:\n" Rails.logger.error e.response Rails.logger.error "\n\n\n" raise e end def get_profile_image(username, as_user) profile = get_profile(username, as_user) profile['profilePicUrl'] || '' end def verify_signature(signature, body, from) digest = OpenSSL::Digest.new('sha1') key = config(from)[:bot_token] signature == OpenSSL::HMAC.hexdigest(digest, key, body).upcase end protected def get_profile(username, from) response = RestClient::Request.execute( method: :get, url: "#{PROFILE_URL}/#{username}", user: config(from)[:bot_user], password: config(from)[:bot_token], headers: { content_type: :json } ) JSON.parse(response) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
bot-0.0.39 | lib/bot/adapters/kik.rb |