Class: Net::IRC::MalaFav

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

Instance Method Summary collapse

Instance Method Details

#main_channelObject



69
70
71
# File 'lib/net/irc/mala.rb', line 69

def main_channel
  "#malastream"
end

#on_new_threadObject



73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# File 'lib/net/irc/mala.rb', line 73

def on_new_thread
  EM.run do
    api = "http://api.ma.la/home_timeline/stream/event"
    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



65
66
67
# File 'lib/net/irc/mala.rb', line 65

def server_name
  "malastream"
end