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/Manifest.txt
CHANGED
@@ -3,6 +3,7 @@ Manifest.txt
|
|
3
3
|
PostInstall.txt
|
4
4
|
README.rdoc
|
5
5
|
Rakefile
|
6
|
+
bin/kill_termtter
|
6
7
|
bin/termtter
|
7
8
|
lib/filter/en2ja.rb
|
8
9
|
lib/filter/english.rb
|
@@ -12,6 +13,7 @@ lib/filter/ignore.rb
|
|
12
13
|
lib/filter/reply.rb
|
13
14
|
lib/filter/reverse.rb
|
14
15
|
lib/filter/yhara.rb
|
16
|
+
lib/plugin/april_fool.rb
|
15
17
|
lib/plugin/bomb.rb
|
16
18
|
lib/plugin/confirm.rb
|
17
19
|
lib/plugin/cool.rb
|
@@ -28,12 +30,16 @@ lib/plugin/hatebu.rb
|
|
28
30
|
lib/plugin/history.rb
|
29
31
|
lib/plugin/keyword.rb
|
30
32
|
lib/plugin/log.rb
|
33
|
+
lib/plugin/modify_arg_hook_sample.rb
|
31
34
|
lib/plugin/msagent.rb
|
32
35
|
lib/plugin/multi_reply.rb
|
33
36
|
lib/plugin/notify-send.rb
|
34
37
|
lib/plugin/otsune.rb
|
35
38
|
lib/plugin/outputz.rb
|
39
|
+
lib/plugin/pause.rb
|
36
40
|
lib/plugin/plugin.rb
|
41
|
+
lib/plugin/post_exec_hook_sample.rb
|
42
|
+
lib/plugin/pre_exec_hook_sample.rb
|
37
43
|
lib/plugin/primes.rb
|
38
44
|
lib/plugin/quicklook.rb
|
39
45
|
lib/plugin/reblog.rb
|
@@ -58,8 +64,12 @@ lib/termtter/api.rb
|
|
58
64
|
lib/termtter/client.rb
|
59
65
|
lib/termtter/command.rb
|
60
66
|
lib/termtter/connection.rb
|
67
|
+
lib/termtter/hook.rb
|
61
68
|
lib/termtter/status.rb
|
69
|
+
lib/termtter/task.rb
|
70
|
+
lib/termtter/task_manager.rb
|
62
71
|
lib/termtter/twitter.rb
|
72
|
+
lib/termtter/user.rb
|
63
73
|
run_termtter.rb
|
64
74
|
test/friends_timeline.json
|
65
75
|
test/search.json
|
data/Rakefile
CHANGED
@@ -37,3 +37,28 @@ Spec::Rake::SpecTask.new do |t|
|
|
37
37
|
t.spec_opts = ['-c']
|
38
38
|
end
|
39
39
|
|
40
|
+
def egrep(pattern)
|
41
|
+
res = []
|
42
|
+
Dir['**/*.rb'].each do |fn|
|
43
|
+
count = 0
|
44
|
+
open(fn) do |f|
|
45
|
+
while line = f.gets
|
46
|
+
count += 1
|
47
|
+
if line =~ pattern
|
48
|
+
res << [fn, count.to_s, line.gsub(/\A\s+/, '')]
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
fmax = res.map {|i| i[0] }.map(&:size).max
|
54
|
+
cmax = res.map {|i| i[1] }.map(&:size).max
|
55
|
+
res.each do |fn, count, line|
|
56
|
+
puts "%s :%s:%s" % [fn.ljust(fmax), count.rjust(cmax), line]
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
desc "Look for TODO and FIXME tags in the code"
|
61
|
+
task :todo do
|
62
|
+
egrep /(FIXME|TODO)/
|
63
|
+
end
|
64
|
+
|
data/bin/kill_termtter
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# If your termtter can't be exited, you might use this script.
|
3
|
+
#
|
4
|
+
# > exit
|
5
|
+
# (no response...)
|
6
|
+
# C-z
|
7
|
+
# $ kill_termtter -i
|
8
|
+
# y
|
9
|
+
#
|
10
|
+
# OPTION
|
11
|
+
# -i interactive
|
12
|
+
def s(a)
|
13
|
+
puts a
|
14
|
+
system a
|
15
|
+
end
|
16
|
+
|
17
|
+
`ps`.map(&:split).map {|i|
|
18
|
+
pid, runner, file = i[0], i[4], i[5]
|
19
|
+
if runner == 'ruby' && $$ != pid.to_i && /termtter/ =~ file
|
20
|
+
s "kill -KILL #{pid}"
|
21
|
+
end
|
22
|
+
}
|
data/lib/filter/en2ja.rb
CHANGED
data/lib/filter/fib.rb
CHANGED
data/lib/filter/ignore.rb
CHANGED
data/lib/filter/reverse.rb
CHANGED
@@ -0,0 +1,15 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
|
3
|
+
def april_fool?;true;end
|
4
|
+
def april_fool;april_fool? ? "今日はエイプリルフールではありません。" : "今日はエイプリルフールです。";end
|
5
|
+
|
6
|
+
Termtter::Client.register_command(
|
7
|
+
:name => :april_fool, :aliases => [:af],
|
8
|
+
:exec_proc => proc {|arg|
|
9
|
+
if arg =~ /^\?you\s(\w+)/
|
10
|
+
puts "=> #{Termtter::Client.update_status("@#{$1} #{april_fool}")}"
|
11
|
+
else
|
12
|
+
puts "=> #{Termtter::Client.update_status(april_fool)}"
|
13
|
+
end
|
14
|
+
}
|
15
|
+
)
|
data/lib/plugin/bomb.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
|
1
3
|
module Termtter
|
2
4
|
class Status
|
3
5
|
def bomb?
|
@@ -6,14 +8,15 @@ module Termtter
|
|
6
8
|
end
|
7
9
|
|
8
10
|
module Client
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
11
|
+
register_command(
|
12
|
+
:name => :bomb, :aliases => [],
|
13
|
+
:exec_proc => proc {|arg|
|
14
|
+
text = "#{arg.strip} 爆発しろ!"
|
15
|
+
Termtter::API::twitter.update_status(text)
|
16
|
+
puts "=> #{text}"
|
17
|
+
},
|
18
|
+
:help => ['bomb WORD', 'Bomb it']
|
19
|
+
)
|
17
20
|
end
|
18
21
|
end
|
19
22
|
|
data/lib/plugin/confirm.rb
CHANGED
@@ -1,24 +1,9 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
resume
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
add_completion do |input|
|
15
|
-
case input
|
16
|
-
when /^(confirm)\s+(.*)@([^\s]*)$/
|
17
|
-
find_user_candidates $3, "#{$1} #{$2}@%s"
|
18
|
-
else
|
19
|
-
['confirm'].grep(/^#{Regexp.quote input}/)
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
end
|
24
|
-
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
|
3
|
+
Termtter::Client.register_hook(
|
4
|
+
:name => :confirm,
|
5
|
+
:points => [:pre_exec_update],
|
6
|
+
:exec_proc => proc {|cmd, arg|
|
7
|
+
false if arg.empty? || /^y?$/i !~ Readline.readline("update? #{arg} [Y/n] ", false)
|
8
|
+
}
|
9
|
+
)
|
data/lib/plugin/cool.rb
CHANGED
@@ -1,12 +1,10 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
|
1
3
|
module Termtter::Client
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
when /^cool ([^\s]*)/
|
9
|
-
find_user_candidates $1, "cool %s"
|
10
|
-
end
|
11
|
-
end
|
4
|
+
register_macro(:cool, "update @%s cool.",
|
5
|
+
:help => ['cool {SCREENNAME}', 'update "@{SCREENNAME} cool."'],
|
6
|
+
:completion_proc => proc {|cmd, args|
|
7
|
+
find_user_candidates args, "#{cmd} %s"
|
8
|
+
}
|
9
|
+
)
|
12
10
|
end
|
data/lib/plugin/english.rb
CHANGED
data/lib/plugin/erb.rb
CHANGED
@@ -1,14 +1,14 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
|
1
3
|
require 'erb'
|
2
4
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
end
|
11
|
-
end
|
5
|
+
Termtter::Client.register_hook(
|
6
|
+
:name => :erb,
|
7
|
+
:points => [:pre_exec_update],
|
8
|
+
:exec_proc => proc {|cmd, arg|
|
9
|
+
ERB.new(arg).result(binding)
|
10
|
+
}
|
11
|
+
)
|
12
12
|
|
13
13
|
# erb.rb
|
14
14
|
# enable to <%= %> in the command update
|
data/lib/plugin/favorite.rb
CHANGED
data/lib/plugin/fib.rb
CHANGED
data/lib/plugin/filter.rb
CHANGED
@@ -1,34 +1,50 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
1
2
|
|
2
|
-
module Termtter::Client
|
3
3
|
|
4
|
+
module Termtter::Client
|
4
5
|
public_storage[:filters] = []
|
5
|
-
|
6
|
-
|
7
|
-
add_command /^filter\s+(.*)/ do |m, t|
|
8
|
-
begin
|
9
|
-
result = filter m[1].strip
|
10
|
-
rescue LoadError
|
11
|
-
result = false
|
12
|
-
ensure
|
13
|
-
puts "=> #{result.inspect}"
|
14
|
-
end
|
6
|
+
filters = Dir["#{File.dirname(__FILE__)}/../filter/*.rb"].map do |f|
|
7
|
+
f.match(%r|([^/]+).rb$|)[1]
|
15
8
|
end
|
16
9
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
10
|
+
register_command(
|
11
|
+
:name => :filter, :aliases => [],
|
12
|
+
:exec_proc => proc {|arg|
|
13
|
+
begin
|
14
|
+
result = filter arg.strip
|
15
|
+
rescue LoadError
|
16
|
+
result = false
|
17
|
+
ensure
|
18
|
+
puts "=> #{result.inspect}"
|
19
|
+
end
|
20
|
+
},
|
21
|
+
:completion_proc => proc {|cmd, args|
|
22
|
+
find_filter_candidates args, "#{cmd} %s", filters
|
23
|
+
},
|
24
|
+
:help => ['filter FILE', 'Apply a filter']
|
25
|
+
)
|
23
26
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
puts '
|
30
|
-
|
31
|
-
|
27
|
+
register_command(
|
28
|
+
:name => :unfilter, :aliases => [],
|
29
|
+
:exec_proc => proc {|arg|
|
30
|
+
clear_filters
|
31
|
+
public_storage[:filters].clear
|
32
|
+
puts '=> filter cleared'
|
33
|
+
},
|
34
|
+
:help => ['ufilter', 'Clear all filters']
|
35
|
+
)
|
36
|
+
|
37
|
+
register_command(
|
38
|
+
:name => :filters, :aliases => [],
|
39
|
+
:exec_proc => proc {|arg|
|
40
|
+
unless public_storage[:filters].empty?
|
41
|
+
puts public_storage[:filters].join(', ')
|
42
|
+
else
|
43
|
+
puts 'no filter was applied'
|
44
|
+
end
|
45
|
+
},
|
46
|
+
:help => ['filters', 'Show list of applied filters']
|
47
|
+
)
|
32
48
|
|
33
49
|
def self.find_filter_candidates(a, b, filters)
|
34
50
|
if a.empty?
|
@@ -38,17 +54,6 @@ module Termtter::Client
|
|
38
54
|
end.
|
39
55
|
map {|u| b % u }
|
40
56
|
end
|
41
|
-
|
42
|
-
filters = Dir["#{File.dirname(__FILE__)}/../filter/*.rb"].map do |f|
|
43
|
-
f.match(%r|([^/]+).rb$|)[1]
|
44
|
-
end
|
45
|
-
add_completion do |input|
|
46
|
-
if input =~ /^(filter)\s+(.*)/
|
47
|
-
find_filter_candidates $2, "#{$1} %s", filters
|
48
|
-
else
|
49
|
-
%w[ filter filters unfilter ].grep(/^#{Regexp.quote input}/)
|
50
|
-
end
|
51
|
-
end
|
52
57
|
end
|
53
58
|
|
54
59
|
# filter.rb
|
data/lib/plugin/follow.rb
CHANGED
@@ -1,25 +1,41 @@
|
|
1
|
-
|
2
|
-
add_help 'follow USER', 'Follow user'
|
3
|
-
add_help 'leave USER', 'Leave user'
|
1
|
+
# -*- coding: utf-8 -*-
|
4
2
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
3
|
+
module Termtter::Client
|
4
|
+
register_command(
|
5
|
+
:name => :follow, :aliases => [],
|
6
|
+
:exec_proc => proc {|arg|
|
7
|
+
if arg =~ /^(\w+)/
|
8
|
+
res = Termtter::API::twitter.social($1.strip, :follow)
|
9
|
+
if res.code == '200'
|
10
|
+
puts "Followed user @#{$1}"
|
11
|
+
else
|
12
|
+
puts "Failed: #{res}"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
},
|
16
|
+
:completion_proc => proc {|cmd, args|
|
17
|
+
find_user_candidates args, "#{cmd} %s"
|
18
|
+
},
|
19
|
+
:help => ['follow USER', 'Follow user']
|
20
|
+
)
|
14
21
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
22
|
+
register_command(
|
23
|
+
:name => :leave, :aliases => [],
|
24
|
+
:exec_proc => proc {|arg|
|
25
|
+
if arg =~ /^(\w+)/
|
26
|
+
res = t.social($1.strip, :leave)
|
27
|
+
if res.code == '200'
|
28
|
+
puts "Leaved user @#{$1}"
|
29
|
+
else
|
30
|
+
puts "Failed: #{res}"
|
31
|
+
end
|
32
|
+
end
|
33
|
+
},
|
34
|
+
:completion_proc => proc {|cmd, args|
|
35
|
+
find_user_candidates args, "#{cmd} %s"
|
36
|
+
},
|
37
|
+
:help => ['leave USER', 'Leave user']
|
38
|
+
)
|
23
39
|
end
|
24
40
|
|
25
41
|
module Termtter
|