draftcode-termtter 1.0.8 → 1.1.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/lib/plugins/search_url.rb +12 -0
- data/lib/plugins/standard_plugins.rb +0 -2
- data/lib/plugins/update_timeline.rb +32 -0
- data/lib/termtter/client.rb +16 -35
- data/lib/termtter/optparse.rb +21 -2
- data/lib/termtter/version.rb +1 -1
- data/spec/termtter/client_spec.rb +0 -2
- metadata +3 -1
@@ -0,0 +1,12 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
|
3
|
+
module Termtter::Client
|
4
|
+
register_command(
|
5
|
+
:name => :search_url, :aliases => [],
|
6
|
+
:exec_proc => lambda{|arg|
|
7
|
+
statuses = public_storage[:log].select {|s| s.text =~ %r!https?://!}
|
8
|
+
output(statuses, :search)
|
9
|
+
},
|
10
|
+
:help => ['search_url', 'Search log for URL']
|
11
|
+
)
|
12
|
+
end
|
@@ -334,7 +334,6 @@ module Termtter::Client
|
|
334
334
|
|
335
335
|
public_storage[:users] ||= Set.new
|
336
336
|
public_storage[:status_ids] ||= Set.new
|
337
|
-
public_storage[:last_status_id] ||= Hash.new
|
338
337
|
|
339
338
|
register_hook(
|
340
339
|
:name => :for_completion,
|
@@ -345,7 +344,6 @@ module Termtter::Client
|
|
345
344
|
public_storage[:users] += s.text.scan(/@([a-zA-Z_0-9]*)/).flatten
|
346
345
|
public_storage[:status_ids].add(s.id)
|
347
346
|
public_storage[:status_ids].add(s.in_reply_to_status_id) if s.in_reply_to_status_id
|
348
|
-
public_storage[:last_status_id].store(s.user.screen_name, s.id)
|
349
347
|
end
|
350
348
|
}
|
351
349
|
)
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
module Termtter::Client
|
3
|
+
register_command(
|
4
|
+
:name => :_update_timeline,
|
5
|
+
:exec_proc => lambda {|arg|
|
6
|
+
begin
|
7
|
+
args = @since_id ? [{:since_id => @since_id}] : []
|
8
|
+
statuses = Termtter::API.twitter.friends_timeline(*args)
|
9
|
+
unless statuses.empty?
|
10
|
+
print "\e[1K\e[0G" unless win?
|
11
|
+
@since_id = statuses[0].id
|
12
|
+
output(statuses, :update_friends_timeline)
|
13
|
+
Readline.refresh_line
|
14
|
+
end
|
15
|
+
rescue OpenURI::HTTPError => e
|
16
|
+
if e.message == '401 Unauthorized'
|
17
|
+
puts 'Could not login'
|
18
|
+
puts 'plese check your account settings'
|
19
|
+
exit!
|
20
|
+
end
|
21
|
+
rescue => e
|
22
|
+
handle_error(e)
|
23
|
+
end
|
24
|
+
}
|
25
|
+
)
|
26
|
+
|
27
|
+
add_task(:name => :update_timeline, :interval => config.update_interval, :after => config.update_interval) do
|
28
|
+
call_commands('_update_timeline')
|
29
|
+
end
|
30
|
+
|
31
|
+
call_commands('_update_timeline')
|
32
|
+
end
|
data/lib/termtter/client.rb
CHANGED
@@ -230,36 +230,6 @@ module Termtter
|
|
230
230
|
end
|
231
231
|
end
|
232
232
|
|
233
|
-
|
234
|
-
# TODO: Make pluggable
|
235
|
-
def setup_update_timeline_task()
|
236
|
-
register_command(
|
237
|
-
:name => :_update_timeline,
|
238
|
-
:exec_proc => lambda {|arg|
|
239
|
-
begin
|
240
|
-
args = @since_id ? [{:since_id => @since_id}] : []
|
241
|
-
statuses = Termtter::API.twitter.friends_timeline(*args)
|
242
|
-
unless statuses.empty?
|
243
|
-
@since_id = statuses[0].id
|
244
|
-
output(statuses, :update_friends_timeline)
|
245
|
-
end
|
246
|
-
rescue OpenURI::HTTPError => e
|
247
|
-
if e.message == '401 Unauthorized'
|
248
|
-
puts 'Could not login'
|
249
|
-
puts 'plese check your account settings'
|
250
|
-
exit!
|
251
|
-
end
|
252
|
-
rescue => e
|
253
|
-
handle_error(e)
|
254
|
-
end
|
255
|
-
}
|
256
|
-
)
|
257
|
-
|
258
|
-
add_task(:name => :update_timeline, :interval => config.update_interval, :after => config.update_interval) do
|
259
|
-
call_commands('_update_timeline')
|
260
|
-
end
|
261
|
-
end
|
262
|
-
|
263
233
|
def logger
|
264
234
|
@logger
|
265
235
|
end
|
@@ -298,11 +268,22 @@ module Termtter
|
|
298
268
|
setup_logger()
|
299
269
|
post_config_load()
|
300
270
|
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
271
|
+
config.system.eval_scripts.each do |script|
|
272
|
+
begin
|
273
|
+
eval script
|
274
|
+
rescue Exception => e
|
275
|
+
handle_error(e)
|
276
|
+
end
|
277
|
+
end
|
278
|
+
|
279
|
+
config.system.run_commands.each { |cmd| call_commands(cmd) }
|
280
|
+
|
281
|
+
unless config.system.cmd_mode
|
282
|
+
call_hooks(:initialize)
|
283
|
+
plugin('update_timeline')
|
284
|
+
@task_manager.run()
|
285
|
+
call_hooks(:before_task_thread_run)
|
286
|
+
end
|
306
287
|
end
|
307
288
|
|
308
289
|
def handle_error(e)
|
data/lib/termtter/optparse.rb
CHANGED
@@ -1,14 +1,33 @@
|
|
1
1
|
OptionParser.new { |opt|
|
2
|
-
opt.
|
2
|
+
opt.program_name = 'Termtter'
|
3
|
+
|
4
|
+
opt.on('-f', '--config-file file', 'Set path to configfile') do |val|
|
3
5
|
config.system.__assign__(:conf_file, val)
|
4
6
|
end
|
7
|
+
|
5
8
|
opt.on('-t', '--termtter-directory directory', 'Set termtter directory') do |val|
|
6
9
|
config.system.__assign__(:conf_dir, val)
|
7
10
|
end
|
11
|
+
|
8
12
|
opt.on('-d', '--devel', 'Start in developer mode') do |flg|
|
9
13
|
config.system.__assign__(:devel, true) if flg
|
10
14
|
end
|
11
15
|
|
12
|
-
|
16
|
+
config.system.cmd_mode = false
|
17
|
+
opt.on('-c', '--command-mode', 'Run as command mode') do |flg|
|
18
|
+
config.system.cmd_mode = flg
|
19
|
+
end
|
20
|
+
|
21
|
+
config.system.run_commands = []
|
22
|
+
opt.on('-r', '--run-command command', 'Run command') do |cmd|
|
23
|
+
config.system.run_commands << cmd
|
24
|
+
end
|
25
|
+
|
26
|
+
config.system.eval_scripts = []
|
27
|
+
opt.on('-e', '--eval-script script', 'Eval script') do |script|
|
28
|
+
config.system.eval_scripts << script
|
29
|
+
end
|
30
|
+
|
31
|
+
opt.version = Termtter::VERSION
|
13
32
|
opt.parse!(ARGV)
|
14
33
|
}
|
data/lib/termtter/version.rb
CHANGED
@@ -181,8 +181,6 @@ module Termtter
|
|
181
181
|
Client.should_receive(:load_config)
|
182
182
|
Termtter::API.should_receive(:setup)
|
183
183
|
Client.should_receive(:post_config_load)
|
184
|
-
Client.should_receive(:call_hooks)
|
185
|
-
Client.should_receive(:setup_update_timeline_task)
|
186
184
|
Client.should_receive(:start_input_thread)
|
187
185
|
Client.run
|
188
186
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: draftcode-termtter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- draftcode
|
@@ -119,6 +119,7 @@ files:
|
|
119
119
|
- lib/plugins/scrape.rb
|
120
120
|
- lib/plugins/screen-notify.rb
|
121
121
|
- lib/plugins/screen.rb
|
122
|
+
- lib/plugins/search_url.rb
|
122
123
|
- lib/plugins/shell.rb
|
123
124
|
- lib/plugins/sl.rb
|
124
125
|
- lib/plugins/spam.rb
|
@@ -135,6 +136,7 @@ files:
|
|
135
136
|
- lib/plugins/translation.rb
|
136
137
|
- lib/plugins/typable_id.rb
|
137
138
|
- lib/plugins/update_editor.rb
|
139
|
+
- lib/plugins/update_timeline.rb
|
138
140
|
- lib/plugins/uri-open.rb
|
139
141
|
- lib/plugins/wassr_post.rb
|
140
142
|
- lib/plugins/yhara.rb
|