termtter 1.6.0 → 1.7.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +5 -0
- data/README.rdoc +2 -2
- data/Rakefile +41 -75
- data/VERSION +1 -0
- data/bin/termtter +9 -2
- data/doc/Termtter-1.0-Release-Note-English.txt +37 -0
- data/doc/Termtter-1.0-Release-Note.txt +37 -0
- data/lib/plugins/another_prompt.rb +8 -8
- data/lib/plugins/ar.rb +102 -0
- data/lib/plugins/async.rb +1 -1
- data/lib/plugins/babelfish.rb +34 -0
- data/lib/plugins/confirm.rb +2 -0
- data/lib/plugins/crypt.rb +44 -0
- data/lib/plugins/defaults/auto_reload.rb +1 -1
- data/lib/plugins/defaults/command_line.rb +34 -17
- data/lib/plugins/defaults/confirm.rb +30 -0
- data/lib/plugins/defaults/hashtag.rb +1 -1
- data/lib/plugins/defaults/irb.rb +30 -0
- data/lib/plugins/defaults/keyword.rb +58 -0
- data/lib/plugins/defaults/list.rb +155 -0
- data/lib/plugins/defaults/plugin.rb +59 -0
- data/lib/plugins/defaults/retweet.rb +75 -23
- data/lib/plugins/defaults/standard_commands.rb +60 -87
- data/lib/plugins/defaults/standard_completion.rb +25 -15
- data/lib/plugins/defaults/stdout.rb +49 -10
- data/lib/plugins/defaults/switch.rb +1 -1
- data/lib/plugins/defaults/users.rb +63 -0
- data/lib/plugins/draft.rb +58 -0
- data/lib/plugins/expand-tinyurl.rb +5 -9
- data/lib/plugins/favotter.rb +1 -1
- data/lib/plugins/footer.rb +22 -0
- data/lib/plugins/friends.rb +5 -4
- data/lib/plugins/g.rb +9 -16
- data/lib/plugins/gem_install.rb +24 -0
- data/lib/plugins/gist.rb +20 -0
- data/lib/plugins/grass.rb +1 -1
- data/lib/plugins/gyazo.rb +78 -0
- data/lib/plugins/http_server.rb +1 -1
- data/lib/plugins/hugeurl.rb +6 -13
- data/lib/plugins/irc_gw.rb +15 -11
- data/lib/plugins/me.rb +1 -1
- data/lib/plugins/notify-send.rb +1 -1
- data/lib/plugins/notify-send3.rb +1 -1
- data/lib/plugins/open.rb +1 -1
- data/lib/plugins/open_url.rb +5 -1
- data/lib/plugins/pool.rb +1 -1
- data/lib/plugins/random.rb +1 -1
- data/lib/plugins/reply_retweet.rb +42 -0
- data/lib/plugins/screen-notify.rb +1 -1
- data/lib/plugins/sl.rb +3 -3
- data/lib/plugins/storage.rb +7 -10
- data/lib/plugins/storage/sqlite3.rb +155 -0
- data/lib/plugins/storage/status.rb +2 -0
- data/lib/plugins/stream.rb +1 -1
- data/lib/plugins/tinyurl.rb +3 -9
- data/lib/plugins/trends.rb +2 -2
- data/lib/plugins/truncate.rb +1 -1
- data/lib/plugins/w3mimg.rb +1 -1
- data/lib/termtter.rb +19 -20
- data/lib/termtter/active_rubytter.rb +4 -0
- data/lib/termtter/api.rb +22 -5
- data/lib/termtter/client.rb +55 -40
- data/lib/termtter/command.rb +3 -2
- data/lib/termtter/config_setup.rb +1 -1
- data/lib/termtter/config_template.erb +5 -0
- data/lib/termtter/default_config.rb +18 -0
- data/lib/termtter/hookable.rb +1 -0
- data/lib/termtter/httppool.rb +44 -0
- data/lib/termtter/memory_cache.rb +32 -0
- data/lib/termtter/optparse.rb +8 -15
- data/lib/termtter/rubytter_proxy.rb +65 -4
- data/lib/termtter/system_extensions.rb +40 -9
- data/lib/termtter/task.rb +2 -1
- data/spec/plugins/defaults/hashtag_spec.rb +8 -7
- data/spec/plugins/defaults/list_spec.rb +33 -0
- data/spec/plugins/defaults/plugin_spec.rb +17 -0
- data/spec/plugins/defaults/retweet_spec.rb +205 -0
- data/spec/plugins/draft_spec.rb +59 -0
- data/spec/plugins/expand-tinyurl_spec.rb +21 -0
- data/spec/plugins/footer_spec.rb +50 -0
- data/spec/plugins/storage/sqlite3_spec.rb +41 -0
- data/spec/termtter/api_spec.rb +1 -1
- data/spec/termtter/client_spec.rb +21 -21
- data/spec/termtter/command_spec.rb +8 -8
- data/spec/termtter/config_spec.rb +2 -2
- data/spec/termtter/memory_cache_spec.rb +20 -0
- data/spec/termtter/optparse_spec.rb +1 -1
- data/spec/termtter/rubytter_proxy_spec.rb +38 -0
- data/spec/termtter/system_extensions_spec.rb +25 -23
- data/spec/termtter/task_manager_spec.rb +1 -1
- data/spec/termtter_spec.rb +4 -2
- metadata +88 -19
- data/lib/plugins/defaults/lists.rb +0 -14
- data/lib/plugins/irb.rb +0 -6
- data/lib/plugins/storage/DB.rb +0 -37
- data/lib/termtter/version.rb +0 -4
- data/spec/plugins/defaults/lists_spec.rb +0 -34
- data/spec/plugins/storage/DB_spec_.rb +0 -12
data/README.rdoc
CHANGED
@@ -32,14 +32,14 @@ Search
|
|
32
32
|
|
33
33
|
== CONFIGURATION:
|
34
34
|
|
35
|
-
If you would like to use proxy server, add configurations like this:
|
35
|
+
If you would like to use a proxy server, add configurations like this:
|
36
36
|
|
37
37
|
config.proxy.host = 'PROXYHOST'
|
38
38
|
config.proxy.port = 'PROXYPORT'
|
39
39
|
config.proxy.user_name = 'USERNAME'
|
40
40
|
config.proxy.password = 'PASSWORD'
|
41
41
|
|
42
|
-
You can
|
42
|
+
You can load plugins this way:
|
43
43
|
|
44
44
|
Termtter::Client.init do |t|
|
45
45
|
t.plug 'fib'
|
data/Rakefile
CHANGED
@@ -1,85 +1,51 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
require '
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
s.add_dependency("json_pure", ">= 1.1.3")
|
23
|
-
s.add_dependency("highline", ">= 1.5.0")
|
24
|
-
s.add_dependency("termcolor", ">= 1.0.0")
|
25
|
-
s.add_dependency("rubytter", ">= 0.9.2")
|
26
|
-
s.authors = %w(jugyo ujihisa)
|
27
|
-
s.email = 'jugyo.org@gmail.com'
|
28
|
-
s.homepage = 'http://termtter.org/'
|
29
|
-
s.rubyforge_project = 'termtter'
|
30
|
-
s.has_rdoc = true
|
31
|
-
s.rdoc_options = ["--main", "README.rdoc", "--exclude", "spec"]
|
32
|
-
s.extra_rdoc_files = ["README.rdoc", "ChangeLog"]
|
33
|
-
end
|
34
|
-
|
35
|
-
Rake::GemPackageTask.new(spec) do |p|
|
36
|
-
p.need_tar = true
|
37
|
-
end
|
38
|
-
|
39
|
-
task :gemspec do
|
40
|
-
filename = "#{name}.gemspec"
|
41
|
-
open(filename, 'w') do |f|
|
42
|
-
f.write spec.to_ruby
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'jeweler'
|
6
|
+
Jeweler::Tasks.new do |gem|
|
7
|
+
gem.name = 'termtter'
|
8
|
+
gem.summary = "Terminal based Twitter client."
|
9
|
+
gem.description = "Termtter is a terminal based Twitter client."
|
10
|
+
gem.executables = ["kill_termtter", "termtter"]
|
11
|
+
gem.add_dependency("json_pure", ">= 1.1.3")
|
12
|
+
gem.add_dependency("highline", ">= 1.5.0")
|
13
|
+
gem.add_dependency("termcolor", ">= 1.0.0")
|
14
|
+
gem.add_dependency("rubytter", ">= 0.11.0")
|
15
|
+
gem.authors = %w(jugyo ujihisa)
|
16
|
+
gem.email = 'jugyo.org@gmail.com'
|
17
|
+
gem.homepage = 'http://termtter.org/'
|
18
|
+
gem.rubyforge_project = 'termtter'
|
19
|
+
gem.has_rdoc = true
|
20
|
+
gem.rdoc_options = ["--main", "README.rdoc", "--exclude", "spec"]
|
21
|
+
gem.extra_rdoc_files = ["README.rdoc", "ChangeLog"]
|
43
22
|
end
|
44
|
-
|
45
|
-
|
46
|
-
Name: #{name}
|
47
|
-
Version: #{version}
|
48
|
-
File: #{filename}
|
49
|
-
EOS
|
50
|
-
end
|
51
|
-
|
52
|
-
task :install => [ :package ] do
|
53
|
-
sh %{sudo gem install pkg/#{name}-#{version}.gem}
|
23
|
+
rescue LoadError
|
24
|
+
puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
|
54
25
|
end
|
55
26
|
|
56
|
-
|
57
|
-
|
27
|
+
require 'spec/rake/spectask'
|
28
|
+
Spec::Rake::SpecTask.new(:spec) do |spec|
|
29
|
+
spec.libs << 'lib' << 'spec'
|
30
|
+
spec.spec_files = FileList['spec/**/*_spec.rb']
|
58
31
|
end
|
59
32
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
t.spec_opts = ['-c']
|
33
|
+
Spec::Rake::SpecTask.new(:rcov) do |spec|
|
34
|
+
spec.libs << 'lib' << 'spec'
|
35
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
36
|
+
spec.rcov = true
|
65
37
|
end
|
66
|
-
desc "Run all examples with RCov"
|
67
38
|
|
68
|
-
|
69
|
-
t.spec_files = FileList['spec/**/*_spec.rb']
|
70
|
-
t.spec_files.sort! # FIXME: Spec depends order.
|
71
|
-
t.spec_opts = ['-c', '-fs']
|
72
|
-
t.rcov = true
|
73
|
-
t.rcov_opts = ['-x', 'spec', '--exclude', 'lib/plugins']
|
74
|
-
end
|
39
|
+
task :spec => :check_dependencies
|
75
40
|
|
76
|
-
|
77
|
-
t.rdoc_dir = 'rdoc'
|
78
|
-
t.title = "rest-client, fetch RESTful resources effortlessly"
|
79
|
-
t.options << '--line-numbers' << '--inline-source' << '-A cattr_accessor=object'
|
80
|
-
t.options << '--charset' << 'utf-8'
|
81
|
-
t.rdoc_files.include('README.rdoc', 'lib/**/*.rb')
|
82
|
-
end
|
41
|
+
task :default => :spec
|
83
42
|
|
84
|
-
|
43
|
+
require 'rake/rdoctask'
|
44
|
+
Rake::RDocTask.new do |rdoc|
|
45
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
85
46
|
|
47
|
+
rdoc.rdoc_dir = 'rdoc'
|
48
|
+
rdoc.title = "jeweler_test #{version}"
|
49
|
+
rdoc.rdoc_files.include('README*')
|
50
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
51
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
1.7.0
|
data/bin/termtter
CHANGED
@@ -1,7 +1,14 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
# -*- coding: utf-8 -*-
|
3
3
|
|
4
|
-
|
4
|
+
self_file =
|
5
|
+
if File.symlink?(__FILE__)
|
6
|
+
require 'pathname'
|
7
|
+
Pathname.new(__FILE__).realpath
|
8
|
+
else
|
9
|
+
__FILE__
|
10
|
+
end
|
11
|
+
$:.unshift(File.dirname(self_file) + "/../lib")
|
12
|
+
|
5
13
|
require 'termtter'
|
6
|
-
Termtter::OptParser.parse!(ARGV)
|
7
14
|
Termtter::Client.run
|
@@ -0,0 +1,37 @@
|
|
1
|
+
Termtter 1.0 Released
|
2
|
+
Today March 15, 2009, we have released Termtter 1.0 as a stable version. Termtter is a twitter client software working on terminal emulators, which is very easy to extend functions. Termtter is the only one twitter client which can calculates fibonacci numbers congenitally.
|
3
|
+
|
4
|
+
== INSTALLATION
|
5
|
+
sudo gem install termtter
|
6
|
+
|
7
|
+
== HOW TO USE
|
8
|
+
Termtter will ask you what are your twitter account(email) and password are when you boot termtter for the first time. Termtter will make a config file ~/.termtter/config and will boot. Now you can post messages to twitter by typing "u Hello, world!" and return key on the termtter.
|
9
|
+
|
10
|
+
Let's fix your ~/.termtter/config and try various plugins! You can post the 100th fibonacci number to twitter by (1) uncomment the line "plugin 'fib'" and reboot termtter and (2) type "fib 100" on the termtter.
|
11
|
+
http://twitter.com/ujm/status/1330652098
|
12
|
+
|
13
|
+
== Changes after Termtter 0.8 series
|
14
|
+
Big changes:
|
15
|
+
* Termtter config file: from ~/.termtter to ~/.termtter/config
|
16
|
+
* Enable to use user-plugin located in ~/.termtter/plugins
|
17
|
+
* Storing timelins on sqlite3 db
|
18
|
+
* Enable to specify your config file by option -f
|
19
|
+
|
20
|
+
Small changes:
|
21
|
+
* Not to use gem package configatron
|
22
|
+
* Enable to target what event will be filtered only in English (plugin/english)
|
23
|
+
|
24
|
+
See all chages:
|
25
|
+
http://jugyo.lighthouseapp.com/projects/22944-termtter/tickets?q=state%3Aclosed
|
26
|
+
|
27
|
+
== Termtter Camp (termtterspa2009, Ruby Spa)
|
28
|
+
We worked to relase our new Termtter 1.0 in Termtter Camp 2009. That's a hackathon which 8 hackers meet near the lake biwako (a.k.a. the Japanese Great Lake). We enjoyed nice and natural spa and hacking.
|
29
|
+
|
30
|
+
Participants: hitode909, jugyo, ujihisa, Sixeight, koichiroo, nay, udonchan, repeatedly
|
31
|
+
|
32
|
+
== Links
|
33
|
+
Termtter trunk
|
34
|
+
http://github.com/jugyo/termcolor/tree/master
|
35
|
+
|
36
|
+
Old Release Note
|
37
|
+
http://jugyo.org/blog/2931
|
@@ -0,0 +1,37 @@
|
|
1
|
+
Termtter 1.0 をリリースしました
|
2
|
+
本日2009年3月15日、Termtter の最新安定版であるバージョン1.0をリリースしました。Termtterはターミナルエミュレータ上で動作する Twitter クライアントで、拡張性に極端に優れているという特徴があります。フィボナッチ数列を計算する機能が標準で提供されている、世界で唯一のtwitterクライアントです。
|
3
|
+
|
4
|
+
== インストール
|
5
|
+
sudo gem install termtter
|
6
|
+
|
7
|
+
== 使い方
|
8
|
+
termtterを起動すると、初回はあなたのtwitterアカウントとパスワードが聞かれます。それによって設定ファイル~/.termtter/configが生成され、同時にtermtterが起動します。"u Hello, world!"などと書いてエンターキーを叩くことによって、termtterからtwitterに発言することができます。
|
9
|
+
|
10
|
+
~/.termtter/configを修正し、さまざまなプラグインを試してみましょう。たとえばplugin 'fib'の行のコメントを外してtermtterを再起動することによって、"fib 100"と入力することで100番目のフィボナッチ数列の値をtwitterにポストすることができます。
|
11
|
+
http://twitter.com/ujm/status/1330652098
|
12
|
+
|
13
|
+
== 0.8系からの変更点
|
14
|
+
大きな変更点:
|
15
|
+
* 設定ファイルが~/.termtterから~/.termtter/configを指すようになりました。なお、古い設定ファイル~/.termtterがある状態でtermtterを起動すると、自動的に最新版の構成になるようmkdir, mvなどが行われます。
|
16
|
+
* termtter本体に標準添付されているプラグイン以外にも、自作プラグインを~/.termtter/plugins以下に配置することで、自作プラグインを容易に使用することができます。
|
17
|
+
* TimelineをSQLite3のデータベースに保存することにより、termtterを常時起動してもそれほど負荷がかからないようになりました。
|
18
|
+
* 起動時のオプションで設定ファイルを切り替えることができるようになりました。
|
19
|
+
|
20
|
+
細かい変更点:
|
21
|
+
* gemのパッケージconfigatronを使わないようになりました。
|
22
|
+
* Englishプラグインでtimelineでは英語だけだがrepliesでは日本語も通すなどのオプションを設定できるようになりました。
|
23
|
+
|
24
|
+
その他の変更点はこちらをご覧ください。
|
25
|
+
http://jugyo.lighthouseapp.com/projects/22944-termtter/tickets?q=state%3Aclosed
|
26
|
+
|
27
|
+
== Termtter合宿 (termtterspa2009, Ruby温泉)
|
28
|
+
Termtter 1.0 のリリース作業はTermtter合宿で行われました。これはTermtterのコミッタのうち8名が滋賀県の琵琶湖のほとりで宿にこもってひたすらTermtterの1.0への課題を克服し、温泉に浸かるような行為を行いました。
|
29
|
+
|
30
|
+
参加者: hitode909, jugyo, ujihisa, Sixeight, koichiroo, nay, udonchan, repeatedly
|
31
|
+
|
32
|
+
== 参考リンク
|
33
|
+
開発中のTermtter
|
34
|
+
http://github.com/jugyo/termcolor/tree/master
|
35
|
+
|
36
|
+
2009年1月時点の Termtter リリースノート (当時のバージョンは不明)
|
37
|
+
http://jugyo.org/blog/2931
|
@@ -23,13 +23,13 @@ config.plugins.another_prompt.
|
|
23
23
|
sub(/^\d+\s(\d+)$/, '\\1').to_i
|
24
24
|
end,
|
25
25
|
'q' => lambda do
|
26
|
-
Termtter::Client.
|
26
|
+
Termtter::Client.execute('quit')
|
27
27
|
end,
|
28
28
|
'r' => lambda do
|
29
|
-
Termtter::Client.
|
29
|
+
Termtter::Client.execute('replies')
|
30
30
|
end,
|
31
31
|
'?' => lambda do
|
32
|
-
Termtter::Client.
|
32
|
+
Termtter::Client.execute('help')
|
33
33
|
end,
|
34
34
|
"\e" => lambda do
|
35
35
|
system('screen', '-X', 'eval', 'copy')
|
@@ -43,7 +43,7 @@ module Termtter::Client
|
|
43
43
|
:interval => config.update_interval,
|
44
44
|
:after => config.update_interval) do
|
45
45
|
begin
|
46
|
-
|
46
|
+
execute('reload')
|
47
47
|
rescue Exception => e
|
48
48
|
handle_error(e)
|
49
49
|
end
|
@@ -54,7 +54,7 @@ module Termtter::Client
|
|
54
54
|
:point => :initialize,
|
55
55
|
:exec => lambda {
|
56
56
|
begin
|
57
|
-
|
57
|
+
execute('reload')
|
58
58
|
rescue Exception => e
|
59
59
|
handle_error(e)
|
60
60
|
end
|
@@ -91,7 +91,7 @@ module Termtter
|
|
91
91
|
end
|
92
92
|
|
93
93
|
def call_prompt(command)
|
94
|
-
Client.
|
94
|
+
Client.execute("curry #{command}")
|
95
95
|
if buf = Readline.readline(ERB.new(prompt).result(Termtter::API.twitter.__send__(:binding)), true)
|
96
96
|
Readline::HISTORY.pop if buf.empty?
|
97
97
|
begin
|
@@ -103,7 +103,7 @@ module Termtter
|
|
103
103
|
puts
|
104
104
|
end
|
105
105
|
ensure
|
106
|
-
Client.
|
106
|
+
Client.execute('uncurry')
|
107
107
|
end
|
108
108
|
|
109
109
|
def wait_keypress
|
@@ -120,7 +120,7 @@ module Termtter
|
|
120
120
|
begin
|
121
121
|
system "stty", STTY_ORIGIN
|
122
122
|
ensure
|
123
|
-
Client.
|
123
|
+
Client.execute('exit')
|
124
124
|
end
|
125
125
|
end
|
126
126
|
rescue ArgumentError
|
data/lib/plugins/ar.rb
ADDED
@@ -0,0 +1,102 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
require 'active_record'
|
3
|
+
config.plugins.db.set_default(:path, Termtter::CONF_DIR + '/termtter.db')
|
4
|
+
|
5
|
+
ActiveRecord::Base.logger=Logger.new(nil)
|
6
|
+
ActiveRecord::Base.establish_connection(
|
7
|
+
:adapter => "sqlite3",
|
8
|
+
:database => config.plugins.db.path
|
9
|
+
)
|
10
|
+
|
11
|
+
class Status < ActiveRecord::Base
|
12
|
+
belongs_to :user
|
13
|
+
end
|
14
|
+
class User < ActiveRecord::Base
|
15
|
+
has_many :statuses
|
16
|
+
end
|
17
|
+
|
18
|
+
unless Status.table_exists?()
|
19
|
+
ActiveRecord::Migration.create_table :statuses do |t|
|
20
|
+
t.column :user_id, :integer
|
21
|
+
t.column :text, :string
|
22
|
+
t.column :created_at, :string
|
23
|
+
t.column :in_reply_to_status_id, :integer
|
24
|
+
t.column :in_reply_to_user_id, :integer
|
25
|
+
t.column :retweeted_status, :boolean
|
26
|
+
t.column :source, :string
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
unless User.table_exists?()
|
31
|
+
ActiveRecord::Migration.create_table :users do |t|
|
32
|
+
t.column :screen_name, :string
|
33
|
+
t.column :protected, :boolean
|
34
|
+
t.column :uid, :integer
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
module Termtter
|
39
|
+
module Client
|
40
|
+
register_hook(:collect_statuses_for_db, :point => :pre_filter) do |statuses, event|
|
41
|
+
statuses.each do |s|
|
42
|
+
# Save users
|
43
|
+
unless User.exists?(s.user.id)
|
44
|
+
user = {}
|
45
|
+
User.columns.map{|x| x.name.intern }.each do |col|
|
46
|
+
user[col] =
|
47
|
+
if event.class == SearchEvent && col == :protected
|
48
|
+
false
|
49
|
+
elsif col == :uid
|
50
|
+
s.user.id
|
51
|
+
elsif col != :id
|
52
|
+
s.user[col]
|
53
|
+
end
|
54
|
+
end
|
55
|
+
User.create(user)
|
56
|
+
end
|
57
|
+
|
58
|
+
# Save statuses
|
59
|
+
unless Status.exists?(s.id)
|
60
|
+
status = {}
|
61
|
+
Status.columns.map{|x| x.name.intern }.each do |col|
|
62
|
+
status[col] =
|
63
|
+
col != :user_id ? (s[col] rescue nil) : nil
|
64
|
+
end
|
65
|
+
u = User.find(:first,
|
66
|
+
:conditions => ['uid = :i', {:i => s.user.id}])
|
67
|
+
u.statuses.create(status)
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
register_command(:db_search, :alias => :ds) do |arg|
|
73
|
+
statuses = Status.find(:all,
|
74
|
+
:conditions => ['text LIKE :l',
|
75
|
+
{:l => "%" + arg + "%"}],
|
76
|
+
:limit => 20)
|
77
|
+
output(statuses, :db_search)
|
78
|
+
end
|
79
|
+
|
80
|
+
register_command(:db_clear) do |arg|
|
81
|
+
if confirm('Are you sure?')
|
82
|
+
User.delete_all
|
83
|
+
Status.delete_all
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
register_command(:db_list) do |arg|
|
88
|
+
user_name = normalize_as_user_name(arg)
|
89
|
+
statuses = Status.find(:all,
|
90
|
+
:joins => "LEFT OUTER JOIN users ON users.uid = statuses.user_id",
|
91
|
+
:conditions => ['users.screen_name = :u',{:u => user_name}],
|
92
|
+
:limit => 20)
|
93
|
+
output(statuses, :db_search)
|
94
|
+
end
|
95
|
+
|
96
|
+
register_command(:db_execute) do |arg|
|
97
|
+
ActionRecord::Base.connection.execute(arg).each do |row|
|
98
|
+
p row
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
data/lib/plugins/async.rb
CHANGED
@@ -0,0 +1,34 @@
|
|
1
|
+
# gem install sishen-rtranslate --source http://gems.github.com --no-ri --no-rdoc
|
2
|
+
# >= 1.2
|
3
|
+
require 'rtranslate'
|
4
|
+
|
5
|
+
config.plugins.babelfish.set_default(:default_lang, 'en,hu')
|
6
|
+
|
7
|
+
Termtter::Client.register_hook(
|
8
|
+
:name => :babelfish,
|
9
|
+
:point => :filter_for_output,
|
10
|
+
:help => ['language settings', 'call babel_lang proc!'],
|
11
|
+
:exec_proc => lambda {|statuses, event|
|
12
|
+
statuses.each do |s|
|
13
|
+
lang = Translate.d( s.text ) # autodetecting language
|
14
|
+
unless config.plugins.babelfish.default_lang.split(',').include?( lang ) # is it understandable?
|
15
|
+
pre_check = Translate.t( s.text, '', config.plugins.babelfish.default_lang.split(',').first ) # translate
|
16
|
+
s[:text]= "#{pre_check}~#{lang}" unless pre_check =~ /^Error/ # modify display
|
17
|
+
end
|
18
|
+
end
|
19
|
+
}
|
20
|
+
)
|
21
|
+
|
22
|
+
Termtter::Client.register_command(
|
23
|
+
:name => :babel_lang,
|
24
|
+
:exec_proc => lambda { |arg|
|
25
|
+
unless arg.empty?
|
26
|
+
puts "setting default language to '#{arg}'."
|
27
|
+
config.plugins.babelfish.default_lang= arg
|
28
|
+
else
|
29
|
+
puts "Babelfish language settings: #{config.plugins.babelfish.default_lang}"
|
30
|
+
puts 'You can specify more languages with colon: like "en,hu" wich means always translate to english but acceptable original tweets in english and hungarian too. '
|
31
|
+
end
|
32
|
+
|
33
|
+
}
|
34
|
+
)
|