Class: Atig::Command::Retweet
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) ⇒ Retweet
Returns a new instance of Retweet.
13
14
15
16
|
# File 'lib/atig/command/retweet.rb', line 13
def initialize(*args)
super
@bitly = Bitly.no_login @log
end
|
Instance Method Details
#action(target, mesg, command, args) ⇒ Object
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
# File 'lib/atig/command/retweet.rb', line 43
def action(target, mesg, command, args)
if args.empty?
yield "/me #{command} <ID_or_SCREEN_NAME> blah blah"
return
end
tid = args.first
if status = Info.find_status(db, tid) then
if args.size >= 2
= mesg.split(" ", 3)[2] + " "
(target, , status)
else
(target, status)
end
else
yield "No such ID : #{tid}"
end
end
|
#command_name ⇒ Object
18
|
# File 'lib/atig/command/retweet.rb', line 18
def command_name; %w(ort rt retweet qt) end
|
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
# File 'lib/atig/command/retweet.rb', line 20
def (target, , entry)
screen_name = "@#{entry.user.screen_name}"
text = "#{.strip} RT #{screen_name}: #{entry.status.text}"
chars = text.each_char.to_a
if chars.size > 140 then
url = @bitly.shorten "http://twitter.com/#{entry.user.screen_name}/status/#{entry.status.id}"
text = chars[0,140-url.size-1].join('') + ' ' + url
end
q = gateway.output_message(:status => text)
api.delay(0) do|t|
ret = t.post("statuses/update", q)
gateway.update_status ret,target, "RT to #{entry.user.screen_name}: #{entry.status.text}"
end
end
|
36
37
38
39
40
41
|
# File 'lib/atig/command/retweet.rb', line 36
def (target, entry)
api.delay(0) do|t|
ret = t.post("statuses/retweet/#{entry.status.id}")
gateway.update_status ret,target, "RT to #{entry.user.screen_name}: #{entry.status.text}"
end
end
|