Class: Atig::Agent::Dm
Instance Method Summary collapse
-
#initialize(context, api, db) ⇒ Dm
constructor
A new instance of Dm.
Methods included from ExceptionUtil
Constructor Details
#initialize(context, api, db) ⇒ Dm
Returns a new instance of Dm.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/atig/agent/dm.rb', line 9 def initialize(context, api, db) return if context.opts.stream @log = context.log @api = api @prev = nil log :info, "initialize" @api.repeat(600) do|t| q = { :count => 200 } if @prev q.update :since_id => @prev else q.update :count => 1 end dms = t.get("direct_messages", q) log :debug, "You have #{dms.size} dm." dms.reverse_each do|dm| db.dms.transaction do|d| d.add :status => dm, :user => dm.sender end end end end |