Class: Atig::Command::User
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) ⇒ User
Returns a new instance of User.
9
|
# File 'lib/atig/command/user.rb', line 9
def initialize(*args); super end
|
Instance Method Details
#action(target, mesg, command, args) ⇒ Object
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
|
# File 'lib/atig/command/user.rb', line 12
def action(target, mesg, command, args)
if args.empty?
yield "/me #{command} <NICK> [<NUM>]"
return
end
nick, num,*_ = args
count = 20 unless (1..200).include?(count = num.to_i)
api.delay(0) do|t|
begin
statuses = t.get("statuses/user_timeline",
{ :count => count, :screen_name => nick})
statuses.reverse_each do|status|
db.statuses.transaction do|d|
d.add :status => status, :user => status.user, :source => :user
end
end
db.statuses.
find_by_screen_name(nick, :limit=>count).
reverse_each do|entry|
gateway[target].message entry, Net::IRC::Constants::NOTICE
end
rescue Twitter::APIFailed => e
yield e.to_s
end
end
end
|
#command_name ⇒ Object
10
|
# File 'lib/atig/command/user.rb', line 10
def command_name; %w(user u) end
|