lib/boty/session.rb in boty-0.0.4 vs lib/boty/session.rb in boty-0.0.6
- old
+ new
@@ -1,21 +1,14 @@
require "json"
require "net/http"
module Boty
class Session
- SLACK_RTM_START_URL = "https://%{domain}.slack.com/api/rtm.start?"+
- "token=%{token}&"+
- "simple_latest=true&no_unreads=true"
- private_constant :SLACK_RTM_START_URL
-
attr_reader :bot
attr_writer :verbose
- def initialize(slack_domain = ENV["SLACK_COMPANY"], verbose: false)
- @rtm_start_url = SLACK_RTM_START_URL.sub "%{domain}", slack_domain
- @rtm_start_url = @rtm_start_url.sub "%{token}", ENV["SLACK_BOT_API_TOKEN"]
+ def initialize(verbose: false)
@verbose = verbose
end
def start(&block)
EM.run do
@@ -41,10 +34,10 @@
stuff.each do |printable| talker.call printable end
end
def login
debug "logging in against slack right now"
- @slack_info = JSON.parse Net::HTTP.get(URI @rtm_start_url)
+ @slack_info = Slack.rtm.start
debug "yep! logged in!"
@session_url = @slack_info["url"]
end
def initialize_bot(&block)