jugyo-termtter 0.7.6 → 0.7.7

Sign up to get free protection for your applications and to get access to all the features.
data/Manifest.txt CHANGED
@@ -8,35 +8,58 @@ lib/filter/en2ja.rb
8
8
  lib/filter/english.rb
9
9
  lib/filter/expand-tinyurl.rb
10
10
  lib/filter/fib.rb
11
+ lib/filter/ignore.rb
12
+ lib/filter/reply.rb
11
13
  lib/filter/reverse.rb
12
14
  lib/filter/yhara.rb
13
15
  lib/plugin/bomb.rb
14
16
  lib/plugin/confirm.rb
17
+ lib/plugin/cool.rb
15
18
  lib/plugin/english.rb
16
19
  lib/plugin/erb.rb
17
20
  lib/plugin/favorite.rb
18
21
  lib/plugin/fib.rb
19
22
  lib/plugin/filter.rb
20
23
  lib/plugin/follow.rb
24
+ lib/plugin/graduatter.rb
21
25
  lib/plugin/group.rb
22
26
  lib/plugin/growl.rb
27
+ lib/plugin/hatebu.rb
23
28
  lib/plugin/history.rb
24
29
  lib/plugin/keyword.rb
25
30
  lib/plugin/log.rb
31
+ lib/plugin/msagent.rb
32
+ lib/plugin/multi_reply.rb
26
33
  lib/plugin/notify-send.rb
34
+ lib/plugin/otsune.rb
35
+ lib/plugin/outputz.rb
27
36
  lib/plugin/plugin.rb
37
+ lib/plugin/primes.rb
28
38
  lib/plugin/quicklook.rb
39
+ lib/plugin/reblog.rb
29
40
  lib/plugin/reload.rb
30
41
  lib/plugin/say.rb
42
+ lib/plugin/scrape.rb
43
+ lib/plugin/screen.rb
31
44
  lib/plugin/shell.rb
32
45
  lib/plugin/sl.rb
33
46
  lib/plugin/spam.rb
34
47
  lib/plugin/standard_plugins.rb
35
48
  lib/plugin/stdout.rb
49
+ lib/plugin/system_status.rb
36
50
  lib/plugin/translation.rb
51
+ lib/plugin/update_editor.rb
37
52
  lib/plugin/uri-open.rb
53
+ lib/plugin/wassr_post.rb
38
54
  lib/plugin/yhara.rb
55
+ lib/plugin/yonda.rb
39
56
  lib/termtter.rb
57
+ lib/termtter/api.rb
58
+ lib/termtter/client.rb
59
+ lib/termtter/command.rb
60
+ lib/termtter/connection.rb
61
+ lib/termtter/status.rb
62
+ lib/termtter/twitter.rb
40
63
  run_termtter.rb
41
64
  test/friends_timeline.json
42
65
  test/search.json
data/bin/termtter CHANGED
@@ -3,44 +3,5 @@
3
3
  $KCODE = 'u'
4
4
 
5
5
  require 'rubygems'
6
- require 'configatron'
7
- require 'highline'
8
6
  require 'termtter'
9
- plugin 'standard_plugins'
10
- plugin 'stdout'
11
-
12
- conf_file = File.expand_path('~/.termtter')
13
- if File.exist? conf_file
14
- load conf_file
15
- else
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
-
21
- File.open(File.expand_path('~/.termtter'), 'w') {|io|
22
- plugins = Dir.glob(File.dirname(__FILE__) + "/../lib/plugin/*.rb").map {|f|
23
- f.match(%r|lib/plugin/(.*?).rb$|)[1]
24
- }
25
- plugins -= %w[stdout standard_plugins]
26
- plugins.each do |p|
27
- io.puts "#plugin '#{p}'"
28
- end
29
-
30
- io.puts
31
- io.puts "configatron.user_name = '#{username}'"
32
- io.puts "configatron.password = '#{password}'"
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'"
38
- io.puts
39
- io.puts "# vim: set filetype=ruby"
40
- }
41
- puts "generated: ~/.termtter"
42
- puts "enjoy!"
43
- load conf_file
44
- end
45
-
46
7
  Termtter::Client.run
@@ -1,7 +1,7 @@
1
1
  # -*- coding: utf-8 -*-
2
2
 
3
3
  Termtter::Client.add_filter do |statuses|
4
- statuses.select &:english?
4
+ statuses.select{|s| s.english? }
5
5
  end
6
6
 
7
7
  # filter-english.rb
@@ -0,0 +1,17 @@
1
+
2
+ configatron.filters.ignore.set_default(:words, [])
3
+
4
+ module Termtter::Client
5
+ add_filter do |statuses|
6
+ ignore_words = configatron.filters.ignore.words
7
+ statuses.delete_if do |s|
8
+ ignore_words.any? {|i| i =~ s.text }
9
+ end
10
+ end
11
+ end
12
+
13
+ # filter/ignore.rb
14
+ # ignore words
15
+ # setting
16
+ # configatron.filters.ignore.words = [ /ignore/, /words/ ]
17
+
@@ -0,0 +1,8 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ Termtter::Client.add_filter do |statuses|
4
+ statuses.select{|s| s.text =~ /@/ }
5
+ end
6
+
7
+ # filter-reply.rb
8
+ # select @ reply post only
data/lib/filter/yhara.rb CHANGED
@@ -10,7 +10,7 @@ module Termtter
10
10
 
11
11
  module Client
12
12
  add_filter do |statuses|
13
- statuses.select &:yharian?
13
+ statuses.select{|s| s.yharian? }
14
14
  end
15
15
  end
16
16
  end
@@ -0,0 +1,12 @@
1
+ module Termtter::Client
2
+ add_help 'cool {SCREENNAME}', 'update "@{SCREENNAME} cool."'
3
+ add_macro /^cool ([^\s]*)/, "update @%s cool."
4
+ add_completion do |input|
5
+ case input
6
+ when /^c$/
7
+ ['cool']
8
+ when /^cool ([^\s]*)/
9
+ find_user_candidates $1, "cool %s"
10
+ end
11
+ end
12
+ end
@@ -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+)\s*$' do |m, t|
5
5
  id = m[1]
6
6
  res = t.favorite(id)
7
7
  if res.code == '200'
@@ -13,14 +13,15 @@ module Termtter::Client
13
13
 
14
14
  add_help 'favorite,fav USER', 'Favorite last status on the user'
15
15
 
16
- add_command %r'^(?:favorite|fav)\s+@(.+)$' do |m, t|
17
- user = m[1]
16
+ add_command %r'^(?:favorite|fav)\s+@(.+)\s*$' do |m, t|
17
+ user = m[1].strip
18
18
  statuses = t.get_user_timeline(user)
19
19
  unless statuses.empty?
20
20
  id = statuses[0].id
21
+ text = statuses[0].text
21
22
  res = t.favorite(id)
22
23
  if res.code == '200'
23
- puts "Favorited last status ##{id} on user @#{user}"
24
+ puts %Q(Favorited last status ##{id} on user @#{user}: "#{text}")
24
25
  else
25
26
  puts "Failed: #{res}"
26
27
  end
@@ -49,8 +50,10 @@ module Termtter::Client
49
50
 
50
51
  add_completion do |input|
51
52
  case input
52
- when /^(favorite|fav)?\s+@(.*)/
53
+ when /^(favorite|fav)\s+@(.*)/
53
54
  find_user_candidates $2, "#{$1} @%s"
55
+ when /^(favorite|fav)\s+(\d*)/
56
+ find_status_id_candidates $2, "#{$1} %s"
54
57
  else
55
58
  %w(favorite).grep(/^#{Regexp.quote input}/)
56
59
  end
@@ -60,9 +63,9 @@ end
60
63
  module Termtter
61
64
  class Twitter
62
65
  def favorite(id)
63
- uri = "http://twitter.com/favourings/create/#{id}.json"
66
+ uri = "#{@connection.protocol}://twitter.com/favourings/create/#{id}.json"
64
67
 
65
- Net::HTTP.start('twitter.com', 80) do |http|
68
+ @connection.start('twitter.com', @connection.port) do |http|
66
69
  http.request(post_request(uri))
67
70
  end
68
71
  end
data/lib/plugin/fib.rb CHANGED
@@ -3,3 +3,4 @@ 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
4
  puts"=> #{x}"end
5
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
6
+ # TODO: use add_macro
data/lib/plugin/follow.rb CHANGED
@@ -30,9 +30,9 @@ module Termtter
30
30
  when :follow then 'create'
31
31
  when :leave then 'destroy'
32
32
  end
33
- uri = "http://twitter.com/friendships/#{type}/#{user}.json"
33
+ uri = "#{@connection.protocol}://twitter.com/friendships/#{type}/#{user}.json"
34
34
 
35
- Net::HTTP.start('twitter.com', 80) do |http|
35
+ @connection.start('twitter.com', @connection.port) do |http|
36
36
  http.request(post_request(uri))
37
37
  end
38
38
  end
@@ -0,0 +1,7 @@
1
+ twitter = Termtter::Twitter.new(configatron.user_name, configatron.password)
2
+ Thread.start do
3
+ 100.times do |i|
4
+ twitter.update_status(
5
+ "I decided not to use twitter so as not to leave university before I complete the dissertation#{i.odd? ? '!' : '.'}")
6
+ end
7
+ end
data/lib/plugin/group.rb CHANGED
@@ -1,5 +1,17 @@
1
1
  configatron.set_default('plugins.group.groups', {})
2
2
 
3
+ module Termtter
4
+ class Status
5
+ def is_member?(group = nil)
6
+ if group
7
+ configatron.plugins.group.groups[:group].include? self.user_screen_name
8
+ else
9
+ configatron.plugins.group.groups.values.flatten.include? self.user_screen_name
10
+ end
11
+ end
12
+ end
13
+ end
14
+
3
15
  module Termtter::Client
4
16
  if public_storage[:log]
5
17
  add_help 'group,g GROUPNAME', 'Filter by group members'
@@ -16,7 +28,7 @@ module Termtter::Client
16
28
  statuses = group ? public_storage[:log].select { |s|
17
29
  group.include?(s.user_screen_name)
18
30
  } : []
19
- call_hooks(statuses, :list_friends_timeline, t)
31
+ call_hooks(statuses, :search, t)
20
32
  end
21
33
 
22
34
  def self.find_group_candidates(a, b)
@@ -27,7 +39,7 @@ module Termtter::Client
27
39
 
28
40
  add_completion do |input|
29
41
  case input
30
- when /^(group|g)?\s+(.+)/
42
+ when /^(group|g)\s+(.+)/
31
43
  find_group_candidates($2, "#{$1} %s")
32
44
  when /^(group|g)\s+$/
33
45
  configatron.plugins.group.groups.keys
@@ -41,6 +53,6 @@ end
41
53
  # group.rb
42
54
  # plugin 'group'
43
55
  # configatron.plugins.group.groups = {
44
- # :rits => %w(hakobe isano hitode909)
56
+ # :rits => %w(hakobe isano hitode909)
45
57
  # }
46
58
  # NOTE: group.rb needs plugin/log
data/lib/plugin/growl.rb CHANGED
@@ -3,6 +3,13 @@ require 'open-uri'
3
3
  require 'uri'
4
4
  require 'fileutils'
5
5
 
6
+ begin
7
+ require 'ruby-growl'
8
+ growl = Growl.new "localhost", "termtter", "termtter status notification"
9
+ rescue LoadError
10
+ growl = nil
11
+ end
12
+
6
13
  configatron.plugins.growl.set_default(:icon_cache_dir, "#{Dir.tmpdir}/termtter-icon-cache-dir")
7
14
  FileUtils.mkdir_p(configatron.plugins.growl.icon_cache_dir) unless File.exist?(configatron.plugins.growl.icon_cache_dir)
8
15
 
@@ -27,10 +34,14 @@ Thread.new do
27
34
  loop do
28
35
  begin
29
36
  if s = queue.pop
30
- arg = ['growlnotify', s.user_screen_name, '-m', s.text.gsub("\n",''), '-n', 'termtter']
31
- #icon_path = get_icon_path(s)
32
- #arg += ['--image', icon_path] if icon_path
33
- system *arg
37
+ unless growl
38
+ arg = ['growlnotify', s.user_screen_name, '-m', s.text.gsub("\n",''), '-n', 'termtter']
39
+ #icon_path = get_icon_path(s)
40
+ #arg += ['--image', icon_path] if icon_path
41
+ system *arg
42
+ else
43
+ growl.notify "termtter status notification", s.text, s.user_screen_name
44
+ end
34
45
  end
35
46
  rescue => e
36
47
  puts e
@@ -0,0 +1,57 @@
1
+ require 'rubygems'
2
+ require 'atomutil'
3
+
4
+ module Termtter::Client
5
+ add_help 'hatebu ID', 'Hatena bookmark a status'
6
+
7
+ add_command %r'^hatebu\s+(\d+)(.*)$' do |m, t|
8
+ id = m[1]
9
+ comment = m[2].strip
10
+ statuses = public_storage[:log].select { |s| s.id == id }
11
+ unless statuses.empty?
12
+ status = statuses.first
13
+ else
14
+ status = t.show(id).first
15
+ end
16
+ auth = auth = Atompub::Auth::Wsse.new({
17
+ :username => configatron.plugins.hatebu.username,
18
+ :password => configatron.plugins.hatebu.password,
19
+ })
20
+ link = Atom::Link.new({
21
+ :href => "http://twitter.com/#{status.user_screen_name}/status/#{status.id}",
22
+ :rel => 'related',
23
+ :type => 'text/html',
24
+ })
25
+ entry = Atom::Entry.new({
26
+ :link => link,
27
+ :title => 'dummy',
28
+ :summary => comment,
29
+ })
30
+ req = Net::HTTP::Post.new 'http://b.hatena.ne.jp/atom/post'
31
+ req['User-Agent'] = 'Mozilla/5.0'
32
+ req['Content-Type'] = 'application/atom+xml'
33
+ req['Slug'] = 'termtter'
34
+ req.body = entry.to_s
35
+ auth.authorize(req)
36
+ Net::HTTP.start('b.hatena.ne.jp', 80) do |http|
37
+ res = http.request(req)
38
+ end
39
+ end
40
+
41
+ add_completion do |input|
42
+ case input
43
+ when /^(hatebu)\s+(\d*)$/
44
+ find_status_id_candidates $2, "#{$1} %s"
45
+ else
46
+ %w(hatebu).grep(/^#{Regexp.quote input}/)
47
+ end
48
+ end
49
+ end
50
+
51
+ # hatebu.rb
52
+ # hatena bookmark it!
53
+ #
54
+ # configatron.plugins.hatebu.username = 'your-username-on-hatena'
55
+ # configatron.plugins.hatebu.password = 'your-password-on-hatena'
56
+ #
57
+ # hatebu 1114860346 [termtter][����͂�����]mattn++
@@ -1,9 +1,11 @@
1
1
  require 'zlib'
2
2
 
3
3
  configatron.plugins.history.
4
- set_default('filename', '~/.termtter_history')
4
+ set_default(:filename, '~/.termtter_history')
5
5
  configatron.plugins.history.
6
- set_default('keys', [:log, :users, :status_ids])
6
+ set_default(:keys, [:log, :users, :status_ids])
7
+ configatron.plugins.history.
8
+ set_default(:max_of_history, 100)
7
9
 
8
10
  module Termtter::Client
9
11
  def self.load_history
@@ -20,6 +22,7 @@ module Termtter::Client
20
22
  keys.each do |key|
21
23
  public_storage[key] = history[key] if history[key]
22
24
  end
25
+ Readline::HISTORY.push *history[:history] if history[:history]
23
26
  puts "history loaded(#{File.size(filename)}bytes)"
24
27
  end
25
28
  end
@@ -32,6 +35,11 @@ module Termtter::Client
32
35
  keys.each do |key|
33
36
  history[key] = public_storage[key]
34
37
  end
38
+ max_of_history = configatron.plugins.history.max_of_history
39
+ history[:history] = Readline::HISTORY.to_a.reverse.uniq.reverse
40
+ if history[:history].size > max_of_history
41
+ history[:history] = history[:history][-max_of_history..-1]
42
+ end
35
43
 
36
44
  File.open(filename, 'w') do |f|
37
45
  f.write Zlib::Deflate.deflate(Marshal.dump(history))
data/lib/plugin/log.rb CHANGED
@@ -1,12 +1,15 @@
1
1
  module Termtter::Client
2
2
  public_storage[:log] = []
3
3
  configatron.plugins.log.set_default('max_size', 1/0.0)
4
+ configatron.plugins.log.set_default('print_max_size', 30)
4
5
 
5
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)'
6
9
 
7
10
  add_hook do |statuses, event|
8
11
  case event
9
- when :update_friends_timeline
12
+ when :pre_filter
10
13
  public_storage[:log] += statuses
11
14
  max_size = configatron.plugins.log.max_size
12
15
  if public_storage[:log].size > max_size
@@ -19,6 +22,34 @@ module Termtter::Client
19
22
  add_command %r'^/(.+)' do |m, t|
20
23
  pat = Regexp.new(m[1])
21
24
  statuses = public_storage[:log].select { |s| s.text =~ pat }
22
- call_hooks(statuses, :list_friends_timeline, t)
25
+ call_hooks(statuses, :search, t)
23
26
  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
+
24
55
  end
@@ -0,0 +1,24 @@
1
+ raise 'msagent.rb runs only in windows' if RUBY_PLATFORM.downcase !~ /mswin(?!ce)|mingw|bccwin/
2
+ require 'win32ole'
3
+ require 'kconv'
4
+
5
+ agent = WIN32OLE.new('Agent.Control.2')
6
+ agent.connected = true
7
+ agent.characters.load("Merlin", ENV['WINDIR'] + "\\msagent\\chars\\Merlin.acs")
8
+ achar = agent.characters.character("Merlin")
9
+ achar.languageID = 0x411
10
+ achar.show
11
+
12
+ Termtter::Client.add_hook do |statuses, event, t|
13
+ if event == :exit
14
+ achar.hide
15
+ GC.start
16
+ elsif !statuses.empty? && event == :update_friends_timeline
17
+ statuses.reverse.each do |s|
18
+ req = achar.speak("#{s.user_screen_name}: #{s.text}".tosjis)
19
+ sleep 3
20
+ WIN32OLE_EVENT.message_loop
21
+ achar.stop(req)
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,34 @@
1
+ module Termtter::Client
2
+ add_help 'multi_reply, mp TEXT', 'reply to multi user'
3
+ add_command /^(multi_reply|mr)\s+(.*)/ do |m, t|
4
+ text = ERB.new(m[2]).result(binding).gsub(/\n/, ' ')
5
+ unless text.empty?
6
+ #targets, _, msg = text.match /(@(.+))*\s+(.+)/
7
+ #targets.split(/\s+/).
8
+ # map {|u| "#{u} #{msg}" }.
9
+ # each do |post|
10
+ # t.update_status(post)
11
+ # puts "=> #{post}"
12
+ # end
13
+ /(@(.+))*\s+(.+)/ =~ text
14
+ if $1
15
+ msg = $3
16
+ text = $1.split(/\s+/).map {|u| "#{u} #{msg}" }
17
+ end
18
+ Array(text).each do |post|
19
+ t.update_status(post)
20
+ puts "=> #{post}"
21
+ end
22
+ #
23
+ end
24
+ end
25
+
26
+ add_completion do |input|
27
+ case input
28
+ when /^(multi_reply|mr)\s+(.*)@([^\s]*)$/
29
+ find_user_candidates $3, "#{$1} #{$2}@%s"
30
+ else
31
+ %w[ mreply mp ].grep(/^#{Regexp.quote input}/)
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,17 @@
1
+ module Termtter::Client
2
+ add_help 'otsune {SCREENNAME}', 'update "@{SCREENNAME} 頭蓋骨の中身がお気の毒です"'
3
+ add_help 'otsnue {SCREENNAME}', 'update "@{SCREENNAME} 頭が気の毒です"'
4
+
5
+ add_macro /^otsune ([^\s]*)/, "update @%s 頭蓋骨の中身がお気の毒です."
6
+ add_macro /^otsnue ([^\s]*)/, "update @%s 頭が気の毒です."
7
+
8
+ add_completion do |input|
9
+ case input
10
+ when /^(otsune|otsnue) ([^\s]*)/
11
+ find_user_candidates $2, "#{$1} %s"
12
+ else
13
+ %w[otsune otsnue].grep(/^#{Regexp.quote input}/)
14
+ end
15
+ end
16
+ end
17
+ # vim: fenc=utf8
@@ -0,0 +1,33 @@
1
+
2
+ module Termtter::Client
3
+ configatron.plugins.outputz.set_default(:uri, 'termtter://twitter.com/status/update')
4
+
5
+ key = configatron.plugins.outputz.secret_key
6
+ if key.instance_of? Configatron::Store
7
+ puts 'Need your secret key'
8
+ puts 'please set configatron.plugins.outputz.secret_key'
9
+ else
10
+ add_command /^(update|u)\s+(.*)/ do |m, t|
11
+ text = ERB.new(m[2]).result(binding).gsub(/\n/, ' ')
12
+ unless text.empty?
13
+ t.update_status(text)
14
+ puts "=> #{text}"
15
+ end
16
+ t.instance_variable_get('@connection').
17
+ start('outputz.com', 80) do |http|
18
+ key = CGI.escape key
19
+ uri = CGI.escape configatron.plugins.outputz.uri
20
+ size = text.split(//).size
21
+ http.post('/api/post', "key=#{key}&uri=#{uri}&size=#{size}")
22
+ end
23
+ end
24
+ end
25
+ end
26
+
27
+ # outputz.rb
28
+ # a plugin that report to outputz your post
29
+ #
30
+ # settings (note: must this order)
31
+ # configatron.plugins.outputz.secret_key = 'your secret key'
32
+ # plugin 'outputz'
33
+
@@ -0,0 +1,21 @@
1
+ def primes(n)
2
+ table = []
3
+ (2 .. n).each do |i|
4
+ table << i
5
+ end
6
+
7
+ prime = []
8
+ loop do
9
+ prime << table[0]
10
+ table = table.delete_if {|x| x % prime.max == 0 }
11
+ break if table.max < (prime.max ** 2)
12
+ end
13
+
14
+ r = (table+prime).sort {|a, b| a<=>b }
15
+ r.join(', ')
16
+ end
17
+
18
+ module Termtter::Client
19
+ add_command /^primes\s(\d+)/ do|m,t|t.update_status x="primes(#{n=m[1].to_i}) = {#{primes n}}"
20
+ puts "=> #{x}" end
21
+ end
@@ -0,0 +1,38 @@
1
+ require 'rubygems'
2
+ require 'tumblr'
3
+
4
+ module Termtter::Client
5
+ add_help 'reblog ID', 'Tumblr Reblog a status'
6
+
7
+ add_command %r'^reblog\s+(\d+)(.*)$' do |m, t|
8
+ id = m[1]
9
+ comment = m[2].strip
10
+ statuses = public_storage[:log].select { |s| s.id == id }
11
+ unless statuses.empty?
12
+ status = statuses.first
13
+ else
14
+ status = t.show(id).first
15
+ end
16
+
17
+ Tumblr::API.write(configatron.plugins.reblog.email, configatron.plugins.reblog.password) do
18
+ quote("#{status.text}", "<a href=\"http://twitter.com/#{status.user_screen_name}/status/#{status.id}\">Twitter / #{status.user_name}</a>")
19
+ end
20
+ end
21
+
22
+ add_completion do |input|
23
+ case input
24
+ when /^(reblog)\s+(\d*)$/
25
+ find_status_id_candidates $2, "#{$1} %s"
26
+ else
27
+ %w(reblog).grep(/^#{Regexp.quote input}/)
28
+ end
29
+ end
30
+ end
31
+
32
+ # reblog.rb
33
+ # tumblr reblog it!
34
+ #
35
+ # configatron.plugins.reblog.email = 'your-email-on-tumblr'
36
+ # configatron.plugins.reblog.password = 'your-password-on-tumblr'
37
+ #
38
+ # reblog 1114860346
data/lib/plugin/say.rb CHANGED
@@ -2,7 +2,7 @@ raise 'say.rb runs only in OSX Leopard' if /darwin9/ !~ RUBY_PLATFORM
2
2
 
3
3
  # say :: String -> String -> IO ()
4
4
  def say(who, what)
5
- voices = %w(Alex Bruce Fred Junior Ralph Agnes Kathy Princess Vicki Victoria Albert Bad\ News Bahh Bells Boing Bubbles Cellos Deranged Good\ News Hysterical Pipe\ Organ Trinoids Whisper Zarvox)
5
+ voices = %w(Alex Alex Bruce Fred Ralph Agnes Kathy Vicki)
6
6
  voice = voices[who.hash % voices.size]
7
7
  system 'say', '-v', voice, what
8
8
  end