draftcode-termtter 1.0.8
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.
- data/History.txt +4 -0
- data/README.rdoc +100 -0
- data/Rakefile +55 -0
- data/bin/kill_termtter +22 -0
- data/bin/termtter +6 -0
- data/lib/plugins/addspace.rb +27 -0
- data/lib/plugins/april_fool.rb +15 -0
- data/lib/plugins/bomb.rb +39 -0
- data/lib/plugins/clear.rb +14 -0
- data/lib/plugins/command_plus.rb +47 -0
- data/lib/plugins/confirm.rb +33 -0
- data/lib/plugins/cool.rb +10 -0
- data/lib/plugins/countter.rb +23 -0
- data/lib/plugins/devel.rb +18 -0
- data/lib/plugins/direct_messages.rb +36 -0
- data/lib/plugins/en2ja.rb +11 -0
- data/lib/plugins/english.rb +25 -0
- data/lib/plugins/erb.rb +17 -0
- data/lib/plugins/exec.rb +17 -0
- data/lib/plugins/exec_and_update.rb +14 -0
- data/lib/plugins/expand-tinyurl.rb +34 -0
- data/lib/plugins/fib.rb +28 -0
- data/lib/plugins/fib_filter.rb +14 -0
- data/lib/plugins/filter.rb +69 -0
- data/lib/plugins/graduatter.rb +8 -0
- data/lib/plugins/grass.rb +27 -0
- data/lib/plugins/group.rb +64 -0
- data/lib/plugins/growl.rb +52 -0
- data/lib/plugins/growl2.rb +143 -0
- data/lib/plugins/hatebu.rb +59 -0
- data/lib/plugins/hatebu_and_update.rb +58 -0
- data/lib/plugins/history.rb +93 -0
- data/lib/plugins/ignore.rb +19 -0
- data/lib/plugins/keyword.rb +18 -0
- data/lib/plugins/l2.rb +25 -0
- data/lib/plugins/log.rb +73 -0
- data/lib/plugins/me.rb +10 -0
- data/lib/plugins/modify_arg_hook_sample.rb +7 -0
- data/lib/plugins/msagent.rb +38 -0
- data/lib/plugins/multi_reply.rb +27 -0
- data/lib/plugins/notify-send.rb +22 -0
- data/lib/plugins/notify-send2.rb +52 -0
- data/lib/plugins/notify-send3.rb +45 -0
- data/lib/plugins/open_url.rb +59 -0
- data/lib/plugins/otsune.rb +21 -0
- data/lib/plugins/outputz.rb +33 -0
- data/lib/plugins/pause.rb +3 -0
- data/lib/plugins/post_exec_hook_sample.rb +9 -0
- data/lib/plugins/pre_exec_hook_sample.rb +9 -0
- data/lib/plugins/primes.rb +30 -0
- data/lib/plugins/quicklook.rb +41 -0
- data/lib/plugins/random.rb +23 -0
- data/lib/plugins/reblog.rb +40 -0
- data/lib/plugins/reload.rb +3 -0
- data/lib/plugins/reply.rb +8 -0
- data/lib/plugins/retweet.rb +46 -0
- data/lib/plugins/reverse.rb +13 -0
- data/lib/plugins/say.rb +26 -0
- data/lib/plugins/scrape.rb +41 -0
- data/lib/plugins/screen-notify.rb +20 -0
- data/lib/plugins/screen.rb +24 -0
- data/lib/plugins/shell.rb +14 -0
- data/lib/plugins/sl.rb +48 -0
- data/lib/plugins/spam.rb +16 -0
- data/lib/plugins/standard_plugins.rb +525 -0
- data/lib/plugins/stdout.rb +220 -0
- data/lib/plugins/storage.rb +55 -0
- data/lib/plugins/storage/DB.rb +37 -0
- data/lib/plugins/storage/status.rb +83 -0
- data/lib/plugins/storage/status_mook.rb +30 -0
- data/lib/plugins/switch_user.rb +22 -0
- data/lib/plugins/system_status.rb +33 -0
- data/lib/plugins/timer.rb +18 -0
- data/lib/plugins/tinyurl.rb +20 -0
- data/lib/plugins/translation.rb +38 -0
- data/lib/plugins/typable_id.rb +94 -0
- data/lib/plugins/update_editor.rb +53 -0
- data/lib/plugins/uri-open.rb +66 -0
- data/lib/plugins/wassr_post.rb +22 -0
- data/lib/plugins/yhara.rb +148 -0
- data/lib/plugins/yhara_filter.rb +8 -0
- data/lib/plugins/yonda.rb +21 -0
- data/lib/termtter.rb +38 -0
- data/lib/termtter/api.rb +57 -0
- data/lib/termtter/client.rb +324 -0
- data/lib/termtter/command.rb +80 -0
- data/lib/termtter/config.rb +68 -0
- data/lib/termtter/config_setup.rb +38 -0
- data/lib/termtter/connection.rb +41 -0
- data/lib/termtter/hook.rb +31 -0
- data/lib/termtter/optparse.rb +14 -0
- data/lib/termtter/system_extensions.rb +115 -0
- data/lib/termtter/task.rb +17 -0
- data/lib/termtter/task_manager.rb +116 -0
- data/lib/termtter/version.rb +4 -0
- data/spec/plugins/cool_spec.rb +10 -0
- data/spec/plugins/english_spec.rb +19 -0
- data/spec/plugins/fib_spec.rb +15 -0
- data/spec/plugins/filter_spec.rb +18 -0
- data/spec/plugins/pause_spec.rb +8 -0
- data/spec/plugins/primes_spec.rb +15 -0
- data/spec/plugins/shell_spec.rb +10 -0
- data/spec/plugins/sl_spec.rb +8 -0
- data/spec/plugins/spam_spec.rb +4 -0
- data/spec/plugins/standard_plugins_spec.rb +23 -0
- data/spec/plugins/storage/DB_spec.rb +12 -0
- data/spec/plugins/storage/status_spec.rb +24 -0
- data/spec/spec_helper.rb +7 -0
- data/spec/termtter/client_spec.rb +255 -0
- data/spec/termtter/command_spec.rb +107 -0
- data/spec/termtter/config_spec.rb +111 -0
- data/spec/termtter/hook_spec.rb +78 -0
- data/spec/termtter/task_manager_spec.rb +78 -0
- data/spec/termtter/task_spec.rb +22 -0
- data/spec/termtter_spec.rb +29 -0
- data/test/friends_timeline.json +5 -0
- data/test/search.json +8 -0
- metadata +211 -0
data/History.txt
ADDED
data/README.rdoc
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
= termtter
|
|
2
|
+
|
|
3
|
+
http://github.com/jugyo/termtter
|
|
4
|
+
|
|
5
|
+
== DESCRIPTION:
|
|
6
|
+
|
|
7
|
+
Termtter is a terminal based Twitter client.
|
|
8
|
+
|
|
9
|
+
== FEATURES/PROBLEMS:
|
|
10
|
+
|
|
11
|
+
== SYNOPSIS:
|
|
12
|
+
|
|
13
|
+
=== Run:
|
|
14
|
+
|
|
15
|
+
% termtter
|
|
16
|
+
|
|
17
|
+
=== Some Termtter Commands:
|
|
18
|
+
|
|
19
|
+
Show help
|
|
20
|
+
|
|
21
|
+
> help
|
|
22
|
+
|
|
23
|
+
Update status
|
|
24
|
+
|
|
25
|
+
> update hi!
|
|
26
|
+
|
|
27
|
+
Show replies
|
|
28
|
+
|
|
29
|
+
> replies
|
|
30
|
+
|
|
31
|
+
Search
|
|
32
|
+
|
|
33
|
+
> search termtter
|
|
34
|
+
|
|
35
|
+
== REQUIREMENTS:
|
|
36
|
+
|
|
37
|
+
* json_pure
|
|
38
|
+
* termcolor
|
|
39
|
+
* rubytter
|
|
40
|
+
|
|
41
|
+
== INSTALL:
|
|
42
|
+
|
|
43
|
+
% sudo gem install termtter
|
|
44
|
+
|
|
45
|
+
== CONFIGURATION:
|
|
46
|
+
|
|
47
|
+
Termtter generates a configuration file named '~/.termtter/config'.
|
|
48
|
+
You can edit the file anytime.
|
|
49
|
+
|
|
50
|
+
% vim ~/.termtter/config
|
|
51
|
+
|
|
52
|
+
config.user_name = 'USERNAME'
|
|
53
|
+
config.password = 'PASSWORD'
|
|
54
|
+
|
|
55
|
+
If you would like to use proxy server, add configurations like this:
|
|
56
|
+
|
|
57
|
+
config.proxy.host = 'PROXYHOST'
|
|
58
|
+
config.proxy.port = 'PROXYPORT'
|
|
59
|
+
config.proxy.user_name = 'USERNAME'
|
|
60
|
+
config.proxy.password = 'PASSWORD'
|
|
61
|
+
|
|
62
|
+
To update the config, just restart your termtter proccess.
|
|
63
|
+
|
|
64
|
+
== FORUM:
|
|
65
|
+
|
|
66
|
+
http://www.lingr.com/room/termtter
|
|
67
|
+
|
|
68
|
+
== DOCUMENT:
|
|
69
|
+
|
|
70
|
+
http://wiki.github.com/jugyo/termtter/home (in Japanese)
|
|
71
|
+
|
|
72
|
+
== TODO:
|
|
73
|
+
|
|
74
|
+
- Enhance the document and spec
|
|
75
|
+
- Improve the UI(a status view, etc...)
|
|
76
|
+
|
|
77
|
+
== LICENSE:
|
|
78
|
+
|
|
79
|
+
(The MIT License)
|
|
80
|
+
|
|
81
|
+
Copyright (c) 2008-2009 The Termtter Development Team
|
|
82
|
+
|
|
83
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
84
|
+
a copy of this software and associated documentation files (the
|
|
85
|
+
'Software'), to deal in the Software without restriction, including
|
|
86
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
87
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
88
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
89
|
+
the following conditions:
|
|
90
|
+
|
|
91
|
+
The above copyright notice and this permission notice shall be
|
|
92
|
+
included in all copies or substantial portions of the Software.
|
|
93
|
+
|
|
94
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
|
95
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
96
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
97
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
98
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
99
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
100
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
$:.unshift File.dirname(__FILE__) + '/lib'
|
|
2
|
+
require 'spec/rake/spectask'
|
|
3
|
+
desc 'run all specs'
|
|
4
|
+
Spec::Rake::SpecTask.new do |t|
|
|
5
|
+
t.spec_files = FileList['spec/**/*_spec.rb']
|
|
6
|
+
t.spec_opts = ['-c']
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
desc 'Generate gemspec'
|
|
10
|
+
task :gemspec do |t|
|
|
11
|
+
require 'termtter'
|
|
12
|
+
open('termtter.gemspec', "wb" ) do |file|
|
|
13
|
+
file << <<-EOS
|
|
14
|
+
Gem::Specification.new do |s|
|
|
15
|
+
s.name = 'termtter'
|
|
16
|
+
s.version = '#{Termtter::VERSION}'
|
|
17
|
+
s.summary = "Terminal based Twitter client"
|
|
18
|
+
s.description = "Termtter is a terminal based Twitter client"
|
|
19
|
+
s.files = %w( #{Dir['lib/**/*.rb'].join(' ')}
|
|
20
|
+
#{Dir['spec/**/*.rb'].join(' ')}
|
|
21
|
+
#{Dir['test/**/*.rb', 'test/**/*.json'].join(' ')}
|
|
22
|
+
README.rdoc
|
|
23
|
+
History.txt
|
|
24
|
+
Rakefile )
|
|
25
|
+
s.executables = ["kill_termtter", "termtter"]
|
|
26
|
+
s.add_dependency("json_pure", ">= 1.1.3")
|
|
27
|
+
s.add_dependency("highline", ">= 1.5.0")
|
|
28
|
+
s.add_dependency("termcolor", ">= 0.3.1")
|
|
29
|
+
s.add_dependency("rubytter", ">= 0.6.4")
|
|
30
|
+
s.authors = %w(jugyo ujihisa)
|
|
31
|
+
s.email = 'jugyo.org@gmail.com'
|
|
32
|
+
s.homepage = 'http://wiki.github.com/jugyo/termtter'
|
|
33
|
+
s.rubyforge_project = 'termtter'
|
|
34
|
+
s.has_rdoc = true
|
|
35
|
+
s.rdoc_options = ["--main", "README.rdoc", "--exclude", "spec"]
|
|
36
|
+
s.extra_rdoc_files = ["README.rdoc", "History.txt"]
|
|
37
|
+
end
|
|
38
|
+
EOS
|
|
39
|
+
end
|
|
40
|
+
puts "Generate gemspec"
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
desc 'Generate gem'
|
|
44
|
+
task :gem => :gemspec do |t|
|
|
45
|
+
system 'gem', 'build', 'termtter.gemspec'
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
namespace :gem do
|
|
49
|
+
desc 'Install needed gems'
|
|
50
|
+
task :install do
|
|
51
|
+
%w[ json_pure highline termcolor rubytter ].each do |gem|
|
|
52
|
+
sh "sudo gem install #{gem} -r"
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
end
|
data/bin/kill_termtter
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# If your termtter can't be exited, you might use this script.
|
|
3
|
+
#
|
|
4
|
+
# > exit
|
|
5
|
+
# (no response...)
|
|
6
|
+
# C-z
|
|
7
|
+
# $ kill_termtter -i
|
|
8
|
+
# y
|
|
9
|
+
#
|
|
10
|
+
# OPTION
|
|
11
|
+
# -i interactive
|
|
12
|
+
def s(a)
|
|
13
|
+
puts a
|
|
14
|
+
system a
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
`ps`.map(&:split).map {|i|
|
|
18
|
+
pid, runner, file = i[0], i[4], i[5]
|
|
19
|
+
if runner == 'ruby' && $$ != pid.to_i && /termtter/ =~ file
|
|
20
|
+
s "kill -KILL #{pid}"
|
|
21
|
+
end
|
|
22
|
+
}
|
data/bin/termtter
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
|
|
3
|
+
config.plugins.addspace.set_default( :before, [ %r{https?://} ] )
|
|
4
|
+
config.plugins.addspace.set_default( :after, %w{ ★ ☆ △ ▽ … })
|
|
5
|
+
|
|
6
|
+
module Termtter::Client
|
|
7
|
+
add_filter do |statuses, event|
|
|
8
|
+
statuses.each do |s|
|
|
9
|
+
config.plugins.addspace.before.each do |c|
|
|
10
|
+
s.text.gsub!(/(?<=\S)(#{c})/, ' \1' )
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
statuses.each do |s|
|
|
14
|
+
config.plugins.addspace.after.each do |c|
|
|
15
|
+
s.text.gsub!(/(#{c})(?=\S)/, '\1 ' )
|
|
16
|
+
end
|
|
17
|
+
statuses
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
# addspace
|
|
22
|
+
# add space before or after specified words.
|
|
23
|
+
# example:
|
|
24
|
+
# before: ABCDEhttp://~~~
|
|
25
|
+
# after: ABCDE http://~~~
|
|
26
|
+
# before: ★★★
|
|
27
|
+
# after: ★ ★ ★
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
|
|
3
|
+
def april_fool?;true;end
|
|
4
|
+
def april_fool;april_fool? ? "今日はエイプリルフールではありません。" : "今日はエイプリルフールです。";end
|
|
5
|
+
|
|
6
|
+
Termtter::Client.register_command(
|
|
7
|
+
:name => :april_fool, :aliases => [:af],
|
|
8
|
+
:exec_proc => lambda {|arg|
|
|
9
|
+
if arg =~ /^\?you\s(\w+)/
|
|
10
|
+
puts "=> #{Termtter::Client.update_status("@#{$1} #{april_fool}")}"
|
|
11
|
+
else
|
|
12
|
+
puts "=> #{Termtter::Client.update_status(april_fool)}"
|
|
13
|
+
end
|
|
14
|
+
}
|
|
15
|
+
)
|
data/lib/plugins/bomb.rb
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
require 'enumerator'
|
|
3
|
+
|
|
4
|
+
module Termtter
|
|
5
|
+
module Client
|
|
6
|
+
config.plugins.bomb.set_default :format, "<on_red><white>%s</white></on_red>"
|
|
7
|
+
|
|
8
|
+
register_hook(
|
|
9
|
+
:name => :bomb,
|
|
10
|
+
:points => [:output],
|
|
11
|
+
:exec_proc => lambda{|statuses, event|
|
|
12
|
+
statuses.each do |status|
|
|
13
|
+
if /爆発|bomb/ =~ status.text
|
|
14
|
+
status.text = config.plugins.bomb.format % status.text
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
}
|
|
18
|
+
)
|
|
19
|
+
|
|
20
|
+
register_command(
|
|
21
|
+
:name => :bomb, :aliases => [],
|
|
22
|
+
:exec_proc => lambda {|arg|
|
|
23
|
+
text = "#{arg.strip} 爆発しろ!"
|
|
24
|
+
Termtter::API::twitter.update(text)
|
|
25
|
+
puts "=> #{text}"
|
|
26
|
+
},
|
|
27
|
+
:help => ['bomb WORD', 'Bomb it']
|
|
28
|
+
)
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
# bomb.rb
|
|
33
|
+
# Bomb it!
|
|
34
|
+
#
|
|
35
|
+
# See http://gyazo.com/4b33517380673d92f51a52e675ecdb02.png .
|
|
36
|
+
# config.plugins.bomb.color.foreground = 'white'
|
|
37
|
+
# config.plugins.bomb.color.background = 'red'
|
|
38
|
+
#
|
|
39
|
+
# vim: fenc=utf8
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
|
|
3
|
+
module Termtter::Client
|
|
4
|
+
register_command :name => :clear, :aliases => [:cls],
|
|
5
|
+
:help => ['clear,cls', "Clear termtter's buffer"],
|
|
6
|
+
:exec_proc => lambda {|args|
|
|
7
|
+
system 'clear'
|
|
8
|
+
}
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
# todo:
|
|
12
|
+
# support windows.
|
|
13
|
+
# i don't have windows machine and cannot test:P
|
|
14
|
+
# cls command?
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
module Termtter::Client
|
|
3
|
+
class << self
|
|
4
|
+
def delete_command(arg)
|
|
5
|
+
if @commands.delete(arg.to_sym)
|
|
6
|
+
puts "#{arg} command is deleted."
|
|
7
|
+
else
|
|
8
|
+
raise "#{arg} command is not found."
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def alias_command(arg)
|
|
13
|
+
original, new = arg.split(/\s+/)
|
|
14
|
+
if @commands[original.to_sym]
|
|
15
|
+
@commands[new.to_sym] = @commands[original.to_sym].clone
|
|
16
|
+
@commands[new.to_sym].name = new.to_sym
|
|
17
|
+
@commands[new.to_sym].aliases = []
|
|
18
|
+
@commands[new.to_sym].help = ''
|
|
19
|
+
puts "alias '#{original}' to '#{new}'."
|
|
20
|
+
else
|
|
21
|
+
raise "#{original} command is not found."
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
module Termtter::Client
|
|
28
|
+
register_command(
|
|
29
|
+
:name => :delete_command,
|
|
30
|
+
:exec_proc => lambda {|arg|
|
|
31
|
+
Termtter::Client.delete_command(arg)
|
|
32
|
+
},
|
|
33
|
+
:completion_proc => lambda {|cmd, arg|
|
|
34
|
+
},
|
|
35
|
+
:help => ['delete_command command', 'delete command from command list (this command is experimental!)']
|
|
36
|
+
)
|
|
37
|
+
|
|
38
|
+
register_command(
|
|
39
|
+
:name => :alias_command,
|
|
40
|
+
:exec_proc => lambda {|arg|
|
|
41
|
+
Termtter::Client.alias_command(arg)
|
|
42
|
+
},
|
|
43
|
+
:completion_proc => lambda {|cmd, arg|
|
|
44
|
+
},
|
|
45
|
+
:help => ['alias_command A B', 'alias command A to B (this command is experimental!)']
|
|
46
|
+
)
|
|
47
|
+
end
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
|
|
3
|
+
config.plugins.confirm.set_default(:commands, [:update, :reply, :direct])
|
|
4
|
+
config.plugins.confirm.set_default(
|
|
5
|
+
:conditions,
|
|
6
|
+
[
|
|
7
|
+
lambda { |cmd_name, arg|
|
|
8
|
+
if cmd_name == :direct && arg =~ /^(list|sent_list)$/
|
|
9
|
+
false
|
|
10
|
+
else
|
|
11
|
+
true
|
|
12
|
+
end
|
|
13
|
+
}
|
|
14
|
+
]
|
|
15
|
+
)
|
|
16
|
+
|
|
17
|
+
Termtter::Client.register_hook(
|
|
18
|
+
:name => :confirm,
|
|
19
|
+
:points => [/^pre_exec_/],
|
|
20
|
+
:exec_proc => lambda {|cmd, arg|
|
|
21
|
+
if config.plugins.confirm.commands.include?(cmd.name) &&
|
|
22
|
+
config.plugins.confirm.conditions.any? { |cond| cond.call(cmd.name, arg) }
|
|
23
|
+
|
|
24
|
+
prompt = "\"#{cmd.name} #{arg}".strip + "\" [Y/n] "
|
|
25
|
+
|
|
26
|
+
if /^y?$/i !~ Readline.readline(prompt, false)
|
|
27
|
+
puts 'canceled.'
|
|
28
|
+
raise Termtter::CommandCanceled
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
end
|
|
32
|
+
}
|
|
33
|
+
)
|
data/lib/plugins/cool.rb
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
module Termtter::Client
|
|
2
|
+
register_command(
|
|
3
|
+
:name => :countter,
|
|
4
|
+
:exec_proc => lambda {|arg|
|
|
5
|
+
count = {}
|
|
6
|
+
public_storage[:log].each do |l|
|
|
7
|
+
source = l.source =~ /(?:<a href=\".+?\">)(.+)(?:<\/a>)/ ? $1 : l.source
|
|
8
|
+
count[source] = 0 unless count[source]
|
|
9
|
+
count[source] += 1
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
format = "%24s %6s"
|
|
13
|
+
puts format % %w(sources count)
|
|
14
|
+
puts format % ['-'*24, '-'*6]
|
|
15
|
+
count.to_a.sort{|a,b|b[1]<=>a[1]}.each do |k,v|
|
|
16
|
+
puts format % [k, v]
|
|
17
|
+
end
|
|
18
|
+
},
|
|
19
|
+
:completion_proc => lambda {|cmd, arg|
|
|
20
|
+
},
|
|
21
|
+
:help => ['countter', 'count sources']
|
|
22
|
+
)
|
|
23
|
+
end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
|
|
3
|
+
begin
|
|
4
|
+
require 'ruby-debug'
|
|
5
|
+
rescue LoadError
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
module Termtter::Client
|
|
9
|
+
register_command(
|
|
10
|
+
:name => :eval,
|
|
11
|
+
:aliases => [],
|
|
12
|
+
:exec_proc => lambda {|arg|
|
|
13
|
+
result = eval(arg) unless arg.empty?
|
|
14
|
+
puts "=> #{result.inspect}"
|
|
15
|
+
},
|
|
16
|
+
:help => ['eval EXPR', 'evaluate expression']
|
|
17
|
+
)
|
|
18
|
+
end
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
module Termtter::Client
|
|
3
|
+
register_command(
|
|
4
|
+
:name => :direct_messages,
|
|
5
|
+
:aliases => [:ds],
|
|
6
|
+
:exec_proc => lambda {|arg|
|
|
7
|
+
event = :list_user_timeline
|
|
8
|
+
ds = Termtter::API.twitter.direct_messages
|
|
9
|
+
DM = Struct.new :id, :text, :user, :created_at, :in_reply_to_status_id
|
|
10
|
+
statuses = ds.map do |d|
|
|
11
|
+
DM.new(d.id, d.text, d.sender, d.created_at)
|
|
12
|
+
end
|
|
13
|
+
output(statuses, event)
|
|
14
|
+
},
|
|
15
|
+
:completion_proc => lambda {|cmd, arg|
|
|
16
|
+
},
|
|
17
|
+
:help => ['direct_messages,ds', 'List direct messages for you']
|
|
18
|
+
)
|
|
19
|
+
|
|
20
|
+
register_command(
|
|
21
|
+
:name => :sent_direct_messages,
|
|
22
|
+
:aliases => [:sds],
|
|
23
|
+
:exec_proc => lambda {|arg|
|
|
24
|
+
event = :list_user_timeline
|
|
25
|
+
ds = Termtter::API.twitter.sent_direct_messages
|
|
26
|
+
DM = Struct.new :id, :text, :user, :created_at, :in_reply_to_status_id
|
|
27
|
+
statuses = ds.map do |d|
|
|
28
|
+
DM.new(d.id, "@#{d.recipient.screen_name} #{d.text}", d.sender, d.created_at)
|
|
29
|
+
end
|
|
30
|
+
output(statuses, event)
|
|
31
|
+
},
|
|
32
|
+
:completion_proc => lambda {|cmd, arg|
|
|
33
|
+
},
|
|
34
|
+
:help => ['sent_direct_messages, sds', 'List direct messages from you']
|
|
35
|
+
)
|
|
36
|
+
end
|