termtter 1.6.0 → 1.7.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.
- 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
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
module Termtter::Client
|
|
2
|
+
register_command(
|
|
3
|
+
:profile,
|
|
4
|
+
:aliases => [:p],
|
|
5
|
+
:help => ["user show USERNAME/[SLUG]", "Show user's profile."]
|
|
6
|
+
) do |arg|
|
|
7
|
+
user_name = arg.empty? ? config.user_name : arg
|
|
8
|
+
if user_name =~ /\//
|
|
9
|
+
user_name, slug = *user_name.split('/')
|
|
10
|
+
user_name = normalize_as_user_name(user_name)
|
|
11
|
+
list = Termtter::API.twitter.list(user_name, slug)
|
|
12
|
+
attrs = %w[ full_name slug description mode id member_count subscriber_count]
|
|
13
|
+
label_width = attrs.map(&:size).max
|
|
14
|
+
attrs.each do |attr|
|
|
15
|
+
value = list.__send__(attr.to_sym)
|
|
16
|
+
puts "#{attr.gsub('_', ' ').rjust(label_width)}: #{value}"
|
|
17
|
+
end
|
|
18
|
+
else
|
|
19
|
+
user = Termtter::API.twitter.user(user_name)
|
|
20
|
+
attrs = %w[ name screen_name url description profile_image_url location protected following
|
|
21
|
+
friends_count followers_count statuses_count favourites_count
|
|
22
|
+
id time_zone created_at utc_offset notifications
|
|
23
|
+
]
|
|
24
|
+
label_width = attrs.map(&:size).max
|
|
25
|
+
attrs.each do |attr|
|
|
26
|
+
value = user.__send__(attr.to_sym)
|
|
27
|
+
puts "#{attr.gsub('_', ' ').rjust(label_width)}: #{value}"
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
class UserSearchEvent; attr_reader :query; def initialize(query); @query = query end; end
|
|
33
|
+
|
|
34
|
+
register_command(
|
|
35
|
+
'user search',
|
|
36
|
+
:help => ["user search QUERY", "search users"]
|
|
37
|
+
) do |arg|
|
|
38
|
+
search_option = config.user_search.option.empty? ? {} : config.user_search.option
|
|
39
|
+
statuses = Termtter::API.twitter.search_user(arg, search_option)
|
|
40
|
+
results = []
|
|
41
|
+
statuses.select{|s| s.status != nil }.map do |s|
|
|
42
|
+
result = {
|
|
43
|
+
:id => s.status.id,
|
|
44
|
+
:text => s.status.text,
|
|
45
|
+
:in_reply_to_status_id => s.in_reply_to_status_id,
|
|
46
|
+
:created_at => s.created_at,
|
|
47
|
+
:user => {:id => s.id, :name => s.name, :screen_name => s.screen_name}
|
|
48
|
+
}
|
|
49
|
+
results << Rubytter.structize(result)
|
|
50
|
+
end
|
|
51
|
+
output(results, UserSearchEvent.new(arg))
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
register_hook(:highlight_for_user_search, :point => :pre_coloring) do |text, event|
|
|
55
|
+
case event
|
|
56
|
+
when UserSearchEvent
|
|
57
|
+
query = event.query.split(/\s/).map {|q|Regexp.quote(q)}.join("|")
|
|
58
|
+
text.gsub(/(#{query})(.*:)/i, '<on_magenta><white>\1</white></on_magenta>\2')
|
|
59
|
+
else
|
|
60
|
+
text
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
end
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
config.plugins.draft.set_default(:ignore, [/^(reload\s+\-r|draft)/])
|
|
2
|
+
|
|
3
|
+
def list_drafts(drafts)
|
|
4
|
+
drafts.each_with_index do |draft, index|
|
|
5
|
+
puts "#{index}: #{draft}"
|
|
6
|
+
end
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def get_draft_index(arg)
|
|
10
|
+
case arg
|
|
11
|
+
when /^\d+$/
|
|
12
|
+
arg.to_i
|
|
13
|
+
when ''
|
|
14
|
+
-1
|
|
15
|
+
else
|
|
16
|
+
nil
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
module Termtter::Client
|
|
21
|
+
public_storage[:drafts] ||= []
|
|
22
|
+
|
|
23
|
+
register_hook(:save_as_draft, :point => :timeout) do |input_text|
|
|
24
|
+
if !config.plugins.draft.ignore.any? {|pattern| pattern =~ input_text} &&
|
|
25
|
+
public_storage[:drafts].last != input_text
|
|
26
|
+
public_storage[:drafts] << input_text
|
|
27
|
+
puts "Save as draft: #{input_text}"
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
register_command('draft list') do |arg|
|
|
32
|
+
list_drafts(public_storage[:drafts])
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
register_command('draft exec') do |arg|
|
|
36
|
+
index = get_draft_index(arg)
|
|
37
|
+
if index
|
|
38
|
+
command = public_storage[:drafts][index]
|
|
39
|
+
if command
|
|
40
|
+
puts "exec => \"#{command}\""
|
|
41
|
+
execute(public_storage[:drafts][index])
|
|
42
|
+
public_storage[:drafts].delete_at(index)
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
register_command('draft delete') do |arg|
|
|
48
|
+
index = get_draft_index(arg)
|
|
49
|
+
if index
|
|
50
|
+
deleted = public_storage[:drafts].delete_at(index)
|
|
51
|
+
puts "deleted => \"#{deleted}\"" if deleted
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
register_command('draft clear') do |arg|
|
|
56
|
+
public_storage[:drafts].clear
|
|
57
|
+
end
|
|
58
|
+
end
|
|
@@ -5,8 +5,8 @@ URL_SHORTTERS = [
|
|
|
5
5
|
{ :host => "is.gd", :pattern => %r'(http://is\.gd(/[\w/]+))' },
|
|
6
6
|
{ :host => "bit.ly", :pattern => %r'(http://bit\.ly(/[\w/]+))' },
|
|
7
7
|
{ :host => "ff.im", :pattern => %r'(http://ff\.im(/[-\w/]+))'},
|
|
8
|
-
{ :host => "to.ly", :pattern => %r'(http://to\.ly(/[-\w/]+))'},
|
|
9
8
|
{ :host => "j.mp", :pattern => %r'(http://j\.mp(/[\w/]+))' },
|
|
9
|
+
{ :host => "goo.gl", :pattern => %r'(http://goo\.gl(/[\w/]+))' },
|
|
10
10
|
]
|
|
11
11
|
|
|
12
12
|
config.plugins.expand_tinyurl.set_default(:shortters, [])
|
|
@@ -44,16 +44,12 @@ Termtter::Client::register_hook(
|
|
|
44
44
|
)
|
|
45
45
|
|
|
46
46
|
def expand_url(host, path)
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
http_class = Net::HTTP::Proxy(config.proxy.host,
|
|
50
|
-
config.proxy.port,
|
|
51
|
-
config.proxy.user_name,
|
|
52
|
-
config.proxy.password)
|
|
47
|
+
res = Termtter::HTTPpool.start(host) do |h|
|
|
48
|
+
h.get(path, { 'User-Agent' => 'Mozilla' })
|
|
53
49
|
end
|
|
54
|
-
res = http_class.new(host).get(path, { 'User-Agent' => 'Mozilla' })
|
|
55
50
|
return nil unless res.code == "301" or res.code == "302"
|
|
56
51
|
res['Location'].force_encoding(Encoding::UTF_8)
|
|
57
|
-
rescue
|
|
52
|
+
rescue Exception => e
|
|
53
|
+
Termtter::Client.handle_error(e)
|
|
58
54
|
nil
|
|
59
55
|
end
|
data/lib/plugins/favotter.rb
CHANGED
|
@@ -70,7 +70,7 @@ module Termtter::Client
|
|
|
70
70
|
register_command('favotter_fav', :alias => :ffav, :help => help) do |arg|
|
|
71
71
|
raise 'need favorited_id' if arg.empty?
|
|
72
72
|
if id = public_storage[:favorited_ids][arg]
|
|
73
|
-
|
|
73
|
+
execute("favorite #{id}")
|
|
74
74
|
end
|
|
75
75
|
end
|
|
76
76
|
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
#-*- coding: utf-8 -*-
|
|
2
|
+
|
|
3
|
+
config.set_default('footer',nil)
|
|
4
|
+
|
|
5
|
+
Termtter::Client.register_hook(
|
|
6
|
+
:name => :add_footer,
|
|
7
|
+
:points => [:modify_arg_for_update, :modify_arg_for_reply],
|
|
8
|
+
:exec => lambda {|cmd, arg|
|
|
9
|
+
(config.footer.nil? || config.footer.empty?) ? arg : arg + " #{config.footer}"
|
|
10
|
+
}
|
|
11
|
+
)
|
|
12
|
+
|
|
13
|
+
Termtter::Client.register_command(
|
|
14
|
+
:name => :footer,
|
|
15
|
+
:aliases => [:ft],
|
|
16
|
+
:exec => lambda {|arg|
|
|
17
|
+
arg.empty? ? config.footer = nil : config.footer = arg
|
|
18
|
+
puts config.footer.nil? ? "footer is turned off" : "new footer=> #{config.footer}"
|
|
19
|
+
}
|
|
20
|
+
)
|
|
21
|
+
|
|
22
|
+
|
data/lib/plugins/friends.rb
CHANGED
|
@@ -4,13 +4,14 @@ module Termtter::Client
|
|
|
4
4
|
class << self
|
|
5
5
|
def get_friends(user_name, max)
|
|
6
6
|
friends = []
|
|
7
|
-
|
|
7
|
+
cursor = -1
|
|
8
8
|
begin
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
tmp = Termtter::API::twitter.friends(user_name, :cursor => cursor)
|
|
10
|
+
cursor = tmp[:next_cursor]
|
|
11
|
+
friends += tmp[:users]
|
|
11
12
|
puts "#{friends.length}/#{max}"
|
|
12
13
|
rescue
|
|
13
|
-
end until (
|
|
14
|
+
end until (cursor.zero? or friends.length > max)
|
|
14
15
|
friends.take(max)
|
|
15
16
|
end
|
|
16
17
|
end
|
data/lib/plugins/g.rb
CHANGED
|
@@ -1,16 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
g eval(arg)
|
|
11
|
-
}
|
|
12
|
-
)
|
|
13
|
-
rescue e
|
|
14
|
-
handle_error(e)
|
|
15
|
-
end
|
|
16
|
-
end
|
|
1
|
+
require 'g'
|
|
2
|
+
Termtter::Client.register_command(
|
|
3
|
+
:g,
|
|
4
|
+
:help => ['g OBJECT', "Do you know 'g'? It's like 'p'."]
|
|
5
|
+
) do |arg|
|
|
6
|
+
# we get arg as String, so without eval() it is not very useful
|
|
7
|
+
# but we shouldn't blindly eval user-supplied string like this, either
|
|
8
|
+
g eval(arg)
|
|
9
|
+
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# Plugin gem_install
|
|
2
|
+
# AUTHOR: Tatsuhiro Ujihisa <http://ujihisa.blogspot.com/>
|
|
3
|
+
# SYNOPSIS:
|
|
4
|
+
# Once you use this plugin by `plug gem_install`, your termtter will
|
|
5
|
+
# install arbitrary gem libraries when they appeared on your timeline,
|
|
6
|
+
# replies or anything on your termtter.
|
|
7
|
+
# How useful it is.
|
|
8
|
+
# If you already have `g`, the automatic installation will be announced
|
|
9
|
+
# on your Growl.
|
|
10
|
+
Termtter::Client.register_hook(
|
|
11
|
+
:name => :gem_install,
|
|
12
|
+
:points => [:output],
|
|
13
|
+
:exec_proc => lambda {|statuses, _|
|
|
14
|
+
statuses.each do |s|
|
|
15
|
+
/gem install ([a-zA-Z0-9_\-]+)/ =~ s.text
|
|
16
|
+
if gem_name = $1
|
|
17
|
+
(private_methods.map(&:to_sym).include?(:g) ? method(:g) : method(:p)).
|
|
18
|
+
call("Termtter's `gem_install` plugin is now installing #{gem_name}")
|
|
19
|
+
fork do
|
|
20
|
+
system 'gem', 'install', gem_name
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
})
|
data/lib/plugins/gist.rb
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
|
|
3
|
+
Termtter::Client.register_command(
|
|
4
|
+
:name => :gist,
|
|
5
|
+
:exec => lambda {|arg|
|
|
6
|
+
args = arg.split(' ')
|
|
7
|
+
output = args[0] == '-p' ?
|
|
8
|
+
`#{args[1..-1].join(' ')} | gist -p` :
|
|
9
|
+
`#{args.join(' ')} | gist`
|
|
10
|
+
Termtter::API.twitter.update(output)
|
|
11
|
+
puts "=> " <<output
|
|
12
|
+
}
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
# gist.rb : Executes command and creates gist with the output
|
|
16
|
+
# Depends on : http://github.com/defunkt/gist
|
|
17
|
+
# Usage : gist command_to_execute
|
|
18
|
+
# Examples :
|
|
19
|
+
# > gist ls (public gist)
|
|
20
|
+
# > gist -p ifconfig (private gist)
|
data/lib/plugins/grass.rb
CHANGED
|
@@ -12,7 +12,7 @@ module Termtter
|
|
|
12
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
|
+
execute("update #{grasses}")
|
|
16
16
|
},
|
|
17
17
|
:help => ['grass, w', 'Grass it!']
|
|
18
18
|
)
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
require 'net/http'
|
|
2
|
+
|
|
3
|
+
def post_gyazo
|
|
4
|
+
browser_cmd = 'firefox'
|
|
5
|
+
gyazo_url = ""
|
|
6
|
+
|
|
7
|
+
idfile = ENV['HOME'] + "/.gyazo.id"
|
|
8
|
+
|
|
9
|
+
id = ''
|
|
10
|
+
if File.exist?(idfile) then
|
|
11
|
+
id = File.read(idfile).chomp
|
|
12
|
+
else
|
|
13
|
+
id = Time.new.strftime("%Y%m%d%H%M%S")
|
|
14
|
+
File.open(idfile,"w").print(id+"\n")
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
tmpfile = "/tmp/image_upload#{$$}.png"
|
|
18
|
+
|
|
19
|
+
system "import #{tmpfile}"
|
|
20
|
+
|
|
21
|
+
imagedata = File.read(tmpfile)
|
|
22
|
+
File.delete(tmpfile)
|
|
23
|
+
|
|
24
|
+
boundary = '----BOUNDARYBOUNDARY----'
|
|
25
|
+
|
|
26
|
+
data = <<EOF
|
|
27
|
+
--#{boundary}\r
|
|
28
|
+
content-disposition: form-data; name="id"\r
|
|
29
|
+
\r
|
|
30
|
+
#{id}\r
|
|
31
|
+
--#{boundary}\r
|
|
32
|
+
content-disposition: form-data; name="imagedata"\r
|
|
33
|
+
\r
|
|
34
|
+
#{imagedata}\r
|
|
35
|
+
\r
|
|
36
|
+
--#{boundary}--\r
|
|
37
|
+
EOF
|
|
38
|
+
|
|
39
|
+
header ={
|
|
40
|
+
'Content-Length' => data.length.to_s,
|
|
41
|
+
'Content-type' => "multipart/form-data; boundary=#{boundary}"
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
Net::HTTP.start("gyazo.com",80){|http|
|
|
45
|
+
res = http.post("/upload.cgi",data,header)
|
|
46
|
+
url = res.response.to_ary[1]
|
|
47
|
+
puts url
|
|
48
|
+
system "#{browser_cmd} #{url}"
|
|
49
|
+
gyazo_url = url
|
|
50
|
+
}
|
|
51
|
+
return gyazo_url
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
Termtter::Client.register_command(
|
|
55
|
+
:name => :gyazo,
|
|
56
|
+
:help => ['gyazo comment', 'upload a captured image'],
|
|
57
|
+
:exec => lambda {|arg|
|
|
58
|
+
text = arg
|
|
59
|
+
url = post_gyazo
|
|
60
|
+
Termtter::API.twitter.update(text + " " + url)
|
|
61
|
+
puts "=> " << text + " " + url
|
|
62
|
+
}
|
|
63
|
+
)
|
|
64
|
+
|
|
65
|
+
# gyazo:
|
|
66
|
+
# Capture an arbitary desktop area and upload the image to gyazo.com,
|
|
67
|
+
# open it up with the browser you specified. Then, tweet the link with
|
|
68
|
+
# a message.
|
|
69
|
+
#
|
|
70
|
+
# You need ImageMagick tools and a web browser(default:Firefox, as you
|
|
71
|
+
# can see.)
|
|
72
|
+
#
|
|
73
|
+
# thanks to:
|
|
74
|
+
# http://yaa.no-ip.org/~yaa/diary/20071108.html#p04
|
|
75
|
+
#
|
|
76
|
+
# example:
|
|
77
|
+
# gyazo What a lame dialogue message! (capture process starts...)
|
|
78
|
+
#
|
data/lib/plugins/http_server.rb
CHANGED
|
@@ -66,7 +66,7 @@ module Termtter::Client
|
|
|
66
66
|
@http_server_output = ''
|
|
67
67
|
begin
|
|
68
68
|
command = req.path.sub(/^\//, '')
|
|
69
|
-
|
|
69
|
+
execute(command)
|
|
70
70
|
res['Content-Type'] = 'text/javascript; charset=utf-8';
|
|
71
71
|
res.body = @http_server_output
|
|
72
72
|
rescue Termtter::CommandNotFound => e
|
data/lib/plugins/hugeurl.rb
CHANGED
|
@@ -14,20 +14,13 @@ Termtter::Client::register_hook(
|
|
|
14
14
|
:name => :hugeurl,
|
|
15
15
|
:point => :filter_for_output,
|
|
16
16
|
:exec_proc => lambda do |statuses, event|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
config.proxy.password)
|
|
23
|
-
end
|
|
24
|
-
http_class.start('search.twitter.com') do |http|
|
|
25
|
-
statuses.each do |s|
|
|
26
|
-
config.plugins.hugeurl.skip_users.include?(s.user.screen_name) and next
|
|
27
|
-
s.text.gsub!(HUGEURL_TARGET_PATTERN) do |m|
|
|
28
|
-
res = http.get('/hugeurl?url=' + m)
|
|
29
|
-
res.code == '200' && res.body !~ /^</ ? res.body : m
|
|
17
|
+
statuses.each do |s|
|
|
18
|
+
config.plugins.hugeurl.skip_users.include?(s.user.screen_name) and next
|
|
19
|
+
s.text.gsub!(HUGEURL_TARGET_PATTERN) do |m|
|
|
20
|
+
res = Termtter::HTTPpool.start('search.twitter.com') do |h|
|
|
21
|
+
h.get('/hugeurl?url=' + m)
|
|
30
22
|
end
|
|
23
|
+
res.code == '200' && res.body !~ /^</ ? res.body : m
|
|
31
24
|
end
|
|
32
25
|
end
|
|
33
26
|
statuses
|
data/lib/plugins/irc_gw.rb
CHANGED
|
@@ -10,12 +10,16 @@ module Termtter::Client
|
|
|
10
10
|
class << self
|
|
11
11
|
def following_friends
|
|
12
12
|
user_name = config.user_name
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
page = 0
|
|
13
|
+
frinends = []
|
|
14
|
+
last = nil
|
|
16
15
|
begin
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
puts "collecting friends (#{frinends.length})"
|
|
17
|
+
last = Termtter::API::twitter.friends(user_name, :cursor => last ? last.next_cursor : -1)
|
|
18
|
+
frinends += last.users
|
|
19
|
+
rescue Timeout::Error, StandardError # XXX
|
|
20
|
+
break
|
|
21
|
+
end until last.next_cursor == 0
|
|
22
|
+
puts "You have #{frinends.length} friends."
|
|
19
23
|
frinends.map(&:screen_name)
|
|
20
24
|
end
|
|
21
25
|
end
|
|
@@ -42,7 +46,7 @@ class TermtterIrcGateway < Net::IRC::Server::Session
|
|
|
42
46
|
if Termtter::Client.respond_to? :register_output
|
|
43
47
|
Termtter::Client.register_output(:irc) do |message|
|
|
44
48
|
@@listners.each do |listener|
|
|
45
|
-
listener.log(message.gsub(/\e\[\d+m/, '')) # remove escape sequence
|
|
49
|
+
listener.log(message.to_s.gsub(/\e\[\d+m/, '')) # remove escape sequence
|
|
46
50
|
end
|
|
47
51
|
end
|
|
48
52
|
end
|
|
@@ -74,9 +78,9 @@ class TermtterIrcGateway < Net::IRC::Server::Session
|
|
|
74
78
|
|
|
75
79
|
def on_message(m)
|
|
76
80
|
termtter_command = m.command.downcase + ' ' + m.params.join(' ')
|
|
77
|
-
return
|
|
81
|
+
return unless Termtter::Client.find_command(termtter_command)
|
|
78
82
|
post '#termtter', NOTICE, main_channel, '> ' + termtter_command
|
|
79
|
-
Termtter::Client.
|
|
83
|
+
Termtter::Client.execute(termtter_command)
|
|
80
84
|
rescue Exception => e
|
|
81
85
|
post '#termtter', NOTICE, main_channel, "#{e.class.to_s}: #{e.message}"
|
|
82
86
|
Termtter::Client.handle_error(e)
|
|
@@ -94,11 +98,11 @@ class TermtterIrcGateway < Net::IRC::Server::Session
|
|
|
94
98
|
target, message = *m.params
|
|
95
99
|
if message =~ / +\//
|
|
96
100
|
termtter_command = message.gsub(/ +\//, '')
|
|
97
|
-
return
|
|
101
|
+
return unless Termtter::Client.find_command(termtter_command)
|
|
98
102
|
post '#termtter', NOTICE, main_channel, '> ' + termtter_command
|
|
99
|
-
Termtter::Client.
|
|
103
|
+
Termtter::Client.execute(termtter_command)
|
|
100
104
|
else
|
|
101
|
-
Termtter::Client.
|
|
105
|
+
Termtter::Client.execute('update ' + message)
|
|
102
106
|
post @prefix, TOPIC, main_channel, message
|
|
103
107
|
end
|
|
104
108
|
rescue Exception => e
|