Class: Feedig::Session

Inherits:
Net::IRC::Server::Session
  • Object
show all
Defined in:
lib/feedig/session.rb

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ Session

Returns a new instance of Session.



16
17
18
# File 'lib/feedig/session.rb', line 16

def initialize(*args)
  super
end

Instance Method Details

#channelsObject



12
13
14
# File 'lib/feedig/session.rb', line 12

def channels
  ['#notification']
end

#clientObject



20
21
22
23
24
25
# File 'lib/feedig/session.rb', line 20

def client
  @client ||= YAML.load_file('./lib/feedig/resources.yml').inject({}) { |hash, (name, url)|
                hash[name] = Feedzirra::Feed.fetch_and_parse url
                hash
              }
end

#on_disconnectedObject



27
28
29
# File 'lib/feedig/session.rb', line 27

def on_disconnected
  @retrieve_thread.kill rescue nil
end

#on_user(m) ⇒ Object



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/feedig/session.rb', line 31

def on_user(m)
  super

  channels.each { |channel| post @nick, JOIN, channel }

  client.each_pair do |name, feed|
    post(
      "RECENT",
      PRIVMSG,
      "#notification",
      "\0035#{name}:\017 \00314#{feed.entries[0].title} [ #{feed.entries[0].url} ] #{feed.entries[0].last_modified}\017"
    )
  end

  @retrieve_thread = Thread.start do
    loop do
      retrieve @opts.interval
    end
  end
end

#server_versionObject



8
9
10
# File 'lib/feedig/session.rb', line 8

def server_version
  Feedig::VERSION
end