jugyo-termtter 0.8.14 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (115) hide show
  1. data/README.rdoc +8 -8
  2. data/Rakefile +3 -5
  3. data/lib/{plugin → plugins}/april_fool.rb +0 -0
  4. data/lib/plugins/bomb.rb +42 -0
  5. data/lib/{plugin → plugins}/clear.rb +0 -0
  6. data/lib/{plugin → plugins}/confirm.rb +0 -0
  7. data/lib/{plugin → plugins}/cool.rb +0 -0
  8. data/lib/{plugin → plugins}/devel.rb +0 -0
  9. data/lib/{filter → plugins}/en2ja.rb +1 -1
  10. data/lib/plugins/english.rb +25 -0
  11. data/lib/{plugin → plugins}/erb.rb +0 -0
  12. data/lib/{filter → plugins}/expand-tinyurl.rb +6 -6
  13. data/lib/plugins/favorite.rb +63 -0
  14. data/lib/plugins/fib.rb +28 -0
  15. data/lib/{filter/fib.rb → plugins/fib_filter.rb} +1 -2
  16. data/lib/{plugin → plugins}/filter.rb +0 -0
  17. data/lib/{plugin → plugins}/graduatter.rb +1 -2
  18. data/lib/{plugin → plugins}/grass.rb +2 -2
  19. data/lib/{plugin → plugins}/group.rb +9 -9
  20. data/lib/{plugin → plugins}/growl.rb +11 -12
  21. data/lib/{plugin → plugins}/hatebu.rb +5 -5
  22. data/lib/{plugin → plugins}/history.rb +13 -13
  23. data/lib/plugins/ignore.rb +19 -0
  24. data/lib/plugins/keyword.rb +18 -0
  25. data/lib/{plugin → plugins}/log.rb +18 -12
  26. data/lib/{plugin → plugins}/me.rb +1 -2
  27. data/lib/{plugin → plugins}/modify_arg_hook_sample.rb +0 -0
  28. data/lib/{plugin → plugins}/msagent.rb +1 -1
  29. data/lib/plugins/multi_reply.rb +27 -0
  30. data/lib/{plugin → plugins}/notify-send.rb +1 -1
  31. data/lib/{plugin → plugins}/otsune.rb +0 -0
  32. data/lib/plugins/outputz.rb +33 -0
  33. data/lib/{plugin → plugins}/pause.rb +0 -0
  34. data/lib/{plugin → plugins}/plugin.rb +0 -0
  35. data/lib/{plugin → plugins}/post_exec_hook_sample.rb +0 -0
  36. data/lib/{plugin → plugins}/pre_exec_hook_sample.rb +0 -0
  37. data/lib/{plugin → plugins}/primes.rb +9 -2
  38. data/lib/plugins/quicklook.rb +41 -0
  39. data/lib/{plugin → plugins}/random.rb +0 -0
  40. data/lib/{plugin → plugins}/reblog.rb +3 -3
  41. data/lib/{plugin → plugins}/reload.rb +0 -0
  42. data/lib/{filter → plugins}/reply.rb +0 -0
  43. data/lib/{filter → plugins}/reverse.rb +1 -1
  44. data/lib/{plugin → plugins}/say.rb +1 -1
  45. data/lib/{plugin → plugins}/scrape.rb +4 -4
  46. data/lib/plugins/screen-notify.rb +13 -0
  47. data/lib/plugins/screen.rb +24 -0
  48. data/lib/{plugin → plugins}/shell.rb +0 -0
  49. data/lib/{plugin → plugins}/sl.rb +4 -4
  50. data/lib/plugins/spam.rb +13 -0
  51. data/lib/{plugin → plugins}/standard_plugins.rb +72 -18
  52. data/lib/plugins/stdout.rb +80 -0
  53. data/lib/plugins/storage/DB.rb +37 -0
  54. data/lib/plugins/storage/status.rb +48 -0
  55. data/lib/plugins/storage/status_mook.rb +30 -0
  56. data/lib/plugins/storage.rb +47 -0
  57. data/lib/plugins/system_status.rb +33 -0
  58. data/lib/{plugin → plugins}/translation.rb +15 -5
  59. data/lib/{plugin → plugins}/update_editor.rb +6 -6
  60. data/lib/plugins/uri-open.rb +64 -0
  61. data/lib/{filter → plugins}/url_addspace.rb +0 -0
  62. data/lib/{plugin → plugins}/wassr_post.rb +1 -1
  63. data/lib/{plugin → plugins}/yhara.rb +1 -1
  64. data/lib/plugins/yhara_filter.rb +8 -0
  65. data/lib/plugins/yonda.rb +21 -0
  66. data/lib/termtter/api.rb +28 -2
  67. data/lib/termtter/client.rb +90 -102
  68. data/lib/termtter/command.rb +32 -31
  69. data/lib/termtter/config.rb +64 -0
  70. data/lib/termtter/connection.rb +9 -7
  71. data/lib/termtter/hook.rb +11 -2
  72. data/lib/termtter/optparse.rb +14 -0
  73. data/lib/termtter/version.rb +1 -1
  74. data/lib/termtter.rb +19 -22
  75. data/spec/plugin/english_spec.rb +19 -0
  76. data/spec/plugin/favorite_spec.rb +10 -0
  77. data/spec/plugin/fib_spec.rb +1 -2
  78. data/spec/plugin/pause_spec.rb +8 -0
  79. data/spec/plugin/plugin_spec.rb +1 -1
  80. data/spec/plugin/primes_spec.rb +15 -0
  81. data/spec/plugin/sl_spec.rb +8 -0
  82. data/spec/plugin/spam_spec.rb +0 -13
  83. data/spec/plugin/standard_plugins_spec.rb +0 -7
  84. data/spec/plugin/storage/DB_spec.rb +12 -0
  85. data/spec/plugin/storage/status_spec.rb +24 -0
  86. data/spec/spec_helper.rb +3 -0
  87. data/spec/termtter/client_spec.rb +63 -1
  88. data/spec/termtter/command_spec.rb +6 -68
  89. data/spec/termtter/config_spec.rb +111 -0
  90. data/spec/termtter/hook_spec.rb +69 -0
  91. data/spec/termtter_spec.rb +22 -34
  92. metadata +81 -72
  93. data/lib/filter/english.rb +0 -8
  94. data/lib/filter/ignore.rb +0 -19
  95. data/lib/filter/yhara.rb +0 -20
  96. data/lib/plugin/bomb.rb +0 -29
  97. data/lib/plugin/english.rb +0 -59
  98. data/lib/plugin/favorite.rb +0 -75
  99. data/lib/plugin/fib.rb +0 -8
  100. data/lib/plugin/follow.rb +0 -60
  101. data/lib/plugin/keyword.rb +0 -18
  102. data/lib/plugin/multi_reply.rb +0 -36
  103. data/lib/plugin/outputz.rb +0 -35
  104. data/lib/plugin/quicklook.rb +0 -38
  105. data/lib/plugin/screen.rb +0 -24
  106. data/lib/plugin/spam.rb +0 -9
  107. data/lib/plugin/stdout.rb +0 -63
  108. data/lib/plugin/system_status.rb +0 -33
  109. data/lib/plugin/uri-open.rb +0 -69
  110. data/lib/plugin/yonda.rb +0 -20
  111. data/lib/termtter/status.rb +0 -26
  112. data/lib/termtter/twitter.rb +0 -188
  113. data/lib/termtter/user.rb +0 -13
  114. data/spec/termtter/user_spec.rb +0 -27
  115. data/test/test_termtter.rb +0 -86
data/README.rdoc CHANGED
@@ -17,7 +17,8 @@ Run:
17
17
  == REQUIREMENTS:
18
18
 
19
19
  * json_pure
20
- * configatron
20
+ * termcolor
21
+ * rubytter
21
22
 
22
23
  == INSTALL:
23
24
 
@@ -40,15 +41,15 @@ You can edit the file anytime.
40
41
 
41
42
  vim ~/.termtter
42
43
 
43
- configatron.user_name = 'USERNAME'
44
- configatron.password = 'PASSWORD'
44
+ config.user_name = 'USERNAME'
45
+ config.password = 'PASSWORD'
45
46
 
46
47
  If you would like to use proxy server, add configurations like this:
47
48
 
48
- configatron.proxy.host = 'PROXYHOST'
49
- configatron.proxy.port = 'PROXYPORT'
50
- configatron.proxy.user_name = 'USERNAME'
51
- configatron.proxy.password = 'PASSWORD'
49
+ config.proxy.host = 'PROXYHOST'
50
+ config.proxy.port = 'PROXYPORT'
51
+ config.proxy.user_name = 'USERNAME'
52
+ config.proxy.password = 'PASSWORD'
52
53
 
53
54
  To update the config, just restart your termtter proccess.
54
55
 
@@ -62,7 +63,6 @@ http://wiki.github.com/jugyo/termtter/home (in Japanese)
62
63
 
63
64
  == TODO:
64
65
 
65
- - rubytter を使うようにする
66
66
  - filter と plugin を統一する
67
67
  - plugin => plugins (ディレクトリ名変更)
68
68
  - $HOME 以下に plugin 用のディレクトリを置けるようにする
data/Rakefile CHANGED
@@ -1,6 +1,4 @@
1
1
  $:.unshift File.dirname(__FILE__) + '/lib'
2
- require 'termtter'
3
-
4
2
  require 'spec/rake/spectask'
5
3
  desc 'run all specs'
6
4
  Spec::Rake::SpecTask.new do |t|
@@ -10,6 +8,7 @@ end
10
8
 
11
9
  desc 'Generate gemspec'
12
10
  task :gemspec do |t|
11
+ require 'termtter'
13
12
  open('termtter.gemspec', "wb" ) do |file|
14
13
  file << <<-EOS
15
14
  Gem::Specification.new do |s|
@@ -25,9 +24,9 @@ Gem::Specification.new do |s|
25
24
  Rakefile )
26
25
  s.executables = ["kill_termtter", "termtter"]
27
26
  s.add_dependency("json_pure", ">= 1.1.3")
28
- s.add_dependency("configatron", ">= 2.2.2")
29
27
  s.add_dependency("highline", ">= 1.5.0")
30
28
  s.add_dependency("termcolor", ">= 0.3.1")
29
+ s.add_dependency("rubytter", ">= 0.4.8")
31
30
  s.authors = %w(jugyo ujihisa)
32
31
  s.email = 'jugyo.org@gmail.com'
33
32
  s.homepage = 'http://wiki.github.com/jugyo/termtter'
@@ -49,9 +48,8 @@ end
49
48
  namespace :gem do
50
49
  desc 'Install needed gems'
51
50
  task :install do
52
- %w[ json_pure configatron highline termcolor ].each do |gem|
51
+ %w[ json_pure highline termcolor ].each do |gem|
53
52
  sh "sudo gem install #{gem} -r"
54
53
  end
55
54
  end
56
55
  end
57
-
File without changes
@@ -0,0 +1,42 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ module Termtter
4
+
5
+ module Client
6
+ config.plugins.bomb.color.set_default :foreground, 'white'
7
+ config.plugins.bomb.color.set_default :background, 'red'
8
+
9
+ add_hook do |statuses, event|
10
+ case event
11
+ when :post_filter
12
+ fg = config.plugins.bomb.color.foreground
13
+ bg = config.plugins.bomb.color.background
14
+ statuses = [statuses] unless statuses.instance_of? Array
15
+ statuses.each do |status|
16
+ if /爆発|bomb/ =~ status.text
17
+ status.text = "<on_#{bg}><#{fg}>#{status.text}</#{fg}></on_#{bg}>"
18
+ end
19
+ end
20
+ end
21
+ end
22
+
23
+ register_command(
24
+ :name => :bomb, :aliases => [],
25
+ :exec_proc => lambda {|arg|
26
+ text = "#{arg.strip} 爆発しろ!"
27
+ Termtter::API::twitter.update(text)
28
+ puts "=> #{text}"
29
+ },
30
+ :help => ['bomb WORD', 'Bomb it']
31
+ )
32
+ end
33
+ end
34
+
35
+ # bomb.rb
36
+ # Bomb it!
37
+ #
38
+ # See http://gyazo.com/4b33517380673d92f51a52e675ecdb02.png .
39
+ # config.plugins.bomb.color.foreground = 'white'
40
+ # config.plugins.bomb.color.background = 'red'
41
+ #
42
+ # vim: fenc=utf8
File without changes
File without changes
File without changes
File without changes
@@ -2,7 +2,7 @@
2
2
 
3
3
  plugin 'translation'
4
4
 
5
- Termtter::Client.add_filter do |statuses|
5
+ Termtter::Client.add_filter do |statuses, event|
6
6
  statuses.each do |s|
7
7
  if s.english?
8
8
  s.text = translate(s.text, 'en|ja')
@@ -0,0 +1,25 @@
1
+ # -*- coding: utf-8 -*-
2
+ # vim: set fenc=utf-8
3
+
4
+ module Termtter::English
5
+ # english? :: String -> Boolean
6
+ def self.english?(message)
7
+ /[一-龠]+|[ぁ-ん]+|[ァ-ヴー]+|[a-zA-Z0-9]+/ !~ message
8
+ end
9
+ end
10
+
11
+ Termtter::Client.add_filter do |statuses, event|
12
+ config.plugins.english.set_default(:only, [])
13
+ statuses.select {|i|
14
+ !config.plugins.english.only.include?(event) ||
15
+ Termtter::English.english?(i.text)
16
+ }
17
+ end
18
+
19
+ # english_filter.rb
20
+ # select English posts only
21
+ #
22
+ # config sample:
23
+ # plugin 'english'
24
+ # or,
25
+ # plugin 'english', :only => [:list_friends_timeline, :update_friends_timeline]
File without changes
@@ -1,7 +1,7 @@
1
1
  # -*- coding: utf-8 -*-
2
2
 
3
3
  module Termtter::Client
4
- add_filter do |statuses|
4
+ add_filter do |statuses, event|
5
5
  statuses.each do |s|
6
6
  s.text.gsub!(%r'(http://tinyurl\.com(/[\w/]+))') do |m|
7
7
  expand_tinyurl($2) || $1
@@ -13,11 +13,11 @@ end
13
13
 
14
14
  def expand_tinyurl(path)
15
15
  http_class = Net::HTTP
16
- unless configatron.proxy.host.empty?
17
- http_class = Net::HTTP::Proxy(configatron.proxy.host,
18
- configatron.proxy.port,
19
- configatron.proxy.user_name,
20
- configatron.proxy.password)
16
+ unless config.proxy.host.nil? or config.proxy.host.empty?
17
+ http_class = Net::HTTP::Proxy(config.proxy.host,
18
+ config.proxy.port,
19
+ config.proxy.user_name,
20
+ config.proxy.password)
21
21
  end
22
22
  res = http_class.new('tinyurl.com').head(path)
23
23
  res['Location']
@@ -0,0 +1,63 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ def create_favorite(id)
4
+ r = Termtter::API.twitter.favorite id
5
+ puts "Favorited status ##{r.id} on user @#{r.user.screen_name} #{r.text}"
6
+ end
7
+
8
+ module Termtter::Client
9
+ register_command(
10
+ :name => :favorite, :aliases => [:fav],
11
+ :exec_proc => lambda {|arg|
12
+ id = 0
13
+ case arg
14
+ when /^\d+/
15
+ id = arg.to_i
16
+ when /^@([A-Za-z0-9_]+)/
17
+ user = $1
18
+ statuses = Termtter::API.twitter.user_timeline(user)
19
+ return if statuses.empty?
20
+ id = statuses[0].id
21
+ when /^\/(.*)$/
22
+ word = $1
23
+ raise "Not implemented yet."
24
+ else
25
+ return
26
+ end
27
+
28
+ create_favorite id
29
+ },
30
+ :completion_proc => lambda {|cmd, arg|
31
+ case arg
32
+ when /@(.*)/
33
+ find_user_candidates $1, "#{cmd} @%s"
34
+ when /(\d+)/
35
+ find_status_ids(arg).map{|id| "#{cmd} #{$1}"}
36
+ else
37
+ %w(favorite).grep(/^#{Regexp.quote arg}/)
38
+ end
39
+ },
40
+ :help => ['favorite,fav (ID|@USER|/WORD)', 'Favorite a status']
41
+ )
42
+
43
+ # TBD: Implement this when database support comes.
44
+ #
45
+ # if public_storage[:log]
46
+ # add_help 'favorite,fav /WORD', 'Favorite a status by searching'
47
+ #
48
+ # add_command %r'^(?:favorite|fav)\s+/(.+)$' do |m, t|
49
+ # pat = Regexp.new(m[1])
50
+ # statuses = public_storage[:log].select {|s| pat =~ s.text }
51
+ # if statuses.size == 1
52
+ # status = statuses.first
53
+ # res = t.favorite(status.id)
54
+ # if res.code == '200'
55
+ # puts %Q(Favorited "#{status.user.screen_name}: #{status.text}")
56
+ # else
57
+ # puts "Failed: #{res}"
58
+ # end
59
+ # else
60
+ # puts "#{pat} does not match single status"
61
+ # end
62
+ # end
63
+ end
@@ -0,0 +1,28 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ def fib(n)i=0;j=1;n.times{j=i+i=j};i end
4
+ module Termtter::Client
5
+ register_command(
6
+ :name => :fib,
7
+ :exec_proc => lambda {|arg|
8
+ n = arg.to_i
9
+ text = "fib(#{n}) = #{fib n}"
10
+ Termtter::API.twitter.update(text)
11
+ puts "=> " << text
12
+ }
13
+ )
14
+ register_command(
15
+ :name => :fibyou,
16
+ :exec_proc => lambda {|arg|
17
+ /(\w+)\s(\d+)/ =~ arg
18
+ name = $1
19
+ n = $2.to_i
20
+ text = "@#{name} fib(#{n}) = #{fib n}"
21
+ Termtter::API.twitter.update(text)
22
+ puts "=> " << text
23
+ },
24
+ :completion_proc => lambda {|cmd, arg|
25
+ find_user_candidates arg, "#{cmd} %s"
26
+ }
27
+ )
28
+ end
@@ -2,7 +2,7 @@
2
2
 
3
3
  def fib(n)i=0;j=1;n.times{j=i+i=j};i end
4
4
  module Termtter::Client
5
- add_filter do |statuses|
5
+ add_filter do |statuses, _|
6
6
  statuses.each do |s|
7
7
  s.text.gsub!(/(\d+)/) do |m|
8
8
  n = $1.to_i
@@ -12,4 +12,3 @@ module Termtter::Client
12
12
  statuses
13
13
  end
14
14
  end
15
-
File without changes
@@ -1,9 +1,8 @@
1
1
  # -*- coding: utf-8 -*-
2
2
 
3
- twitter = Termtter::Twitter.new(configatron.user_name, configatron.password)
4
3
  Thread.start do
5
4
  100.times do |i|
6
- twitter.update_status(
5
+ Twitter::API.twitter.update(
7
6
  "I decided not to use twitter so as not to leave university before I complete the dissertation#{i.odd? ? '!' : '.'}")
8
7
  end
9
8
  end
@@ -2,14 +2,14 @@
2
2
  module Termtter
3
3
  module Client
4
4
 
5
- configatron.plugins.grass.set_default(:rate, 0)
5
+ config.plugins.grass.set_default(:rate, 0)
6
6
 
7
7
  register_command(
8
8
  :name => :w, :aliases => [:grass],
9
9
  :exec_proc => lambda {|arg|
10
10
  arg, rate = arg.split(/ /)
11
11
  count = arg =~ /^[0-9]+$/ ? arg.to_i : 3
12
- rate ||= configatron.plugins.grass.rate
12
+ rate ||= config.plugins.grass.rate
13
13
  grow = (count * rate.to_i).quo(100).round
14
14
  grasses = ('w' * (count-grow) + 'W' * grow).split(//).shuffle.join
15
15
  call_commands("update #{grasses}")
@@ -4,20 +4,20 @@ module Termtter
4
4
  class Status
5
5
  def is_member?(group = nil)
6
6
  if group
7
- configatron.plugins.group.groups[group].include? self.user_screen_name
7
+ config.plugins.group.groups[group].include? self.user_screen_name
8
8
  else
9
- configatron.plugins.group.groups.values.flatten.include? self.user_screen_name
9
+ config.plugins.group.groups.values.flatten.include? self.user_screen_name
10
10
  end
11
11
  end
12
12
  end
13
13
  end
14
14
 
15
15
  module Termtter::Client
16
- configatron.plugins.group.
16
+ config.plugins.group.
17
17
  set_default(:groups, {})
18
18
 
19
19
  def self.find_group_candidates(a, b)
20
- configatron.plugins.group.groups.keys.map {|k| k.to_s}.
20
+ config.plugins.group.groups.keys.map {|k| k.to_s}.
21
21
  grep(/^#{Regexp.quote a}/).
22
22
  map {|u| b % u }
23
23
  end
@@ -29,16 +29,16 @@ module Termtter::Client
29
29
  unless arg.empty?
30
30
  group_name = arg.to_sym
31
31
  if group_name == :all
32
- group = configatron.plugins.group.groups.values.flatten.uniq
32
+ group = config.plugins.group.groups.values.flatten.uniq
33
33
  else
34
- group = configatron.plugins.group.groups[group_name]
34
+ group = config.plugins.group.groups[group_name]
35
35
  end
36
36
  statuses = group ? public_storage[:log].select { |s|
37
- group.include?(s.user_screen_name)
37
+ group.include?(s.user.screen_name)
38
38
  } : []
39
39
  call_hooks(statuses, :search)
40
40
  else
41
- configatron.plugins.group.groups.each_pair do |key, value|
41
+ config.plugins.group.groups.each_pair do |key, value|
42
42
  puts "#{key}: #{value.join(',')}"
43
43
  end
44
44
  end
@@ -53,7 +53,7 @@ end
53
53
 
54
54
  # group.rb
55
55
  # plugin 'group'
56
- # configatron.plugins.group.groups = {
56
+ # config.plugins.group.groups = {
57
57
  # :rits => %w(hakobe isano hitode909)
58
58
  # }
59
59
  # NOTE: group.rb needs plugin/log
@@ -12,11 +12,11 @@ rescue LoadError
12
12
  growl = nil
13
13
  end
14
14
 
15
- configatron.plugins.growl.set_default(:icon_cache_dir, "#{Dir.tmpdir}/termtter-icon-cache-dir")
16
- FileUtils.mkdir_p(configatron.plugins.growl.icon_cache_dir) unless File.exist?(configatron.plugins.growl.icon_cache_dir)
15
+ config.plugins.growl.set_default(:icon_cache_dir, "#{Dir.tmpdir}/termtter-icon-cache-dir")
16
+ FileUtils.mkdir_p(config.plugins.growl.icon_cache_dir) unless File.exist?(config.plugins.growl.icon_cache_dir)
17
17
 
18
18
  def get_icon_path(s)
19
- cache_file = "%s/%s%s" % [ configatron.plugins.growl.icon_cache_dir,
19
+ cache_file = "%s/%s%s" % [ config.plugins.growl.icon_cache_dir,
20
20
  s.user_screen_name,
21
21
  File.extname(s.user_profile_image_url) ]
22
22
  if File.exist?(cache_file) && (File.atime(cache_file) + 24*60*60) > Time.now
@@ -37,12 +37,12 @@ Thread.new do
37
37
  begin
38
38
  if s = queue.pop
39
39
  unless growl
40
- 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']
41
41
  #icon_path = get_icon_path(s)
42
42
  #arg += ['--image', icon_path] if icon_path
43
43
  system *arg
44
44
  else
45
- growl.notify "termtter status notification", s.text, s.user_screen_name
45
+ growl.notify "termtter status notification", s.text, s.user.screen_name
46
46
  end
47
47
  end
48
48
  rescue => e
@@ -53,10 +53,9 @@ Thread.new do
53
53
  end
54
54
  end
55
55
 
56
- Termtter::Client.add_hook do |statuses, event|
57
- if !statuses.empty? && event == :update_friends_timeline
58
- statuses.reverse.each do |s|
59
- queue << s
60
- end
61
- end
62
- end
56
+ Termtter::Client.register_hook(:name => :growl,
57
+ :points => [:post_exec__update_timeline],
58
+ :exec_proc => lambda { |cmd, arg, result|
59
+ result.reverse.each { |s| queue << s }
60
+ }
61
+ )
@@ -17,11 +17,11 @@ module Termtter::Client
17
17
  status = t.show(id).first
18
18
  end
19
19
  auth = auth = Atompub::Auth::Wsse.new({
20
- :username => configatron.plugins.hatebu.username,
21
- :password => configatron.plugins.hatebu.password,
20
+ :username => config.plugins.hatebu.username,
21
+ :password => config.plugins.hatebu.password,
22
22
  })
23
23
  link = Atom::Link.new({
24
- :href => "http://twitter.com/#{status.user_screen_name}/status/#{status.id}",
24
+ :href => "http://twitter.com/#{status.user.screen_name}/status/#{status.id}",
25
25
  :rel => 'related',
26
26
  :type => 'text/html',
27
27
  })
@@ -53,7 +53,7 @@ end
53
53
  # hatebu.rb
54
54
  # hatena bookmark it!
55
55
  #
56
- # configatron.plugins.hatebu.username = 'your-username-on-hatena'
57
- # configatron.plugins.hatebu.password = 'your-password-on-hatena'
56
+ # config.plugins.hatebu.username = 'your-username-on-hatena'
57
+ # config.plugins.hatebu.password = 'your-password-on-hatena'
58
58
  #
59
59
  # hatebu 1114860346 [termtter][<82>±<82>ê<82>Í<82>·<82>²<82>¢]mattn++
@@ -2,21 +2,21 @@
2
2
 
3
3
  require 'zlib'
4
4
 
5
- configatron.plugins.history.
5
+ config.plugins.history.
6
6
  set_default(:filename, '~/.termtter_history')
7
- configatron.plugins.history.
7
+ config.plugins.history.
8
8
  set_default(:keys, [:log, :users, :status_ids])
9
- configatron.plugins.history.
9
+ config.plugins.history.
10
10
  set_default(:max_of_history, 100)
11
- configatron.plugins.history.
11
+ config.plugins.history.
12
12
  set_default(:enable_autosave, true)
13
- configatron.plugins.history.
13
+ config.plugins.history.
14
14
  set_default(:autosave_interval, 3600)
15
15
 
16
16
  module Termtter::Client
17
17
  def self.load_history
18
- filename = File.expand_path(configatron.plugins.history.filename)
19
- keys = configatron.plugins.history.keys
18
+ filename = File.expand_path(config.plugins.history.filename)
19
+ keys = config.plugins.history.keys
20
20
 
21
21
  if File.exist?(filename)
22
22
  begin
@@ -33,13 +33,13 @@ module Termtter::Client
33
33
  end
34
34
 
35
35
  def self.save_history
36
- filename = File.expand_path(configatron.plugins.history.filename)
37
- keys = configatron.plugins.history.keys
36
+ filename = File.expand_path(config.plugins.history.filename)
37
+ keys = config.plugins.history.keys
38
38
  history = { }
39
39
  keys.each do |key|
40
40
  history[key] = public_storage[key]
41
41
  end
42
- max_of_history = configatron.plugins.history.max_of_history
42
+ max_of_history = config.plugins.history.max_of_history
43
43
  history[:history] = Readline::HISTORY.to_a.reverse.uniq.reverse
44
44
  if history[:history].size > max_of_history
45
45
  history[:history] = history[:history][-max_of_history..-1]
@@ -60,9 +60,9 @@ module Termtter::Client
60
60
  end
61
61
  end
62
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
63
+ if config.plugins.history.enable_autosave
64
+ Termtter::Client.add_task(:interval => config.plugins.history.autosave_interval,
65
+ :after => config.plugins.history.autosave_interval) do
66
66
  save_history
67
67
  end
68
68
  end
@@ -0,0 +1,19 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+
4
+ config.filters.ignore.set_default(:words, [])
5
+
6
+ module Termtter::Client
7
+ add_filter do |statuses, _|
8
+ ignore_words = config.filters.ignore.words
9
+ statuses.delete_if do |s|
10
+ ignore_words.any? {|i| i =~ s.text }
11
+ end
12
+ end
13
+ end
14
+
15
+ # filter/ignore.rb
16
+ # ignore words
17
+ # setting
18
+ # config.filters.ignore.words = [ /ignore/, /words/ ]
19
+
@@ -0,0 +1,18 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ config.set_default('plugins.keyword.keywords', [])
4
+
5
+ module Termtter
6
+ class Status
7
+ def has_keyword?
8
+ config.plugins.keyword.keywords.find { |k| k === self.text }
9
+ end
10
+ alias :has_keyword :has_keyword?
11
+ end
12
+ end
13
+
14
+ # keyword.rb
15
+ # provides a keyword watching method
16
+ # example config
17
+ # config.plugins.stdout.timeline_format = '<%= color(time, 90) %> <%= color(status, s.has_keyword ? 4 : status_color) %> <%= color(id, 90) %>'
18
+ # config.plugins.keyword.keywords = [ /motemen/ ]
@@ -2,18 +2,30 @@
2
2
 
3
3
  module Termtter::Client
4
4
  public_storage[:log] = []
5
- configatron.plugins.log.set_default('max_size', 1/0.0)
6
- configatron.plugins.log.set_default('print_max_size', 30)
5
+ public_storage[:tweet] = { }
6
+ config.plugins.log.set_default('max_size', 1/0.0)
7
+ config.plugins.log.set_default('print_max_size', 30)
7
8
 
8
9
  add_hook do |statuses, event|
9
10
  case event
10
11
  when :pre_filter
12
+ # log(sequential storage)
11
13
  public_storage[:log] += statuses
12
- max_size = configatron.plugins.log.max_size
14
+ max_size = config.plugins.log.max_size
13
15
  if public_storage[:log].size > max_size
14
16
  public_storage[:log] = public_storage[:log][-max_size..-1]
15
17
  end
16
18
  public_storage[:log] = public_storage[:log].uniq.sort_by{|a| a.created_at} if statuses.first
19
+
20
+ # tweet(storage for each user)
21
+
22
+ statuses.each do |s|
23
+ public_storage[:tweet][s.user.screen_name] = [] unless public_storage[:tweet][s.user.screen_name]
24
+ public_storage[:tweet][s.user.screen_name] << s
25
+ if public_storage[:tweet].size > max_size
26
+ public_storage[:tweet] = public_storage[:tweet][-max_size..-1]
27
+ end
28
+ end
17
29
  end
18
30
  end
19
31
 
@@ -23,15 +35,15 @@ module Termtter::Client
23
35
  if arg.empty?
24
36
  # log
25
37
  statuses = public_storage[:log]
26
- print_max = configatron.plugins.log.print_max_size
38
+ print_max = config.plugins.log.print_max_size
27
39
  print_max = 0 if statuses.size < print_max
28
40
  call_hooks(statuses[-print_max..-1], :search)
29
41
  else
30
42
  # log (user) (max)
31
43
  vars = arg.split(' ')
32
- print_max = vars.last =~ /^\d+$/ ? vars.pop.to_i : configatron.plugins.log.print_max_size
44
+ print_max = vars.last =~ /^\d+$/ ? vars.pop.to_i : config.plugins.log.print_max_size
33
45
  id = vars
34
- statuses = id.first ? public_storage[:log].select{ |s| id.include? s.user_screen_name} : public_storage[:log]
46
+ statuses = id.first ? public_storage[:log].select{ |s| id.include? s.user.screen_name} : public_storage[:log]
35
47
  print_max = 0 if statuses.size < print_max
36
48
  call_hooks(statuses[-print_max..-1], :search)
37
49
  end
@@ -54,10 +66,4 @@ module Termtter::Client
54
66
  :help => [ 'search_log WORD', 'Search log for WORD' ]
55
67
  )
56
68
 
57
- add_command %r'^/(.+)' do |m, t|
58
- warn '/WORD command will be removed. Use search_log command instead.'
59
- pat = Regexp.new(m[1])
60
- statuses = public_storage[:log].select { |s| s.text =~ pat }
61
- call_hooks(statuses, :search, t)
62
- end
63
69
  end
@@ -3,8 +3,7 @@ module Termtter::Client
3
3
  register_command(
4
4
  :name => :me, :aliases => [],
5
5
  :exec_proc => lambda {|arg|
6
- myname = configatron.user_name
7
- call_hooks(Termtter::API.twitter.get_user_timeline(myname), :list_user_timeline)
6
+ call_commands('list ' + config.user_name)
8
7
  },
9
8
  :help => ['me', 'show my timeline']
10
9
  )
File without changes
@@ -17,7 +17,7 @@ Termtter::Client.add_hook do |statuses, event, t|
17
17
  GC.start
18
18
  elsif !statuses.empty? && event == :update_friends_timeline
19
19
  statuses.reverse.each do |s|
20
- req = achar.speak("#{s.user_screen_name}: #{s.text}".tosjis)
20
+ req = achar.speak("#{s.user.screen_name}: #{s.text}".tosjis)
21
21
  sleep 3
22
22
  WIN32OLE_EVENT.message_loop
23
23
  achar.stop(req)