Class: Net::IRC::Mala

Inherits:
AsyncSession
  • Object
show all
Defined in:
lib/net/irc/mala.rb

Instance Method Summary collapse

Instance Method Details

#main_channelObject



40
41
42
# File 'lib/net/irc/mala.rb', line 40

def main_channel
  "#malastream"
end

#on_new_threadObject



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/net/irc/mala.rb', line 44

def on_new_thread
  EM.run do
    api = "http://api.ma.la/home_timeline/stream"
    source = EventMachine::EventSource.new(api)
    source.message do |message|
      begin
        status = JSON.parse(message)
        tweet = status["text"]
        screen_name = status['user']['screen_name']
        post screen_name, PRIVMSG, main_channel, tweet
      rescue => ex
        STDERR.puts "error: #{ex.inspect}"
        next
      end
    end
    source.start # Start listening
  end
end

#server_nameObject



36
37
38
# File 'lib/net/irc/mala.rb', line 36

def server_name
  "malastream"
end