Class: Atig::Channel::Timeline
- Includes:
- Util
- Defined in:
- lib/atig/channel/timeline.rb
Instance Method Summary collapse
- #channel_name ⇒ Object
-
#initialize(context, gateway, db) ⇒ Timeline
constructor
A new instance of Timeline.
- #on_invite(api, nick) ⇒ Object
- #on_kick(api, nick) ⇒ Object
- #on_who(&f) ⇒ Object
Methods included from ExceptionUtil
Constructor Details
#initialize(context, gateway, db) ⇒ Timeline
Returns a new instance of Timeline.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/atig/channel/timeline.rb', line 12 def initialize(context, gateway, db) super @log = context.log @channel.notify "Client options: #{context.opts.marshal_dump.inspect}" # つないだときに発言がないとさみしいので db.statuses.find_all(:limit=>50).reverse_each do|entry| case entry.source when :timeline, :me @channel. entry end end # git clone した状態から動かしていたら常に最新版のチェック daemon do log :info,"check update" = UpdateChecker.latest unless .empty? @channel.notify "\002New version is available.\017 run 'git pull'." [0, 3].each do |m| @channel.notify " \002#{m[/.+/]}\017" end @channel.notify(" ... and more. check it: http://mzp.github.com/atig/") if .size > 3 end sleep (3*60*60) end if UpdateChecker.git_repos? db.statuses.listen do|entry| if db.followings.include?(entry.user) or entry.source == :timeline or entry.source == :user_stream or entry.source == :me then @channel. entry end end @channel.send :join, db.followings.users db.followings.listen do|kind, users| @channel.send(kind, users) if @channel.respond_to?(kind) end end |
Instance Method Details
#channel_name ⇒ Object
71 |
# File 'lib/atig/channel/timeline.rb', line 71 def channel_name; "#twitter" end |
#on_invite(api, nick) ⇒ Object
56 57 58 59 |
# File 'lib/atig/channel/timeline.rb', line 56 def on_invite(api, nick) api.post("friendships/create/#{nick}") @db.followings.invalidate end |
#on_kick(api, nick) ⇒ Object
61 62 63 64 |
# File 'lib/atig/channel/timeline.rb', line 61 def on_kick(api, nick) api.post("friendships/destroy/#{nick}") @db.followings.invalidate end |
#on_who(&f) ⇒ Object
66 67 68 69 |
# File 'lib/atig/channel/timeline.rb', line 66 def on_who(&f) return unless f @db.followings.users.each(&f) end |