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
40
41
42
43
44
45
46
47
48
|
# File 'lib/atig/command/search.rb', line 13
def action(target, mesg, command, args)
if args.empty?
yield "/me #{command} [option...] blah blah"
return
end
q = mesg.sub(/^#{command}\s+/, '')
opts = { :q => q }
while /^:(?:(lang)=(\w+))/ =~ args.first
opts[$1] = $2
q.sub!(/^#{args.first}\W+/, "")
args.shift
end
statuses = api.search.get('search', opts).results
if statuses.empty?
yield "\"#{q}\": not found. options=#{opts.inspect} (#{res['completed_in']} sec.)"
return
end
statuses.reverse_each do|status|
db.statuses.transaction do|d|
user = .make('id' => status.from_user_id,
'screen_name' => status.from_user)
d.add :status => status, :user => user, :source => :user
end
end
statuses.reverse_each do|status|
entry = db.statuses.find_by_status_id(status.id)
entry.status = entry.status.merge('text' =>
"#{entry.status.text} (#{entry.status.created_at})")
gateway[target].message entry, Net::IRC::Constants::NOTICE
end
end
|