Class: Atig::Command::Reply

Inherits:
Command
  • Object
show all
Defined in:
lib/atig/command/reply.rb

Instance Attribute Summary

Attributes inherited from Command

#api, #db, #gateway, #opts

Instance Method Summary collapse

Methods inherited from Command

#find_by_tid

Constructor Details

#initialize(*args) ⇒ Reply

Returns a new instance of Reply.



8
# File 'lib/atig/command/reply.rb', line 8

def initialize(*args); super end

Instance Method Details

#action(target, mesg, command, args) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/atig/command/reply.rb', line 11

def action(target, mesg, command, args)
  if args.empty?
    yield "/me #{command} <ID_or_SCREEN_NAME> blah blah"
    return
  end

  tid = args.first
  if entry = Info.find_status(db,tid) then
    text = mesg.split(" ", 3)[2]
    name = entry.user.screen_name

    text = "@#{name} #{text}" if text.nil? or not text.include?("@#{name}")

    q = gateway.output_message(:status => text,
                               :in_reply_to_status_id => entry.status.id)

    api.delay(0) do|t|
      ret = t.post("statuses/update", q)
      gateway.update_status ret, target, "In reply to #{name}: #{entry.status.text}"
    end
  else
    yield "No such ID : #{tid}"
  end
end

#command_nameObject



9
# File 'lib/atig/command/reply.rb', line 9

def command_name; %w(mention re reply rp) end