jugyo-termtter 0.7.0 → 0.7.5
Sign up to get free protection for your applications and to get access to all the features.
- data/Manifest.txt +19 -9
- data/README.rdoc +20 -0
- data/Rakefile +3 -2
- data/bin/termtter +11 -5
- data/lib/filter/expand-tinyurl.rb +8 -1
- data/lib/filter/fib.rb +13 -0
- data/lib/filter/yhara.rb +1 -1
- data/lib/plugin/bomb.rb +26 -0
- data/lib/plugin/confirm.rb +24 -0
- data/lib/plugin/favorite.rb +25 -4
- data/lib/plugin/fib.rb +2 -1
- data/lib/plugin/filter.rb +1 -3
- data/lib/plugin/follow.rb +40 -0
- data/lib/plugin/group.rb +40 -0
- data/lib/plugin/history.rb +53 -0
- data/lib/plugin/keyword.rb +1 -1
- data/lib/plugin/log.rb +8 -2
- data/lib/plugin/plugin.rb +8 -8
- data/lib/plugin/quicklook.rb +36 -0
- data/lib/plugin/reload.rb +3 -0
- data/lib/plugin/shell.rb +2 -3
- data/lib/plugin/sl.rb +3 -0
- data/lib/plugin/spam.rb +7 -0
- data/lib/plugin/standard_plugins.rb +10 -1
- data/lib/plugin/stdout.rb +25 -10
- data/lib/plugin/uri-open.rb +10 -4
- data/lib/plugin/yhara.rb +142 -0
- data/lib/termtter.rb +173 -37
- data/run_termtter.rb +0 -2
- data/test/test_termtter.rb +0 -22
- metadata +38 -11
- data/lib/filter.rb +0 -28
data/Manifest.txt
CHANGED
@@ -3,31 +3,41 @@ Manifest.txt
|
|
3
3
|
PostInstall.txt
|
4
4
|
README.rdoc
|
5
5
|
Rakefile
|
6
|
-
run_termtter.rb
|
7
6
|
bin/termtter
|
8
|
-
lib/
|
9
|
-
lib/filter.rb
|
7
|
+
lib/filter/en2ja.rb
|
8
|
+
lib/filter/english.rb
|
9
|
+
lib/filter/expand-tinyurl.rb
|
10
|
+
lib/filter/fib.rb
|
11
|
+
lib/filter/reverse.rb
|
12
|
+
lib/filter/yhara.rb
|
13
|
+
lib/plugin/bomb.rb
|
14
|
+
lib/plugin/confirm.rb
|
10
15
|
lib/plugin/english.rb
|
11
16
|
lib/plugin/erb.rb
|
12
17
|
lib/plugin/favorite.rb
|
13
18
|
lib/plugin/fib.rb
|
14
19
|
lib/plugin/filter.rb
|
20
|
+
lib/plugin/follow.rb
|
21
|
+
lib/plugin/group.rb
|
15
22
|
lib/plugin/growl.rb
|
23
|
+
lib/plugin/history.rb
|
16
24
|
lib/plugin/keyword.rb
|
17
25
|
lib/plugin/log.rb
|
18
26
|
lib/plugin/notify-send.rb
|
19
27
|
lib/plugin/plugin.rb
|
28
|
+
lib/plugin/quicklook.rb
|
29
|
+
lib/plugin/reload.rb
|
20
30
|
lib/plugin/say.rb
|
21
31
|
lib/plugin/shell.rb
|
32
|
+
lib/plugin/sl.rb
|
33
|
+
lib/plugin/spam.rb
|
22
34
|
lib/plugin/standard_plugins.rb
|
23
35
|
lib/plugin/stdout.rb
|
24
36
|
lib/plugin/translation.rb
|
25
37
|
lib/plugin/uri-open.rb
|
26
|
-
lib/
|
27
|
-
lib/
|
28
|
-
|
29
|
-
lib/filter/expand-tinyurl.rb
|
30
|
-
lib/filter/en2ja.rb
|
31
|
-
test/test_termtter.rb
|
38
|
+
lib/plugin/yhara.rb
|
39
|
+
lib/termtter.rb
|
40
|
+
run_termtter.rb
|
32
41
|
test/friends_timeline.json
|
33
42
|
test/search.json
|
43
|
+
test/test_termtter.rb
|
data/README.rdoc
CHANGED
@@ -24,6 +24,15 @@ Run:
|
|
24
24
|
sudo gem source -a http://gems.github.com (you only have to do this once)
|
25
25
|
sudo gem install jugyo-termtter
|
26
26
|
|
27
|
+
if you want to install gem package from source code, install like following.
|
28
|
+
|
29
|
+
git clone git://github.com/jugyo/termtter.git
|
30
|
+
cd termtter
|
31
|
+
rake manifest
|
32
|
+
rake gemspec
|
33
|
+
gem build termtter.gemspec
|
34
|
+
gem install *.gem
|
35
|
+
|
27
36
|
Just run a new command termtter.
|
28
37
|
|
29
38
|
termtter
|
@@ -36,12 +45,23 @@ You can edit the file anytime.
|
|
36
45
|
configatron.user_name = 'USERNAME'
|
37
46
|
configatron.password = 'PASSWORD'
|
38
47
|
|
48
|
+
If you would like to use proxy server, add configurations like this:
|
49
|
+
|
50
|
+
configatron.proxy.host = 'PROXYHOST'
|
51
|
+
configatron.proxy.port = 'PROXYPORT'
|
52
|
+
configatron.proxy.user_name = 'USERNAME'
|
53
|
+
configatron.proxy.password = 'PASSWORD'
|
54
|
+
|
39
55
|
To update the config, just restart your termtter proccess.
|
40
56
|
|
41
57
|
== FORUM:
|
42
58
|
|
43
59
|
http://www.lingr.com/room/termtter
|
44
60
|
|
61
|
+
== DOCUMENT:
|
62
|
+
|
63
|
+
http://wiki.github.com/jugyo/termtter/home (in Japanese)
|
64
|
+
|
45
65
|
== LICENSE:
|
46
66
|
|
47
67
|
(The MIT License)
|
data/Rakefile
CHANGED
@@ -4,14 +4,15 @@ require File.dirname(__FILE__) + '/lib/termtter'
|
|
4
4
|
# Generate all the Rake tasks
|
5
5
|
# Run 'rake -T' to see list of generated tasks (from gem root directory)
|
6
6
|
$hoe = Hoe.new('termtter', Termtter::VERSION) do |p|
|
7
|
-
p.author = [
|
8
|
-
p.
|
7
|
+
p.author = %w[jugyo hakobe motemen koichiro Sixeight mattn ujihisa yanbe hitode909 bubblegum].sort_by{|i|i.downcase}
|
8
|
+
p.email = ['jugyo.org@gmail.com']
|
9
9
|
p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
|
10
10
|
p.post_install_message = 'PostInstall.txt' # TODO remove if post-install message not required
|
11
11
|
p.rubyforge_name = p.name # TODO this is default value
|
12
12
|
p.extra_deps = [
|
13
13
|
['json'],
|
14
14
|
['configatron'],
|
15
|
+
['highline'],
|
15
16
|
]
|
16
17
|
#p.extra_dev_deps = [
|
17
18
|
# ['newgem', ">= #{::Newgem::VERSION}"]
|
data/bin/termtter
CHANGED
@@ -3,8 +3,9 @@
|
|
3
3
|
$KCODE = 'u'
|
4
4
|
|
5
5
|
require 'rubygems'
|
6
|
-
require 'termtter'
|
7
6
|
require 'configatron'
|
7
|
+
require 'highline'
|
8
|
+
require 'termtter'
|
8
9
|
plugin 'standard_plugins'
|
9
10
|
plugin 'stdout'
|
10
11
|
|
@@ -12,10 +13,11 @@ conf_file = File.expand_path('~/.termtter')
|
|
12
13
|
if File.exist? conf_file
|
13
14
|
load conf_file
|
14
15
|
else
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
password =
|
16
|
+
HighLine.track_eof = false
|
17
|
+
ui = HighLine.new
|
18
|
+
username = ui.ask('your twitter username: ')
|
19
|
+
password = ui.ask('your twitter password: ') { |q| q.echo = false }
|
20
|
+
|
19
21
|
File.open(File.expand_path('~/.termtter'), 'w') {|io|
|
20
22
|
plugins = Dir.glob(File.dirname(__FILE__) + "/../lib/plugin/*.rb").map {|f|
|
21
23
|
f.match(%r|lib/plugin/(.*?).rb$|)[1]
|
@@ -29,6 +31,10 @@ else
|
|
29
31
|
io.puts "configatron.user_name = '#{username}'"
|
30
32
|
io.puts "configatron.password = '#{password}'"
|
31
33
|
io.puts "#configatron.update_interval = 120"
|
34
|
+
io.puts "#configatron.proxy.host = 'proxy host'"
|
35
|
+
io.puts "#configatron.proxy.port = '8080'"
|
36
|
+
io.puts "#configatron.proxy.user_name = 'proxy user'"
|
37
|
+
io.puts "#configatron.proxy.password = 'proxy password'"
|
32
38
|
io.puts
|
33
39
|
io.puts "# vim: set filetype=ruby"
|
34
40
|
}
|
@@ -10,6 +10,13 @@ module Termtter::Client
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def expand_tinyurl(path)
|
13
|
-
|
13
|
+
http_class = Net::HTTP
|
14
|
+
unless configatron.proxy.host.empty?
|
15
|
+
http_class = Net::HTTP::Proxy(configatron.proxy.host,
|
16
|
+
configatron.proxy.port,
|
17
|
+
configatron.proxy.user_name,
|
18
|
+
configatron.proxy.password)
|
19
|
+
end
|
20
|
+
res = http_class.new('tinyurl.com').head(path)
|
14
21
|
res['Location']
|
15
22
|
end
|
data/lib/filter/fib.rb
ADDED
data/lib/filter/yhara.rb
CHANGED
data/lib/plugin/bomb.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
module Termtter
|
2
|
+
class Status
|
3
|
+
def bomb?
|
4
|
+
/爆発|bomb/ =~ self.text
|
5
|
+
end
|
6
|
+
end
|
7
|
+
|
8
|
+
module Client
|
9
|
+
add_help 'bomb WORD', 'Bomb it'
|
10
|
+
add_command %r'^bomb\s+(.+)$' do |m, t|
|
11
|
+
bomb = m[1]
|
12
|
+
msg = "#{bomb} 爆発しろ!"
|
13
|
+
|
14
|
+
puts msg
|
15
|
+
t.update_status msg
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
# bomb.rb
|
21
|
+
# Bomb it!
|
22
|
+
#
|
23
|
+
# See http://gyazo.com/4b33517380673d92f51a52e675ecdb02.png .
|
24
|
+
# configatron.plugins.stdout.timeline_format =
|
25
|
+
# '<%= color(time, 90) %> <%= s.bomb? ? color(color(status, 41), 37) : color(status, status_color) %> <%= color(id, 90) %>'
|
26
|
+
# vim: fenc=utf8
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Termtter::Client
|
2
|
+
|
3
|
+
add_command /^confirm\s+(.*)/ do |m, t|
|
4
|
+
text = m[1]
|
5
|
+
unless text.empty?
|
6
|
+
pause
|
7
|
+
print "update? #{text} [Y/n] "
|
8
|
+
buf = Readline.readline("", false)
|
9
|
+
t.update_status(text) if /^y?$/i =~ buf
|
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
|
+
|
data/lib/plugin/favorite.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
module Termtter::Client
|
2
2
|
add_help 'favorite,fav ID', 'Favorite a status'
|
3
3
|
|
4
|
-
add_command %r'^(?:favorite|fav)\s+(\d+)$' do |m,t|
|
4
|
+
add_command %r'^(?:favorite|fav)\s+(\d+)$' do |m, t|
|
5
5
|
id = m[1]
|
6
6
|
res = t.favorite(id)
|
7
7
|
if res.code == '200'
|
@@ -11,12 +11,28 @@ module Termtter::Client
|
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
14
|
+
add_help 'favorite,fav USER', 'Favorite last status on the user'
|
15
|
+
|
16
|
+
add_command %r'^(?:favorite|fav)\s+@(.+)$' do |m, t|
|
17
|
+
user = m[1]
|
18
|
+
statuses = t.get_user_timeline(user)
|
19
|
+
unless statuses.empty?
|
20
|
+
id = statuses[0].id
|
21
|
+
res = t.favorite(id)
|
22
|
+
if res.code == '200'
|
23
|
+
puts "Favorited last status ##{id} on user @#{user}"
|
24
|
+
else
|
25
|
+
puts "Failed: #{res}"
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
14
30
|
if public_storage[:log]
|
15
31
|
add_help 'favorite,fav /WORD', 'Favorite a status by searching'
|
16
32
|
|
17
|
-
add_command %r'^(?:favorite|fav)\s+/(.+)$' do |m,t|
|
33
|
+
add_command %r'^(?:favorite|fav)\s+/(.+)$' do |m, t|
|
18
34
|
pat = Regexp.new(m[1])
|
19
|
-
statuses = public_storage[:log].select {
|
35
|
+
statuses = public_storage[:log].select {|s| pat =~ s.text }
|
20
36
|
if statuses.size == 1
|
21
37
|
status = statuses.first
|
22
38
|
res = t.favorite(status.id)
|
@@ -32,7 +48,12 @@ module Termtter::Client
|
|
32
48
|
end
|
33
49
|
|
34
50
|
add_completion do |input|
|
35
|
-
|
51
|
+
case input
|
52
|
+
when /^(favorite|fav)?\s+@(.*)/
|
53
|
+
find_user_candidates $2, "#{$1} @%s"
|
54
|
+
else
|
55
|
+
%w(favorite).grep(/^#{Regexp.quote input}/)
|
56
|
+
end
|
36
57
|
end
|
37
58
|
end
|
38
59
|
|
data/lib/plugin/fib.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
def fib(n)i=0;j=1;n.times{j=i+i=j};i end
|
2
2
|
module Termtter::Client
|
3
3
|
add_command /^fib\s+(\d+)/ do|m,t|t.update_status x="fib(#{n=m[1].to_i}) = #{fib n}"
|
4
|
-
puts"=> #{x}"end
|
4
|
+
puts"=> #{x}"end
|
5
|
+
add_command /^fibyou\s(\w+)\s(\d+)/ do|m,t|puts"=> #{t.update_status("@#{m[1]} fib(#{n=m[2].to_i}) = #{fib n}")}"end end
|
data/lib/plugin/filter.rb
CHANGED
@@ -9,8 +9,6 @@ module Termtter::Client
|
|
9
9
|
result = filter m[1].strip
|
10
10
|
rescue LoadError
|
11
11
|
result = false
|
12
|
-
else
|
13
|
-
public_storage[:filters] << m[1].strip
|
14
12
|
ensure
|
15
13
|
puts "=> #{result.inspect}"
|
16
14
|
end
|
@@ -63,4 +61,4 @@ end
|
|
63
61
|
# => true
|
64
62
|
# > list
|
65
63
|
# (15:48:02) termtter: hello
|
66
|
-
|
64
|
+
# vim: fenc=utf8
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module Termtter::Client
|
2
|
+
add_help 'follow USER', 'Follow user'
|
3
|
+
add_help 'leave USER', 'Leave user'
|
4
|
+
|
5
|
+
add_command %r'^(follow|leave)\s+(\w+)\s*$' do |m, t|
|
6
|
+
user = m[2]
|
7
|
+
res = t.social(user, m[1].to_sym)
|
8
|
+
if res.code == '200'
|
9
|
+
puts "#{m[1].capitalize}ed user @#{user}"
|
10
|
+
else
|
11
|
+
puts "Failed: #{res}"
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
add_completion do |input|
|
16
|
+
case input
|
17
|
+
when /^(follow|leave)?\s+(.*)/
|
18
|
+
find_user_candidates $2, "#{$1} %s"
|
19
|
+
else
|
20
|
+
%w[follow leave].grep(/^#{Regexp.quote input}/)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
module Termtter
|
26
|
+
class Twitter
|
27
|
+
def social(user, type)
|
28
|
+
type =
|
29
|
+
case type.to_sym
|
30
|
+
when :follow then 'create'
|
31
|
+
when :leave then 'destroy'
|
32
|
+
end
|
33
|
+
uri = "http://twitter.com/friendships/#{type}/#{user}.json"
|
34
|
+
|
35
|
+
Net::HTTP.start('twitter.com', 80) do |http|
|
36
|
+
http.request(post_request(uri))
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
data/lib/plugin/group.rb
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
configatron.set_default('plugins.group.groups', {})
|
2
|
+
|
3
|
+
module Termtter::Client
|
4
|
+
if public_storage[:log]
|
5
|
+
add_help 'group,g GROUPNAME', 'Filter by group members'
|
6
|
+
|
7
|
+
add_command /^(?:group|g)\s+(.+)/ do |m, t|
|
8
|
+
group_name = m[1].to_sym
|
9
|
+
group = configatron.plugins.group.groups[group_name]
|
10
|
+
statuses = group ? public_storage[:log].select { |s|
|
11
|
+
group.include?(s.user_screen_name)
|
12
|
+
} : []
|
13
|
+
call_hooks(statuses, :list_friends_timeline, t)
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.find_group_candidates(a, b)
|
17
|
+
configatron.plugins.group.groups.keys.map {|k| k.to_s}.
|
18
|
+
grep(/^#{Regexp.quote a}/).
|
19
|
+
map {|u| b % u }
|
20
|
+
end
|
21
|
+
|
22
|
+
add_completion do |input|
|
23
|
+
case input
|
24
|
+
when /^(group|g)?\s+(.+)/
|
25
|
+
find_group_candidates($2, "#{$1} %s")
|
26
|
+
when /^(group|g)\s+$/
|
27
|
+
configatron.plugins.group.groups.keys
|
28
|
+
else
|
29
|
+
%w(group).grep(/^#{Regexp.quote input}/)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
# group.rb
|
36
|
+
# plugin 'group'
|
37
|
+
# configatron.plugins.group.groups = {
|
38
|
+
# :rits => %w(hakobe isano hitode909)
|
39
|
+
# }
|
40
|
+
# NOTE: group.rb needs plugin/log
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require 'zlib'
|
2
|
+
|
3
|
+
configatron.plugins.history.
|
4
|
+
set_default('filename', '~/.termtter_history')
|
5
|
+
configatron.plugins.history.
|
6
|
+
set_default('keys', [:log, :users, :status_ids])
|
7
|
+
|
8
|
+
module Termtter::Client
|
9
|
+
def self.load_history
|
10
|
+
filename = File.expand_path(configatron.plugins.history.filename)
|
11
|
+
keys = configatron.plugins.history.keys
|
12
|
+
|
13
|
+
if File.exist?(filename)
|
14
|
+
begin
|
15
|
+
history = Marshal.load Zlib::Inflate.inflate(File.read(filename))
|
16
|
+
rescue Zlib::DataError
|
17
|
+
history = Marshal.load File.read(filename)
|
18
|
+
end
|
19
|
+
if history
|
20
|
+
keys.each do |key|
|
21
|
+
public_storage[key] = history[key] if history[key]
|
22
|
+
end
|
23
|
+
puts "history loaded(#{File.size(filename)}bytes)"
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.save_history
|
29
|
+
filename = File.expand_path(configatron.plugins.history.filename)
|
30
|
+
keys = configatron.plugins.history.keys
|
31
|
+
history = { }
|
32
|
+
keys.each do |key|
|
33
|
+
history[key] = public_storage[key]
|
34
|
+
end
|
35
|
+
|
36
|
+
File.open(filename, 'w') do |f|
|
37
|
+
f.write Zlib::Deflate.deflate(Marshal.dump(history))
|
38
|
+
end
|
39
|
+
puts "history saved(#{File.size(filename)}bytes)"
|
40
|
+
end
|
41
|
+
|
42
|
+
add_hook do |statuses, event|
|
43
|
+
case event
|
44
|
+
when :initialize
|
45
|
+
load_history
|
46
|
+
when :exit
|
47
|
+
save_history
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
# history.rb
|
53
|
+
# save log to file
|