jugyo-termtter 0.7.7 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Manifest.txt +10 -0
- data/Rakefile +25 -0
- data/bin/kill_termtter +22 -0
- data/lib/filter/en2ja.rb +2 -0
- data/lib/filter/expand-tinyurl.rb +2 -0
- data/lib/filter/fib.rb +2 -0
- data/lib/filter/ignore.rb +2 -0
- data/lib/filter/reverse.rb +2 -0
- data/lib/plugin/april_fool.rb +15 -0
- data/lib/plugin/bomb.rb +11 -8
- data/lib/plugin/confirm.rb +9 -24
- data/lib/plugin/cool.rb +8 -10
- data/lib/plugin/english.rb +2 -0
- data/lib/plugin/erb.rb +9 -9
- data/lib/plugin/favorite.rb +2 -0
- data/lib/plugin/fib.rb +2 -0
- data/lib/plugin/filter.rb +41 -36
- data/lib/plugin/follow.rb +36 -20
- data/lib/plugin/graduatter.rb +2 -0
- data/lib/plugin/group.rb +32 -34
- data/lib/plugin/growl.rb +3 -1
- data/lib/plugin/hatebu.rb +46 -44
- data/lib/plugin/history.rb +16 -4
- data/lib/plugin/keyword.rb +2 -0
- data/lib/plugin/log.rb +32 -32
- data/lib/plugin/modify_arg_hook_sample.rb +7 -0
- data/lib/plugin/msagent.rb +2 -0
- data/lib/plugin/multi_reply.rb +2 -0
- data/lib/plugin/notify-send.rb +2 -0
- data/lib/plugin/otsune.rb +17 -13
- data/lib/plugin/outputz.rb +2 -0
- data/lib/plugin/pause.rb +3 -0
- data/lib/plugin/plugin.rb +29 -24
- data/lib/plugin/post_exec_hook_sample.rb +9 -0
- data/lib/plugin/pre_exec_hook_sample.rb +9 -0
- data/lib/plugin/primes.rb +2 -0
- data/lib/plugin/quicklook.rb +2 -0
- data/lib/plugin/reblog.rb +27 -25
- data/lib/plugin/reload.rb +3 -3
- data/lib/plugin/say.rb +2 -0
- data/lib/plugin/scrape.rb +35 -37
- data/lib/plugin/screen.rb +2 -0
- data/lib/plugin/shell.rb +12 -2
- data/lib/plugin/sl.rb +42 -25
- data/lib/plugin/spam.rb +2 -0
- data/lib/plugin/standard_plugins.rb +99 -49
- data/lib/plugin/stdout.rb +2 -0
- data/lib/plugin/system_status.rb +7 -15
- data/lib/plugin/translation.rb +2 -0
- data/lib/plugin/update_editor.rb +21 -21
- data/lib/plugin/uri-open.rb +2 -0
- data/lib/plugin/wassr_post.rb +10 -9
- data/lib/plugin/yhara.rb +16 -25
- data/lib/plugin/yonda.rb +2 -0
- data/lib/termtter.rb +44 -24
- data/lib/termtter/api.rb +2 -0
- data/lib/termtter/client.rb +140 -56
- data/lib/termtter/command.rb +15 -5
- data/lib/termtter/connection.rb +3 -1
- data/lib/termtter/hook.rb +18 -0
- data/lib/termtter/status.rb +2 -0
- data/lib/termtter/task.rb +16 -0
- data/lib/termtter/task_manager.rb +116 -0
- data/lib/termtter/twitter.rb +15 -4
- data/lib/termtter/user.rb +13 -0
- data/run_termtter.rb +1 -0
- data/test/test_termtter.rb +2 -0
- metadata +14 -3
data/lib/plugin/primes.rb
CHANGED
data/lib/plugin/quicklook.rb
CHANGED
data/lib/plugin/reblog.rb
CHANGED
@@ -1,32 +1,34 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
|
1
3
|
require 'rubygems'
|
2
4
|
require 'tumblr'
|
3
5
|
|
4
6
|
module Termtter::Client
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
7
|
+
register_command(
|
8
|
+
:name => :reblog, :aliases => [],
|
9
|
+
:exec_proc => proc {|arg|
|
10
|
+
if arg =~ /^reblog\s+(\d+)(.*)$/
|
11
|
+
id = $1.strip
|
12
|
+
comment = $2.strip
|
13
|
+
statuses = public_storage[:log].select { |s| s.id == id }
|
14
|
+
unless statuses.empty?
|
15
|
+
status = statuses.first
|
16
|
+
else
|
17
|
+
status = t.show(id).first
|
18
|
+
end
|
19
|
+
|
20
|
+
Tumblr::API.write(configatron.plugins.reblog.email, configatron.plugins.reblog.password) do
|
21
|
+
quote("#{status.text}", "<a href=\"http://twitter.com/#{status.user_screen_name}/status/#{status.id}\">Twitter / #{status.user_name}</a>")
|
22
|
+
end
|
23
|
+
end
|
24
|
+
},
|
25
|
+
:completion_proc => proc {|cmd, args|
|
26
|
+
if args =~ /^(\d*)$/
|
27
|
+
find_status_id_candidates $1, "#{cmd} %s"
|
28
|
+
end
|
29
|
+
},
|
30
|
+
:help => ['reblog ID', 'Tumblr Reblog a status']
|
31
|
+
)
|
30
32
|
end
|
31
33
|
|
32
34
|
# reblog.rb
|
data/lib/plugin/reload.rb
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
|
3
|
+
Termtter::Client.register_macro :reload, "eval exec $0"
|
data/lib/plugin/say.rb
CHANGED
data/lib/plugin/scrape.rb
CHANGED
@@ -1,43 +1,41 @@
|
|
1
|
-
|
2
|
-
def self.scrape_group(group, t)
|
3
|
-
members = configatron.plugins.group.groups[group] || []
|
4
|
-
members.map {|member|
|
5
|
-
t.get_user_timeline(member)
|
6
|
-
}.flatten
|
7
|
-
end
|
8
|
-
|
9
|
-
def self.scrape_groups(t)
|
10
|
-
groups = configatron.plugins.group.groups
|
11
|
-
groups.map {|group|
|
12
|
-
scrape_group(group, t)
|
13
|
-
}.flatten
|
14
|
-
end
|
15
|
-
|
16
|
-
add_help 'scrape_group GROUPNAME', 'Get the group timeline'
|
17
|
-
add_help 'scrape_groups', 'Get all groups timeline'
|
1
|
+
# -*- coding: utf-8 -*-
|
18
2
|
|
19
|
-
|
20
|
-
group_name = m[1].to_sym
|
21
|
-
statuses = scrape_group(group_name, t)
|
22
|
-
call_hooks(statuses, :pre_filter, t)
|
23
|
-
puts "done"
|
24
|
-
end
|
25
|
-
|
26
|
-
add_command /^(?:scrape_groups)\s*$/ do |m, t|
|
27
|
-
statuses = scrape_groups(t)
|
28
|
-
call_hooks(statuses, :pre_filter, t)
|
29
|
-
puts "done"
|
30
|
-
end
|
3
|
+
module Termtter::Client
|
31
4
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
configatron.plugins.group.groups.keys
|
38
|
-
else
|
39
|
-
%w(scrape_group scrape_groups).grep(/^#{Regexp.quote input}/)
|
5
|
+
def self.scrape_members(members)
|
6
|
+
statuses = []
|
7
|
+
members.each_with_index do |member, index|
|
8
|
+
puts "member #{index+1}/#{members.size} #{member}"
|
9
|
+
statuses += Termtter::API.twitter.get_user_timeline(member)
|
40
10
|
end
|
11
|
+
statuses
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.scrape_group(group)
|
15
|
+
members = configatron.plugins.group.groups[group] || []
|
16
|
+
scrape_members(members)
|
41
17
|
end
|
42
18
|
|
19
|
+
register_command(
|
20
|
+
:name => :scrape_group,
|
21
|
+
:exec_proc => proc{ |args|
|
22
|
+
groups = args.split(' ').map{|g| g.to_sym}
|
23
|
+
if groups.include? :all
|
24
|
+
groups = configatron.plugins.group.groups.keys
|
25
|
+
puts "get all groups..."
|
26
|
+
end
|
27
|
+
members = []
|
28
|
+
groups.each do |group|
|
29
|
+
members += configatron.plugins.group.groups[group]
|
30
|
+
end
|
31
|
+
statuses = scrape_members(members.uniq.compact.sort)
|
32
|
+
call_hooks(statuses, :pre_filter)
|
33
|
+
},
|
34
|
+
:completion_proc => proc {|cmd, args|
|
35
|
+
arg = args.split(' ').last
|
36
|
+
prefix = args.split(' ')[0..-2].join(' ')
|
37
|
+
find_group_candidates arg, "#{cmd} #{prefix} %s"
|
38
|
+
},
|
39
|
+
:help => ['scrape_group GROUPNAME(S)', 'Get the group timeline']
|
40
|
+
)
|
43
41
|
end
|
data/lib/plugin/screen.rb
CHANGED
data/lib/plugin/shell.rb
CHANGED
@@ -1,4 +1,14 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
|
1
3
|
module Termtter::Client
|
2
|
-
|
3
|
-
|
4
|
+
register_command :name => :shell, :aliases => [:sh],
|
5
|
+
:help => ['shell,sh', 'Start your shell'],
|
6
|
+
:exec_proc => proc {|args|
|
7
|
+
begin
|
8
|
+
pause
|
9
|
+
system ENV['SHELL'] || ENV['COMSPEC']
|
10
|
+
ensure
|
11
|
+
resume
|
12
|
+
end
|
13
|
+
}
|
4
14
|
end
|
data/lib/plugin/sl.rb
CHANGED
@@ -1,31 +1,48 @@
|
|
1
|
-
|
2
|
-
public_storage[:current] = ''
|
1
|
+
# -*- coding: utf-8 -*-
|
3
2
|
|
4
|
-
|
3
|
+
module Termtter
|
5
4
|
|
6
|
-
|
7
|
-
add_macro /^pwd\s*$/, 'eval public_storage[:current]'
|
5
|
+
module Client
|
8
6
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
end
|
7
|
+
public_storage[:current] = ''
|
8
|
+
public_storage[:orig_prompt] = configatron.prompt
|
9
|
+
configatron.prompt = "~/ #{public_storage[:orig_prompt]}"
|
13
10
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
11
|
+
register_command(
|
12
|
+
:name => :sl, :aliases => [],
|
13
|
+
:exec_proc => proc {|arg| system("sl") },
|
14
|
+
:help => ['sl', 'The train pass in front of your screen']
|
15
|
+
)
|
16
|
+
|
17
|
+
register_command(
|
18
|
+
:name => :pwd, :aliases => [],
|
19
|
+
:exec_proc => proc {|arg| public_storage[:current] },
|
20
|
+
:help => ['pwd', 'Show current direcroty']
|
21
|
+
)
|
22
|
+
|
23
|
+
register_command(
|
24
|
+
:name => :ls, :aliases => [],
|
25
|
+
:exec_proc => proc {|arg|
|
26
|
+
call_commands("list #{arg.empty? ? public_storage[:current] : arg}", API.twitter)
|
27
|
+
},
|
28
|
+
:completion_proc => proc {|cmd, args|
|
29
|
+
find_user_candidates args, "#{cmd} %s"
|
30
|
+
},
|
31
|
+
:help => ['ls', 'Show list in current directory']
|
32
|
+
)
|
33
|
+
|
34
|
+
register_command(
|
35
|
+
:name => :cd, :aliases => [],
|
36
|
+
:exec_proc => proc {|arg|
|
37
|
+
public_storage[:current] =
|
38
|
+
(arg.nil? || /\~/ =~ arg) ? '' : arg
|
39
|
+
configatron.prompt = "~/#{public_storage[:current]} #{public_storage[:orig_prompt]}"
|
40
|
+
},
|
41
|
+
:completion_proc => proc {|cmd, args|
|
42
|
+
find_user_candidates args, "#{cmd} %s"
|
43
|
+
},
|
44
|
+
:help => ['cd USER', 'Change current directory']
|
45
|
+
)
|
30
46
|
end
|
31
47
|
end
|
48
|
+
|
data/lib/plugin/spam.rb
CHANGED
@@ -1,61 +1,108 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
|
1
3
|
require 'erb'
|
2
4
|
|
3
5
|
module Termtter::Client
|
4
6
|
|
5
7
|
# standard commands
|
6
8
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
9
|
+
register_command(
|
10
|
+
:name => :update, :aliases => [:u],
|
11
|
+
:exec_proc => proc {|arg|
|
12
|
+
text = ERB.new(arg).result(binding).gsub(/\n/, ' ')
|
13
|
+
Termtter::API.twitter.update_status(text)
|
11
14
|
puts "=> #{text}"
|
12
|
-
|
13
|
-
|
15
|
+
},
|
16
|
+
:completion_proc => proc {|cmd, args|
|
17
|
+
if /(.*)@([^\s]*)$/ =~ args
|
18
|
+
find_user_candidates $2, "#{cmd} #{$1}@%s"
|
19
|
+
end
|
20
|
+
}
|
21
|
+
)
|
14
22
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
+
register_command(
|
24
|
+
:name => :direct, :aliases => [:d],
|
25
|
+
:exec_proc => proc {|arg|
|
26
|
+
if arg =~ /^([^\s]+)\s+(.*)\s*$/
|
27
|
+
user, text = $1, $2
|
28
|
+
Termtter::API.twitter.direct_message(user, text)
|
29
|
+
puts "=> to:#{user} message:#{text}"
|
30
|
+
end
|
31
|
+
},
|
32
|
+
:completion_proc => proc {|cmd, args|
|
33
|
+
if args =~ /^([^\s]+)$/
|
34
|
+
find_user_candidates $1, "#{cmd} %s"
|
35
|
+
end
|
36
|
+
}
|
37
|
+
)
|
23
38
|
|
24
|
-
|
25
|
-
profile
|
26
|
-
|
27
|
-
|
28
|
-
|
39
|
+
register_command(
|
40
|
+
:name => :profile, :aliases => [:p],
|
41
|
+
:exec_proc => proc {|arg|
|
42
|
+
user = Termtter::API.twitter.get_user_profile(arg)
|
43
|
+
attrs = %w[ name screen_name url description profile_image_url location protected following
|
44
|
+
friends_count followers_count statuses_count favourites_count
|
45
|
+
id time_zone created_at utc_offset notifications
|
46
|
+
]
|
47
|
+
label_width = attrs.map{|i|i.size}.max
|
48
|
+
attrs.each do |attr|
|
49
|
+
value = user.__send__(attr.to_sym)
|
50
|
+
puts "#{attr.gsub('_', ' ').rjust(label_width)}: #{value}"
|
29
51
|
end
|
30
|
-
|
31
|
-
|
52
|
+
},
|
53
|
+
:completion_proc => proc {|cmd, arg|
|
54
|
+
find_user_candidates arg, "#{cmd} %s"
|
55
|
+
}
|
56
|
+
)
|
32
57
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
58
|
+
register_command(
|
59
|
+
:name => :list, :aliases => [:l],
|
60
|
+
:exec_proc => proc {|arg|
|
61
|
+
unless arg.empty?
|
62
|
+
call_hooks(Termtter::API.twitter.get_user_timeline(arg), :list_user_timeline)
|
63
|
+
else
|
64
|
+
call_hooks(Termtter::API.twitter.get_friends_timeline(), :list_friends_timeline)
|
65
|
+
end
|
66
|
+
},
|
67
|
+
:completion_proc => proc {|cmd, arg|
|
68
|
+
find_user_candidates arg, "#{cmd} %s"
|
69
|
+
}
|
70
|
+
)
|
37
71
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
72
|
+
register_command(
|
73
|
+
:name => :search, :aliases => [:s],
|
74
|
+
:exec_proc => proc {|arg|
|
75
|
+
call_hooks(Termtter::API.twitter.search(arg), :search)
|
76
|
+
}
|
77
|
+
)
|
42
78
|
|
43
|
-
|
44
|
-
|
45
|
-
|
79
|
+
register_command(
|
80
|
+
:name => :replies, :aliases => [:r],
|
81
|
+
:exec_proc => proc {
|
82
|
+
call_hooks(Termtter::API.twitter.replies(), :replies)
|
83
|
+
}
|
84
|
+
)
|
46
85
|
|
47
|
-
|
48
|
-
|
49
|
-
|
86
|
+
register_command(
|
87
|
+
:name => :show,
|
88
|
+
:exec_proc => proc {|arg|
|
89
|
+
id = arg.gsub(/.*:/, '')
|
90
|
+
call_hooks(Termtter::API.twitter.show(id), :show)
|
91
|
+
}
|
92
|
+
)
|
50
93
|
|
51
|
-
|
52
|
-
|
53
|
-
|
94
|
+
register_command(
|
95
|
+
:name => :shows,
|
96
|
+
:exec_proc => proc {|arg|
|
97
|
+
id = arg.gsub(/.*:/, '')
|
98
|
+
call_hooks(Termtter::API.twitter.show(id, true), :show)
|
99
|
+
}
|
100
|
+
)
|
54
101
|
|
55
102
|
# TODO: Change colors when remaining_hits is low.
|
56
103
|
# TODO: Simmulate remaining_hits.
|
57
104
|
register_command(
|
58
|
-
:name => :limit, :aliases => [
|
105
|
+
:name => :limit, :aliases => [:lm],
|
59
106
|
:exec_proc => proc {|arg|
|
60
107
|
limit = Termtter::API.twitter.get_rate_limit_status
|
61
108
|
remaining_time = "%dmin %dsec" % (limit.reset_time - Time.now).divmod(60)
|
@@ -83,11 +130,22 @@ module Termtter::Client
|
|
83
130
|
)
|
84
131
|
|
85
132
|
register_command(
|
86
|
-
:name => :exit, :aliases => [
|
133
|
+
:name => :exit, :aliases => [:e],
|
87
134
|
:exec_proc => proc {|arg| exit},
|
88
135
|
:help => ['exit,e', 'Exit']
|
89
136
|
)
|
90
137
|
|
138
|
+
register_hook(
|
139
|
+
:name => :default_error_handler,
|
140
|
+
:points => [:on_error],
|
141
|
+
:exec_proc => proc {|e|
|
142
|
+
puts "Error: #{e}"
|
143
|
+
if configatron.debug == true
|
144
|
+
puts e.backtrace.join("\n")
|
145
|
+
end
|
146
|
+
}
|
147
|
+
)
|
148
|
+
|
91
149
|
add_command /^(help|h)\s*$/ do |m, t|
|
92
150
|
# TODO: migrate to use Termtter::Command#help
|
93
151
|
helps = [
|
@@ -166,7 +224,7 @@ module Termtter::Client
|
|
166
224
|
end
|
167
225
|
|
168
226
|
def self.find_user_candidates(a, b)
|
169
|
-
if a.empty?
|
227
|
+
if a.nil? || a.empty?
|
170
228
|
public_storage[:users].to_a
|
171
229
|
else
|
172
230
|
public_storage[:users].grep(/^#{Regexp.quote a}/i)
|
@@ -177,14 +235,6 @@ module Termtter::Client
|
|
177
235
|
add_completion do |input|
|
178
236
|
standard_commands = %w[exit help list pause profile update direct resume replies search show limit]
|
179
237
|
case input
|
180
|
-
when /^(list|l)?\s+(.*)/
|
181
|
-
find_user_candidates $2, "#{$1} %s"
|
182
|
-
when /^(update|u)\s+(.*)@([^\s]*)$/
|
183
|
-
find_user_candidates $3, "#{$1} #{$2}@%s"
|
184
|
-
when /^(direct|d)\s+(.*)/
|
185
|
-
find_user_candidates $2, "#{$1} %s"
|
186
|
-
when /^(profile|p)\s+(.*)/
|
187
|
-
find_user_candidates $2, "#{$1} %s"
|
188
238
|
when /^show(s)?\s+(([\w\d]+):)?\s*(.*)/
|
189
239
|
if $2
|
190
240
|
find_status_id_candidates $4, "show#{$1} #{$2}%s", $3
|