Class: Atig::Command::Thread
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) ⇒ Thread
Returns a new instance of Thread.
8
9
10
|
# File 'lib/atig/command/thread.rb', line 8
def initialize(*args)
super
end
|
Instance Method Details
#action(target, mesg, command, args) ⇒ Object
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/atig/command/thread.rb', line 14
def action(target, mesg, command, args)
if args.empty?
yield "/me #{command} <ID> [<NUM>]"
return
end
tid, num = args
count = 10 unless (1..20).include?(count = num.to_i)
if entry = Info.find_status(db, tid) then
chain(entry,count){|x|
gateway[target].message x, Net::IRC::Constants::NOTICE
}
else
yield "No such ID : #{tid}"
end
end
|
#chain(entry, count, &f) ⇒ Object
32
33
34
35
36
37
38
39
40
41
|
# File 'lib/atig/command/thread.rb', line 32
def chain(entry,count, &f)
if count <= 0 then
return
elsif id = entry.status.in_reply_to_status_id then
Info.status(db, api, id){|next_|
chain(next_, count - 1, &f)
}
end
f.call entry
end
|
#command_name ⇒ Object
12
|
# File 'lib/atig/command/thread.rb', line 12
def command_name; %w(thread) end
|