jugyo-termtter 0.8.2 → 0.8.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +9 -0
- data/Rakefile +46 -64
- data/lib/filter/url_addspace.rb +16 -0
- data/lib/plugin/april_fool.rb +1 -1
- data/lib/plugin/bomb.rb +1 -1
- data/lib/plugin/clear.rb +14 -0
- data/lib/plugin/confirm.rb +1 -1
- data/lib/plugin/cool.rb +1 -1
- data/lib/plugin/devel.rb +13 -0
- data/lib/plugin/erb.rb +1 -1
- data/lib/plugin/filter.rb +4 -4
- data/lib/plugin/follow.rb +5 -5
- data/lib/plugin/grass.rb +27 -0
- data/lib/plugin/group.rb +8 -4
- data/lib/plugin/growl.rb +1 -1
- data/lib/plugin/hatebu.rb +2 -2
- data/lib/plugin/history.rb +9 -0
- data/lib/plugin/log.rb +14 -6
- data/lib/plugin/modify_arg_hook_sample.rb +1 -1
- data/lib/plugin/otsune.rb +2 -2
- data/lib/plugin/plugin.rb +3 -3
- data/lib/plugin/post_exec_hook_sample.rb +1 -1
- data/lib/plugin/pre_exec_hook_sample.rb +1 -1
- data/lib/plugin/reblog.rb +2 -2
- data/lib/plugin/scrape.rb +2 -2
- data/lib/plugin/shell.rb +1 -1
- data/lib/plugin/sl.rb +6 -6
- data/lib/plugin/standard_plugins.rb +62 -44
- data/lib/plugin/system_status.rb +2 -2
- data/lib/plugin/update_editor.rb +1 -1
- data/lib/plugin/wassr_post.rb +1 -1
- data/lib/plugin/yhara.rb +2 -2
- data/lib/plugin/yonda.rb +9 -9
- data/lib/termtter/client.rb +24 -7
- data/lib/termtter/command.rb +2 -2
- data/lib/termtter/hook.rb +1 -1
- data/lib/termtter/task.rb +1 -1
- data/lib/termtter/twitter.rb +51 -27
- data/lib/termtter/version.rb +1 -1
- data/spec/plugin/cool_spec.rb +10 -0
- data/spec/plugin/fib_spec.rb +16 -0
- data/spec/plugin/filter_spec.rb +18 -0
- data/spec/plugin/plugin_spec.rb +25 -0
- data/spec/plugin/shell_spec.rb +10 -0
- data/spec/plugin/spam_spec.rb +17 -0
- data/spec/plugin/standard_plugins_spec.rb +31 -0
- data/spec/spec_helper.rb +4 -0
- data/spec/termtter/client_spec.rb +175 -0
- data/spec/termtter/command_spec.rb +161 -0
- data/spec/termtter/task_manager_spec.rb +78 -0
- data/spec/termtter/task_spec.rb +22 -0
- data/spec/termtter/user_spec.rb +27 -0
- data/spec/termtter_spec.rb +43 -0
- metadata +40 -42
- data/Manifest.txt +0 -77
- data/PostInstall.txt +0 -1
- data/run_termtter.rb +0 -17
data/lib/plugin/otsune.rb
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
module Termtter::Client
|
4
4
|
register_macro(:otsune, "update @%s 頭蓋骨の中身がお気の毒です.",
|
5
5
|
:help => ['otsune {SCREENNAME}', 'update "@{SCREENNAME} 頭蓋骨の中身がお気の毒です"'],
|
6
|
-
:completion_proc =>
|
6
|
+
:completion_proc => lambda {|cmd, args|
|
7
7
|
find_user_candidates args, "#{cmd} %s"
|
8
8
|
}
|
9
9
|
)
|
@@ -12,7 +12,7 @@ end
|
|
12
12
|
module Termtter::Client
|
13
13
|
register_macro(:otsnue, "update @%s 頭蓋骨の中身がお気の毒です.",
|
14
14
|
:help => ['otsnue {SCREENNAME}', 'update @%s 頭が気の毒です.'],
|
15
|
-
:completion_proc =>
|
15
|
+
:completion_proc => lambda {|cmd, args|
|
16
16
|
find_user_candidates args, "#{cmd} %s"
|
17
17
|
}
|
18
18
|
)
|
data/lib/plugin/plugin.rb
CHANGED
@@ -8,7 +8,7 @@ module Termtter::Client
|
|
8
8
|
|
9
9
|
register_command(
|
10
10
|
:name => :plugin, :aliases => [],
|
11
|
-
:exec_proc =>
|
11
|
+
:exec_proc => lambda {|arg|
|
12
12
|
begin
|
13
13
|
result = plugin arg.strip
|
14
14
|
rescue LoadError
|
@@ -16,7 +16,7 @@ module Termtter::Client
|
|
16
16
|
puts "=> #{result.inspect}"
|
17
17
|
end
|
18
18
|
},
|
19
|
-
:completion_proc =>
|
19
|
+
:completion_proc => lambda {|cmd, args|
|
20
20
|
find_user_candidates args, "#{cmd} %s"
|
21
21
|
unless args.empty?
|
22
22
|
find_plugin_candidates args, "#{cmd} %s"
|
@@ -29,7 +29,7 @@ module Termtter::Client
|
|
29
29
|
|
30
30
|
register_command(
|
31
31
|
:name => :plugins, :aliases => [],
|
32
|
-
:exec_proc =>
|
32
|
+
:exec_proc => lambda {|arg|
|
33
33
|
puts public_storage[:plugins].sort.join("\n")
|
34
34
|
},
|
35
35
|
:help => ['plugins', 'Show list of plugins']
|
data/lib/plugin/reblog.rb
CHANGED
@@ -6,7 +6,7 @@ require 'tumblr'
|
|
6
6
|
module Termtter::Client
|
7
7
|
register_command(
|
8
8
|
:name => :reblog, :aliases => [],
|
9
|
-
:exec_proc =>
|
9
|
+
:exec_proc => lambda {|arg|
|
10
10
|
if arg =~ /^reblog\s+(\d+)(.*)$/
|
11
11
|
id = $1.strip
|
12
12
|
comment = $2.strip
|
@@ -22,7 +22,7 @@ module Termtter::Client
|
|
22
22
|
end
|
23
23
|
end
|
24
24
|
},
|
25
|
-
:completion_proc =>
|
25
|
+
:completion_proc => lambda {|cmd, args|
|
26
26
|
if args =~ /^(\d*)$/
|
27
27
|
find_status_id_candidates $1, "#{cmd} %s"
|
28
28
|
end
|
data/lib/plugin/scrape.rb
CHANGED
@@ -18,7 +18,7 @@ module Termtter::Client
|
|
18
18
|
|
19
19
|
register_command(
|
20
20
|
:name => :scrape_group,
|
21
|
-
:exec_proc =>
|
21
|
+
:exec_proc => lambda{ |args|
|
22
22
|
groups = args.split(' ').map{|g| g.to_sym}
|
23
23
|
if groups.include? :all
|
24
24
|
groups = configatron.plugins.group.groups.keys
|
@@ -31,7 +31,7 @@ module Termtter::Client
|
|
31
31
|
statuses = scrape_members(members.uniq.compact.sort)
|
32
32
|
call_hooks(statuses, :pre_filter)
|
33
33
|
},
|
34
|
-
:completion_proc =>
|
34
|
+
:completion_proc => lambda {|cmd, args|
|
35
35
|
arg = args.split(' ').last
|
36
36
|
prefix = args.split(' ')[0..-2].join(' ')
|
37
37
|
find_group_candidates arg, "#{cmd} #{prefix} %s"
|
data/lib/plugin/shell.rb
CHANGED
data/lib/plugin/sl.rb
CHANGED
@@ -10,22 +10,22 @@ module Termtter
|
|
10
10
|
|
11
11
|
register_command(
|
12
12
|
:name => :sl, :aliases => [],
|
13
|
-
:exec_proc =>
|
13
|
+
:exec_proc => lambda {|arg| system("sl") },
|
14
14
|
:help => ['sl', 'The train pass in front of your screen']
|
15
15
|
)
|
16
16
|
|
17
17
|
register_command(
|
18
18
|
:name => :pwd, :aliases => [],
|
19
|
-
:exec_proc =>
|
19
|
+
:exec_proc => lambda {|arg| public_storage[:current] },
|
20
20
|
:help => ['pwd', 'Show current direcroty']
|
21
21
|
)
|
22
22
|
|
23
23
|
register_command(
|
24
24
|
:name => :ls, :aliases => [],
|
25
|
-
:exec_proc =>
|
25
|
+
:exec_proc => lambda {|arg|
|
26
26
|
call_commands("list #{arg.empty? ? public_storage[:current] : arg}", API.twitter)
|
27
27
|
},
|
28
|
-
:completion_proc =>
|
28
|
+
:completion_proc => lambda {|cmd, args|
|
29
29
|
find_user_candidates args, "#{cmd} %s"
|
30
30
|
},
|
31
31
|
:help => ['ls', 'Show list in current directory']
|
@@ -33,12 +33,12 @@ module Termtter
|
|
33
33
|
|
34
34
|
register_command(
|
35
35
|
:name => :cd, :aliases => [],
|
36
|
-
:exec_proc =>
|
36
|
+
:exec_proc => lambda {|arg|
|
37
37
|
public_storage[:current] =
|
38
38
|
(arg.nil? || /\~/ =~ arg) ? '' : arg
|
39
39
|
configatron.prompt = "~/#{public_storage[:current]} #{public_storage[:orig_prompt]}"
|
40
40
|
},
|
41
|
-
:completion_proc =>
|
41
|
+
:completion_proc => lambda {|cmd, args|
|
42
42
|
find_user_candidates args, "#{cmd} %s"
|
43
43
|
},
|
44
44
|
:help => ['cd USER', 'Change current directory']
|
@@ -8,12 +8,12 @@ module Termtter::Client
|
|
8
8
|
|
9
9
|
register_command(
|
10
10
|
:name => :update, :aliases => [:u],
|
11
|
-
:exec_proc =>
|
11
|
+
:exec_proc => lambda {|arg|
|
12
12
|
text = ERB.new(arg).result(binding).gsub(/\n/, ' ')
|
13
13
|
Termtter::API.twitter.update_status(text)
|
14
14
|
puts "=> #{text}"
|
15
15
|
},
|
16
|
-
:completion_proc =>
|
16
|
+
:completion_proc => lambda {|cmd, args|
|
17
17
|
if /(.*)@([^\s]*)$/ =~ args
|
18
18
|
find_user_candidates $2, "#{cmd} #{$1}@%s"
|
19
19
|
end
|
@@ -22,14 +22,14 @@ module Termtter::Client
|
|
22
22
|
|
23
23
|
register_command(
|
24
24
|
:name => :direct, :aliases => [:d],
|
25
|
-
:exec_proc =>
|
25
|
+
:exec_proc => lambda {|arg|
|
26
26
|
if arg =~ /^([^\s]+)\s+(.*)\s*$/
|
27
27
|
user, text = $1, $2
|
28
28
|
Termtter::API.twitter.direct_message(user, text)
|
29
29
|
puts "=> to:#{user} message:#{text}"
|
30
30
|
end
|
31
31
|
},
|
32
|
-
:completion_proc =>
|
32
|
+
:completion_proc => lambda {|cmd, args|
|
33
33
|
if args =~ /^([^\s]+)$/
|
34
34
|
find_user_candidates $1, "#{cmd} %s"
|
35
35
|
end
|
@@ -38,7 +38,7 @@ module Termtter::Client
|
|
38
38
|
|
39
39
|
register_command(
|
40
40
|
:name => :profile, :aliases => [:p],
|
41
|
-
:exec_proc =>
|
41
|
+
:exec_proc => lambda {|arg|
|
42
42
|
user = Termtter::API.twitter.get_user_profile(arg)
|
43
43
|
attrs = %w[ name screen_name url description profile_image_url location protected following
|
44
44
|
friends_count followers_count statuses_count favourites_count
|
@@ -50,42 +50,51 @@ module Termtter::Client
|
|
50
50
|
puts "#{attr.gsub('_', ' ').rjust(label_width)}: #{value}"
|
51
51
|
end
|
52
52
|
},
|
53
|
-
:completion_proc =>
|
53
|
+
:completion_proc => lambda {|cmd, arg|
|
54
54
|
find_user_candidates arg, "#{cmd} %s"
|
55
55
|
}
|
56
56
|
)
|
57
57
|
|
58
|
+
register_command(
|
59
|
+
:name => :followers,
|
60
|
+
:exec_proc => lambda {|arg|
|
61
|
+
followers = Termtter::API.twitter.followers
|
62
|
+
Termtter::Client.public_storage[:followers] = followers
|
63
|
+
p followers.map{|f|f.screen_name}
|
64
|
+
}
|
65
|
+
)
|
66
|
+
|
58
67
|
register_command(
|
59
68
|
:name => :list, :aliases => [:l],
|
60
|
-
:exec_proc =>
|
69
|
+
:exec_proc => lambda {|arg|
|
61
70
|
unless arg.empty?
|
62
71
|
call_hooks(Termtter::API.twitter.get_user_timeline(arg), :list_user_timeline)
|
63
72
|
else
|
64
73
|
call_hooks(Termtter::API.twitter.get_friends_timeline(), :list_friends_timeline)
|
65
74
|
end
|
66
75
|
},
|
67
|
-
:completion_proc =>
|
76
|
+
:completion_proc => lambda {|cmd, arg|
|
68
77
|
find_user_candidates arg, "#{cmd} %s"
|
69
78
|
}
|
70
79
|
)
|
71
80
|
|
72
81
|
register_command(
|
73
82
|
:name => :search, :aliases => [:s],
|
74
|
-
:exec_proc =>
|
83
|
+
:exec_proc => lambda {|arg|
|
75
84
|
call_hooks(Termtter::API.twitter.search(arg), :search)
|
76
85
|
}
|
77
86
|
)
|
78
87
|
|
79
88
|
register_command(
|
80
89
|
:name => :replies, :aliases => [:r],
|
81
|
-
:exec_proc =>
|
90
|
+
:exec_proc => lambda {|arg|
|
82
91
|
call_hooks(Termtter::API.twitter.replies(), :replies)
|
83
92
|
}
|
84
93
|
)
|
85
94
|
|
86
95
|
register_command(
|
87
96
|
:name => :show,
|
88
|
-
:exec_proc =>
|
97
|
+
:exec_proc => lambda {|arg|
|
89
98
|
id = arg.gsub(/.*:/, '')
|
90
99
|
call_hooks(Termtter::API.twitter.show(id), :show)
|
91
100
|
}
|
@@ -93,7 +102,7 @@ module Termtter::Client
|
|
93
102
|
|
94
103
|
register_command(
|
95
104
|
:name => :shows,
|
96
|
-
:exec_proc =>
|
105
|
+
:exec_proc => lambda {|arg|
|
97
106
|
id = arg.gsub(/.*:/, '')
|
98
107
|
call_hooks(Termtter::API.twitter.show(id, true), :show)
|
99
108
|
}
|
@@ -103,7 +112,7 @@ module Termtter::Client
|
|
103
112
|
# TODO: Simmulate remaining_hits.
|
104
113
|
register_command(
|
105
114
|
:name => :limit, :aliases => [:lm],
|
106
|
-
:exec_proc =>
|
115
|
+
:exec_proc => lambda {|arg|
|
107
116
|
limit = Termtter::API.twitter.get_rate_limit_status
|
108
117
|
remaining_time = "%dmin %dsec" % (limit.reset_time - Time.now).divmod(60)
|
109
118
|
remaining_color =
|
@@ -119,62 +128,71 @@ module Termtter::Client
|
|
119
128
|
|
120
129
|
register_command(
|
121
130
|
:name => :pause,
|
122
|
-
:exec_proc =>
|
131
|
+
:exec_proc => lambda {|arg| pause},
|
123
132
|
:help => ["pause", "Pause updating"]
|
124
133
|
)
|
125
134
|
|
126
135
|
register_command(
|
127
136
|
:name => :resume,
|
128
|
-
:exec_proc =>
|
137
|
+
:exec_proc => lambda {|arg| resume},
|
129
138
|
:help => ["resume", "Resume updating"]
|
130
139
|
)
|
131
140
|
|
132
141
|
register_command(
|
133
142
|
:name => :exit, :aliases => [:e],
|
134
|
-
:exec_proc =>
|
143
|
+
:exec_proc => lambda {|arg| exit},
|
135
144
|
:help => ['exit,e', 'Exit']
|
136
145
|
)
|
137
146
|
|
138
147
|
register_hook(
|
139
148
|
:name => :default_error_handler,
|
140
149
|
:points => [:on_error],
|
141
|
-
:exec_proc =>
|
150
|
+
:exec_proc => lambda {|e|
|
142
151
|
puts "Error: #{e}"
|
143
|
-
if configatron.
|
152
|
+
if configatron.devel == true
|
144
153
|
puts e.backtrace.join("\n")
|
145
154
|
end
|
146
155
|
}
|
147
156
|
)
|
148
157
|
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
158
|
+
register_command(
|
159
|
+
:name => :help, :aliases => [:h],
|
160
|
+
:exec_proc => lambda {|arg|
|
161
|
+
helps = [
|
162
|
+
["help,h", "Print this help message"],
|
163
|
+
["list,l", "List the posts in your friends timeline"],
|
164
|
+
["list,l USERNAME", "List the posts in the the given user's timeline"],
|
165
|
+
["update,u TEXT", "Post a new message"],
|
166
|
+
["direct,d @USERNAME TEXT", "Send direct message"],
|
167
|
+
["profile,p USERNAME", "Show user's profile"],
|
168
|
+
["replies,r", "List the most recent @replies for the authenticating user"],
|
169
|
+
["search,s TEXT", "Search for Twitter"],
|
170
|
+
["show ID", "Show a single status"]
|
171
|
+
]
|
172
|
+
helps += @@helps
|
173
|
+
helps += @@new_commands.map {|name, command| command.help}
|
174
|
+
helps.compact!
|
175
|
+
puts formatted_help(helps)
|
176
|
+
}
|
177
|
+
)
|
167
178
|
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
179
|
+
register_command(
|
180
|
+
:name => :execute,
|
181
|
+
:exec_proc => lambda{|arg|
|
182
|
+
if arg
|
183
|
+
`#{arg}`.each_line do |line|
|
184
|
+
unless line.strip.empty?
|
185
|
+
Termtter::API.twitter.update_status(line)
|
186
|
+
puts "=> #{line}"
|
187
|
+
end
|
188
|
+
end
|
189
|
+
end
|
190
|
+
},
|
191
|
+
:help => ['execute COMMAND', 'execute the command']
|
192
|
+
)
|
176
193
|
|
177
194
|
add_command /^!(!)?\s*(.*)$/ do |m, t|
|
195
|
+
warn '!COMMAND command will be removed. Use command execute instead.'
|
178
196
|
begin
|
179
197
|
result = `#{m[2]}` unless m[2].empty?
|
180
198
|
unless m[1].nil? || result.empty?
|
data/lib/plugin/system_status.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
require 'erb'
|
4
4
|
|
5
|
-
configatron.plugins.system_status.set_default(:default_status_proc,
|
5
|
+
configatron.plugins.system_status.set_default(:default_status_proc, lambda { Time.now.strftime("%x %X") })
|
6
6
|
configatron.plugins.system_status.set_default(:interval, 1)
|
7
7
|
configatron.plugins.system_status.set_default(:default_color, :on_blue)
|
8
8
|
configatron.plugins.system_status.set_default(:format, '<%= status %>')
|
@@ -27,7 +27,7 @@ end
|
|
27
27
|
# show system status on left side.
|
28
28
|
# output public_storage[:system_status] or Time.now.strftime("%x %X") if nil
|
29
29
|
# example config
|
30
|
-
# configatron.plugins.system_status.default_status_proc =
|
30
|
+
# configatron.plugins.system_status.default_status_proc = lambda { Time.now.strftime("%x %X") }
|
31
31
|
# configatron.plugins.system_status.interval = 1
|
32
32
|
# configatron.plugins.system_status.default_color = :on_blue
|
33
33
|
# configatron.plugins.system_status.format = '<%= status %>'
|
data/lib/plugin/update_editor.rb
CHANGED
data/lib/plugin/wassr_post.rb
CHANGED
@@ -6,7 +6,7 @@ require 'net/http'
|
|
6
6
|
Termtter::Client.register_hook(
|
7
7
|
:name => :wassr_post,
|
8
8
|
:points => [:modify_arg_for_update],
|
9
|
-
:exec_proc =>
|
9
|
+
:exec_proc => lambda {|cmd, arg|
|
10
10
|
begin
|
11
11
|
Net::HTTP.version_1_2
|
12
12
|
req = Net::HTTP::Post.new("/statuses/update.json?")
|
data/lib/plugin/yhara.rb
CHANGED
@@ -127,12 +127,12 @@ end
|
|
127
127
|
module Termtter::Client
|
128
128
|
register_command(
|
129
129
|
:name => :yhara,
|
130
|
-
:exec_proc =>
|
130
|
+
:exec_proc => lambda{|arg|
|
131
131
|
text = "#{'@' if arg[0..0] != '@'}#{arg} #{Yharian::text}"
|
132
132
|
Termtter::API.twitter.update_status(text)
|
133
133
|
puts "=> #{text}"
|
134
134
|
},
|
135
|
-
:completion_proc =>
|
135
|
+
:completion_proc => lambda {|cmd, args|
|
136
136
|
if /(.*)@([^\s]*)$/ =~ args
|
137
137
|
find_user_candidates $2, "#{cmd} #{$1}@%s"
|
138
138
|
end
|
data/lib/plugin/yonda.rb
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
|
3
3
|
module Termtter::Client
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
4
|
+
register_command(
|
5
|
+
:name => :yonda, :aliases => [:y],
|
6
|
+
:exec_proc => proc{|arg|
|
7
|
+
public_storage[:unread_count] = 0
|
8
|
+
print "\033[2J\033[H" # FIXME
|
9
|
+
call_hooks [], :plugin_yonda_yonda
|
10
|
+
},
|
11
|
+
:help => ['yonda,y', 'Mark as read']
|
12
|
+
)
|
13
13
|
|
14
14
|
add_hook do |statuses, event|
|
15
15
|
case event
|