Sha256: 363cab3deeb885bc17d57ce9d77705f9f4a2a3ac1d3e9e6f75dfb002a764e34b

Contents?: true

Size: 963 Bytes

Versions: 20

Compression:

Stored size: 963 Bytes

Contents

require 'net/http'

namespace :bot do
  namespace :kik do

    desc "Update a bot config"
    task :configure do
      uri = URI.parse("https://api.kik.com/v1/config")

      bot_user = ENV['KIK_BOT_USER']
      bot_token = ENV['KIK_TOKEN']

      request = Net::HTTP::Post.new(uri.request_uri, initheader = { "Content-Type" => "application/json" })
      request.basic_auth bot_user, bot_token
      request.body = {
        webhook: "#{ENV['CALLBACK_URL']}?bot_username=#{bot_user}",
        features: {
          manuallySendReadReceipts: false,
          receiveReadReceipts: false,
          receiveDeliveryReceipts: false,
          receiveIsTyping: false
        }
      }.to_json

      http = Net::HTTP.new(uri.host, uri.port)
      http.use_ssl = (uri.scheme == "https")
      response = http.request(request)

      if response.code == "200"
        puts "Configured okay!"
      else
        puts "Error: #{response.body}"
      end
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
bot-0.0.46 lib/tasks/bot_builder_tasks.rake
bot-0.0.45 lib/tasks/bot_builder_tasks.rake
bot-0.0.44 lib/tasks/bot_builder_tasks.rake
bot-0.0.43 lib/tasks/bot_builder_tasks.rake
bot-0.0.42 lib/tasks/bot_builder_tasks.rake
bot-0.0.41 lib/tasks/bot_builder_tasks.rake
bot-0.0.40 lib/tasks/bot_builder_tasks.rake
bot-0.0.39 lib/tasks/bot_builder_tasks.rake
bot-0.0.38 lib/tasks/bot_builder_tasks.rake
bot-0.0.37 lib/tasks/bot_builder_tasks.rake
bot-0.0.35 lib/tasks/bot_builder_tasks.rake
bot-0.0.34 lib/tasks/bot_builder_tasks.rake
bot-0.0.33 lib/tasks/bot_builder_tasks.rake
bot-0.0.32 lib/tasks/bot_builder_tasks.rake
bot-0.0.31 lib/tasks/bot_builder_tasks.rake
bot-0.0.30 lib/tasks/bot_builder_tasks.rake
bot-0.0.29 lib/tasks/bot_builder_tasks.rake
bot-0.0.28 lib/tasks/bot_builder_tasks.rake
bot-0.0.27 lib/tasks/bot_builder_tasks.rake
bot-0.0.26 lib/tasks/bot_builder_tasks.rake