lib/firetower/session.rb in firetower-0.0.4 vs lib/firetower/session.rb in firetower-0.0.5
- old
+ new
@@ -1,19 +1,22 @@
+require 'firetower/accounts'
+
module Firetower
module Plugins
end
class Session
include ::Firetower::Plugins
-
include HookR::Hooks
+ include Firetower::Accounts
+ include Firetower::Rooms
- attr_reader :accounts
attr_reader :connections
attr_reader :subscribed_rooms
attr_reader :kind
attr_reader :default_room
+ attr_reader :ignore_list
attr_accessor :logger
define_hook :startup, :session
define_hook :connect, :session, :account
@@ -23,13 +26,11 @@
define_hook :leave, :session, :room
define_hook :disconnect, :session, :account
define_hook :shutdown, :session
def initialize(kind=:command, options={})
- @accounts = Hash.new do |hash, subdomain|
- raise "Unknown subdomain '#{subdomain}'"
- end
+ @ignore_list = []
@connections = Hash.new do |hash, subdomain|
connection =
if accounts[subdomain].ssl?
connection = Net::HTTP.new("#{subdomain}.campfirenow.com", Net::HTTP.https_default_port)
connection.use_ssl = true
@@ -43,24 +44,18 @@
@subscribed_rooms = []
@kind = kind
@logger = options.fetch(:logger) { ::Logger.new($stderr) }
end
- # Declare an account
- def account(subdomain, token, options={})
- accounts[subdomain] = Account.new(subdomain, token, self, options)
+ def ignore(*names)
+ @ignore_list.concat names
end
-
# Enable a plugin or extension
def use(class_or_instance, *args)
case class_or_instance
when Class then add_listener(class_or_instance.new(*args))
else add_listener(class_or_instance)
end
- end
-
- def join(subdomain, room_name)
- @subscribed_rooms << accounts[subdomain].rooms[room_name]
end
# Set default room
def default(subdomain, room_name)
@default_room = accounts[subdomain].rooms[room_name]