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/group.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
# -*- coding: utf-8 -*-
|
2
2
|
|
3
3
|
module Termtter
|
4
4
|
class Status
|
@@ -13,41 +13,38 @@ module Termtter
|
|
13
13
|
end
|
14
14
|
|
15
15
|
module Termtter::Client
|
16
|
-
|
17
|
-
|
16
|
+
configatron.plugins.group.
|
17
|
+
set_default(:groups, {})
|
18
18
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
end
|
24
|
-
|
25
|
-
add_command /^(?:group|g)\s+(.+)/ do |m, t|
|
26
|
-
group_name = m[1].to_sym
|
27
|
-
group = configatron.plugins.group.groups[group_name]
|
28
|
-
statuses = group ? public_storage[:log].select { |s|
|
29
|
-
group.include?(s.user_screen_name)
|
30
|
-
} : []
|
31
|
-
call_hooks(statuses, :search, t)
|
32
|
-
end
|
33
|
-
|
34
|
-
def self.find_group_candidates(a, b)
|
35
|
-
configatron.plugins.group.groups.keys.map {|k| k.to_s}.
|
36
|
-
grep(/^#{Regexp.quote a}/).
|
37
|
-
map {|u| b % u }
|
38
|
-
end
|
39
|
-
|
40
|
-
add_completion do |input|
|
41
|
-
case input
|
42
|
-
when /^(group|g)\s+(.+)/
|
43
|
-
find_group_candidates($2, "#{$1} %s")
|
44
|
-
when /^(group|g)\s+$/
|
45
|
-
configatron.plugins.group.groups.keys
|
46
|
-
else
|
47
|
-
%w(group).grep(/^#{Regexp.quote input}/)
|
48
|
-
end
|
49
|
-
end
|
19
|
+
def self.find_group_candidates(a, b)
|
20
|
+
configatron.plugins.group.groups.keys.map {|k| k.to_s}.
|
21
|
+
grep(/^#{Regexp.quote a}/).
|
22
|
+
map {|u| b % u }
|
50
23
|
end
|
24
|
+
|
25
|
+
register_command(
|
26
|
+
:name => :group,
|
27
|
+
:aliases => [:g],
|
28
|
+
:exec_proc => proc {|arg|
|
29
|
+
unless arg.empty?
|
30
|
+
group_name = arg.to_sym
|
31
|
+
group = configatron.plugins.group.groups[group_name]
|
32
|
+
statuses = group ? public_storage[:log].select { |s|
|
33
|
+
group.include?(s.user_screen_name)
|
34
|
+
} : []
|
35
|
+
call_hooks(statuses, :search)
|
36
|
+
else
|
37
|
+
configatron.plugins.group.groups.each_pair do |key, value|
|
38
|
+
puts "#{key}: #{value.join(',')}"
|
39
|
+
end
|
40
|
+
end
|
41
|
+
},
|
42
|
+
:completion_proc => proc {|cmd, arg|
|
43
|
+
find_group_candidates arg, "#{cmd} %s"
|
44
|
+
},
|
45
|
+
:help => ['group,g GROUPNAME', 'Filter by group members']
|
46
|
+
)
|
47
|
+
|
51
48
|
end
|
52
49
|
|
53
50
|
# group.rb
|
@@ -56,3 +53,4 @@ end
|
|
56
53
|
# :rits => %w(hakobe isano hitode909)
|
57
54
|
# }
|
58
55
|
# NOTE: group.rb needs plugin/log
|
56
|
+
|
data/lib/plugin/growl.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
|
1
3
|
require 'tmpdir'
|
2
4
|
require 'open-uri'
|
3
5
|
require 'uri'
|
@@ -35,7 +37,7 @@ Thread.new do
|
|
35
37
|
begin
|
36
38
|
if s = queue.pop
|
37
39
|
unless growl
|
38
|
-
arg = ['growlnotify', s.user_screen_name, '-m', s.text.gsub("\n",''), '-n', 'termtter']
|
40
|
+
arg = ['growlnotify', s.user_screen_name, '-m', s.text.gsub("\n",''), '-n', 'termtter', '-H', 'localhost']
|
39
41
|
#icon_path = get_icon_path(s)
|
40
42
|
#arg += ['--image', icon_path] if icon_path
|
41
43
|
system *arg
|
data/lib/plugin/hatebu.rb
CHANGED
@@ -1,51 +1,53 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
|
1
3
|
require 'rubygems'
|
2
4
|
require 'atomutil'
|
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
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
7
|
+
register_command(
|
8
|
+
:name => :hatebu, :aliases => [],
|
9
|
+
:exec_proc => proc {|arg|
|
10
|
+
if arg =~ /^(\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
|
+
auth = auth = Atompub::Auth::Wsse.new({
|
20
|
+
:username => configatron.plugins.hatebu.username,
|
21
|
+
:password => configatron.plugins.hatebu.password,
|
22
|
+
})
|
23
|
+
link = Atom::Link.new({
|
24
|
+
:href => "http://twitter.com/#{status.user_screen_name}/status/#{status.id}",
|
25
|
+
:rel => 'related',
|
26
|
+
:type => 'text/html',
|
27
|
+
})
|
28
|
+
entry = Atom::Entry.new({
|
29
|
+
:link => link,
|
30
|
+
:title => 'dummy',
|
31
|
+
:summary => comment,
|
32
|
+
})
|
33
|
+
req = Net::HTTP::Post.new 'http://b.hatena.ne.jp/atom/post'
|
34
|
+
req['User-Agent'] = 'Mozilla/5.0'
|
35
|
+
req['Content-Type'] = 'application/atom+xml'
|
36
|
+
req['Slug'] = 'termtter'
|
37
|
+
req.body = entry.to_s
|
38
|
+
auth.authorize(req)
|
39
|
+
Net::HTTP.start('b.hatena.ne.jp', 80) do |http|
|
40
|
+
res = http.request(req)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
},
|
44
|
+
:completion_proc => proc {|cmd, args|
|
45
|
+
if args =~ /^(\d*)$/
|
46
|
+
find_status_id_candidates $1, "#{cmd} %s"
|
47
|
+
end
|
48
|
+
},
|
49
|
+
:help => ['hatebu ID', 'Hatena bookmark a status']
|
50
|
+
)
|
49
51
|
end
|
50
52
|
|
51
53
|
# hatebu.rb
|
data/lib/plugin/history.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
|
1
3
|
require 'zlib'
|
2
4
|
|
3
5
|
configatron.plugins.history.
|
@@ -6,6 +8,10 @@ configatron.plugins.history.
|
|
6
8
|
set_default(:keys, [:log, :users, :status_ids])
|
7
9
|
configatron.plugins.history.
|
8
10
|
set_default(:max_of_history, 100)
|
11
|
+
configatron.plugins.history.
|
12
|
+
set_default(:enable_autosave, true)
|
13
|
+
configatron.plugins.history.
|
14
|
+
set_default(:autosave_interval, 3600)
|
9
15
|
|
10
16
|
module Termtter::Client
|
11
17
|
def self.load_history
|
@@ -15,15 +21,13 @@ module Termtter::Client
|
|
15
21
|
if File.exist?(filename)
|
16
22
|
begin
|
17
23
|
history = Marshal.load Zlib::Inflate.inflate(File.read(filename))
|
18
|
-
rescue Zlib::DataError
|
19
|
-
history = Marshal.load File.read(filename)
|
20
24
|
end
|
21
25
|
if history
|
22
26
|
keys.each do |key|
|
23
27
|
public_storage[key] = history[key] if history[key]
|
24
28
|
end
|
25
29
|
Readline::HISTORY.push *history[:history] if history[:history]
|
26
|
-
puts "history loaded(#{File.size(filename)}
|
30
|
+
puts "history loaded(#{File.size(filename)/1000}kb)"
|
27
31
|
end
|
28
32
|
end
|
29
33
|
end
|
@@ -44,7 +48,7 @@ module Termtter::Client
|
|
44
48
|
File.open(filename, 'w') do |f|
|
45
49
|
f.write Zlib::Deflate.deflate(Marshal.dump(history))
|
46
50
|
end
|
47
|
-
puts "history saved(#{File.size(filename)}
|
51
|
+
puts "history saved(#{File.size(filename)/1000}kb)"
|
48
52
|
end
|
49
53
|
|
50
54
|
add_hook do |statuses, event|
|
@@ -55,6 +59,14 @@ module Termtter::Client
|
|
55
59
|
save_history
|
56
60
|
end
|
57
61
|
end
|
62
|
+
|
63
|
+
if configatron.plugins.history.enable_autosave
|
64
|
+
Termtter::Client.add_task(:interval => configatron.plugins.history.autosave_interval,
|
65
|
+
:after => configatron.plugins.history.autosave_interval) do
|
66
|
+
save_history
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
58
70
|
end
|
59
71
|
|
60
72
|
# history.rb
|
data/lib/plugin/keyword.rb
CHANGED
data/lib/plugin/log.rb
CHANGED
@@ -1,12 +1,10 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
|
1
3
|
module Termtter::Client
|
2
4
|
public_storage[:log] = []
|
3
5
|
configatron.plugins.log.set_default('max_size', 1/0.0)
|
4
6
|
configatron.plugins.log.set_default('print_max_size', 30)
|
5
7
|
|
6
|
-
add_help '/WORD', 'Search log for WORD'
|
7
|
-
add_help 'log', 'Show local log'
|
8
|
-
add_help 'log (USER(S)) (MAX)', 'Show local log of the user(s)'
|
9
|
-
|
10
8
|
add_hook do |statuses, event|
|
11
9
|
case event
|
12
10
|
when :pre_filter
|
@@ -19,37 +17,39 @@ module Termtter::Client
|
|
19
17
|
end
|
20
18
|
end
|
21
19
|
|
20
|
+
register_command(
|
21
|
+
:name => :log,
|
22
|
+
:exec_proc => proc{|arg|
|
23
|
+
if arg.empty?
|
24
|
+
# log
|
25
|
+
statuses = public_storage[:log]
|
26
|
+
print_max = configatron.plugins.log.print_max_size
|
27
|
+
print_max = 0 if statuses.size < print_max
|
28
|
+
call_hooks(statuses[-print_max..-1], :search)
|
29
|
+
else
|
30
|
+
# log (user) (max)
|
31
|
+
vars = arg.split(' ')
|
32
|
+
print_max = vars.last =~ /^\d+$/ ? vars.pop.to_i : configatron.plugins.log.print_max_size
|
33
|
+
id = vars
|
34
|
+
statuses = id.first ? public_storage[:log].select{ |s| id.include? s.user_screen_name} : public_storage[:log]
|
35
|
+
print_max = 0 if statuses.size < print_max
|
36
|
+
call_hooks(statuses[-print_max..-1], :search)
|
37
|
+
end
|
38
|
+
},
|
39
|
+
:completion_proc => proc {|cmd, arg|
|
40
|
+
find_user_candidates arg, "#{cmd} %s"
|
41
|
+
},
|
42
|
+
:help => [ 'log (USER(S)) (MAX)', 'Show local log of the user(s)']
|
43
|
+
)
|
44
|
+
|
45
|
+
# These are old code we must fix.
|
46
|
+
|
47
|
+
add_help 'log', 'Show local log'
|
48
|
+
|
49
|
+
add_help '/WORD', 'Search log for WORD'
|
22
50
|
add_command %r'^/(.+)' do |m, t|
|
23
51
|
pat = Regexp.new(m[1])
|
24
52
|
statuses = public_storage[:log].select { |s| s.text =~ pat }
|
25
53
|
call_hooks(statuses, :search, t)
|
26
54
|
end
|
27
|
-
|
28
|
-
# log
|
29
|
-
add_command /^(log)\s*$/ do |m, t|
|
30
|
-
statuses = public_storage[:log]
|
31
|
-
print_max = configatron.plugins.log.print_max_size
|
32
|
-
print_max = 0 if statuses.size < print_max
|
33
|
-
call_hooks(statuses[-print_max..-1], :search, t)
|
34
|
-
end
|
35
|
-
|
36
|
-
# log (user) (max)
|
37
|
-
add_command /^(log)\s+(.+)\s*/ do |m, t|
|
38
|
-
vars = m[2].split(' ')
|
39
|
-
print_max = vars.last =~ /^\d+$/ ? vars.pop.to_i : configatron.plugins.log.print_max_size
|
40
|
-
id = vars
|
41
|
-
statuses = id.first ? public_storage[:log].select{ |s| id.include? s.user_screen_name} : public_storage[:log]
|
42
|
-
print_max = 0 if statuses.size < print_max
|
43
|
-
call_hooks(statuses[-print_max..-1], :search, t)
|
44
|
-
end
|
45
|
-
|
46
|
-
add_completion do |input|
|
47
|
-
case input
|
48
|
-
when /^(log)\s+(.*)/
|
49
|
-
find_user_candidates $2, "#{$1} %s"
|
50
|
-
else
|
51
|
-
%w[ log ].grep(/^#{Regexp.quote input}/)
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
55
|
end
|
data/lib/plugin/msagent.rb
CHANGED
data/lib/plugin/multi_reply.rb
CHANGED
data/lib/plugin/notify-send.rb
CHANGED
data/lib/plugin/otsune.rb
CHANGED
@@ -1,17 +1,21 @@
|
|
1
|
-
|
2
|
-
add_help 'otsune {SCREENNAME}', 'update "@{SCREENNAME} 頭蓋骨の中身がお気の毒です"'
|
3
|
-
add_help 'otsnue {SCREENNAME}', 'update "@{SCREENNAME} 頭が気の毒です"'
|
1
|
+
# -*- coding: utf-8 -*-
|
4
2
|
|
5
|
-
|
6
|
-
|
3
|
+
module Termtter::Client
|
4
|
+
register_macro(:otsune, "update @%s 頭蓋骨の中身がお気の毒です.",
|
5
|
+
:help => ['otsune {SCREENNAME}', 'update "@{SCREENNAME} 頭蓋骨の中身がお気の毒です"'],
|
6
|
+
:completion_proc => proc {|cmd, args|
|
7
|
+
find_user_candidates args, "#{cmd} %s"
|
8
|
+
}
|
9
|
+
)
|
10
|
+
end
|
7
11
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
end
|
12
|
+
module Termtter::Client
|
13
|
+
register_macro(:otsnue, "update @%s 頭蓋骨の中身がお気の毒です.",
|
14
|
+
:help => ['otsnue {SCREENNAME}', 'update @%s 頭が気の毒です.'],
|
15
|
+
:completion_proc => proc {|cmd, args|
|
16
|
+
find_user_candidates args, "#{cmd} %s"
|
17
|
+
}
|
18
|
+
)
|
16
19
|
end
|
20
|
+
|
17
21
|
# vim: fenc=utf8
|
data/lib/plugin/outputz.rb
CHANGED
data/lib/plugin/pause.rb
ADDED
data/lib/plugin/plugin.rb
CHANGED
@@ -1,40 +1,45 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
|
1
3
|
module Termtter::Client
|
2
4
|
|
3
5
|
public_storage[:plugins] = Dir["#{File.dirname(__FILE__)}/*.rb"].map do |f|
|
4
6
|
f.match(%r|([^/]+).rb$|)[1]
|
5
7
|
end
|
6
8
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
9
|
+
register_command(
|
10
|
+
:name => :plugin, :aliases => [],
|
11
|
+
:exec_proc => proc {|arg|
|
12
|
+
begin
|
13
|
+
result = plugin arg.strip
|
14
|
+
rescue LoadError
|
15
|
+
ensure
|
16
|
+
puts "=> #{result.inspect}"
|
17
|
+
end
|
18
|
+
},
|
19
|
+
:completion_proc => proc {|cmd, args|
|
20
|
+
find_user_candidates args, "#{cmd} %s"
|
21
|
+
unless args.empty?
|
22
|
+
find_plugin_candidates args, "#{cmd} %s"
|
23
|
+
else
|
24
|
+
public_storage[:plugins].sort
|
25
|
+
end
|
26
|
+
},
|
27
|
+
:help => ['plugin FILE', 'Load a plugin']
|
28
|
+
)
|
16
29
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
30
|
+
register_command(
|
31
|
+
:name => :plugins, :aliases => [],
|
32
|
+
:exec_proc => proc {|arg|
|
33
|
+
puts public_storage[:plugins].sort.join("\n")
|
34
|
+
},
|
35
|
+
:help => ['plugins', 'Show list of plugins']
|
36
|
+
)
|
21
37
|
|
22
38
|
def self.find_plugin_candidates(a, b)
|
23
39
|
public_storage[:plugins].
|
24
40
|
grep(/^#{Regexp.quote a}/i).
|
25
41
|
map {|u| b % u }
|
26
42
|
end
|
27
|
-
|
28
|
-
add_completion do |input|
|
29
|
-
case input
|
30
|
-
when /^(plugin)\s+(.+)/
|
31
|
-
find_plugin_candidates $2, "#{$1} %s"
|
32
|
-
when /^(plugin)\s+$/
|
33
|
-
public_storage[:plugins].sort
|
34
|
-
else
|
35
|
-
%w[ plugin plugins ].grep(/^#{Regexp.quote input}/)
|
36
|
-
end
|
37
|
-
end
|
38
43
|
end
|
39
44
|
|
40
45
|
# plugin.rb
|