Class: Atig::Gateway::Session

Inherits:
Net::IRC::Server::Session
  • Object
show all
Includes:
Util
Defined in:
lib/atig/gateway/session.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from ExceptionUtil

daemon, safe

Constructor Details

#initialize(*args) ⇒ Session

Returns a new instance of Session.



41
42
43
44
# File 'lib/atig/gateway/session.rb', line 41

def initialize(*args)
  super
  @on_message = nil
end

Class Method Details

.class_writer(*ids) ⇒ Object



28
29
30
31
32
33
34
35
36
# File 'lib/atig/gateway/session.rb', line 28

def self.class_writer(*ids)
  ids.each do|id|
    module_eval <<END
def #{id}=(arg)
  @@#{id} = arg
end
END
  end
end

Instance Method Details

#[](name) ⇒ Object



71
72
73
# File 'lib/atig/gateway/session.rb', line 71

def [](name)
  @channels[name]
end

#channel(name, opts = {}) ⇒ Object



59
60
61
62
63
64
65
66
67
68
69
# File 'lib/atig/gateway/session.rb', line 59

def channel(name,opts={})
  opts.update(:session => self,
              :name    => name,
              :filters => @ifilters,
              :prefix  => @prefix,
              :nick    => @nick,
              :opts    => @opts)
  channel = Channel.new opts
  @channels[name] = channel
  channel
end

#ctcp_action(*commands, &block) ⇒ Object



79
80
81
82
83
# File 'lib/atig/gateway/session.rb', line 79

def ctcp_action(*commands, &block)
  commands.each do |command|
    @ctcp_actions[command] = block
  end
end

#output_message(query) ⇒ Object



75
76
77
# File 'lib/atig/gateway/session.rb', line 75

def output_message(query)
  @ofilters.inject(query) {|x, f| f.call x }
end

#post(*args) ⇒ Object



46
47
48
# File 'lib/atig/gateway/session.rb', line 46

def post(*args)
  super
end

#prefix(u) ⇒ Object



85
86
87
88
89
90
91
92
93
# File 'lib/atig/gateway/session.rb', line 85

def prefix(u)
  nick = u.screen_name
  nick = "@#{nick}" if @opts.athack
  user = "id=%.9d" % u.id
  host = "twitter"
  host += "/protected" if u.protected

  Net::IRC::Prefix.new("#{nick}!#{user}@#{host}")
end

#topic(entry) ⇒ Object



95
96
97
# File 'lib/atig/gateway/session.rb', line 95

def topic(entry)
  @channels.each{|_, ch| ch.topic entry }
end

#update_status(ret, target, msg = '') ⇒ Object



50
51
52
53
54
55
56
57
# File 'lib/atig/gateway/session.rb', line 50

def update_status(ret, target, msg='')
  @db.transaction do|db|
    db.statuses.add(:source => :me, :status => ret, :user => ret.user )
  end

  msg = "(#{msg})" unless msg.empty?
  self[target].notify "Status updated #{msg}"
end