kimotter 0.0.2 → 0.0.3
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/bin/kimotter +35 -38
- metadata +2 -2
data/bin/kimotter
CHANGED
@@ -1,50 +1,47 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
# encoding: utf-8
|
3
|
-
$LOAD_PATH << File.expand_path(File.join(File.dirname(__FILE__), "../lib"))
|
3
|
+
# $LOAD_PATH << File.expand_path(File.join(File.dirname(__FILE__), "../lib"))
|
4
4
|
require 'kimotter'
|
5
5
|
require 'logger'
|
6
|
+
require 'optparse'
|
6
7
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
}
|
18
|
-
}.parse!
|
8
|
+
options = {}
|
9
|
+
OptionParser.new{ |opts|
|
10
|
+
opts.banner = "Usage: #{$0} [options] tweet_message"
|
11
|
+
opts.on("-d", "--debug", "Debug Mode"){ |v|
|
12
|
+
options[:debug_mode] = true
|
13
|
+
}
|
14
|
+
opts.on("-f", "--force", "Force execute, ignore api limit"){ |v|
|
15
|
+
options[:force_execute] = true
|
16
|
+
}
|
17
|
+
}.parse!
|
19
18
|
|
20
|
-
|
21
|
-
|
19
|
+
message = ARGV.shift
|
20
|
+
raise "argument error" unless message
|
22
21
|
|
23
|
-
|
24
|
-
|
22
|
+
logger = options[:debug_mode] ? Logger.new(STDERR) : Logger.new(nil)
|
23
|
+
kimotter = Kimotter.new(:logger => logger)
|
25
24
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
25
|
+
kimotter.fetch_api_limit
|
26
|
+
if !options[:force_execute] and kimotter.api_limit?
|
27
|
+
puts "u cant use this api now(api limit)"
|
28
|
+
puts "try again later or retry with --force option (ignore API limit)"
|
29
|
+
exit(1)
|
30
|
+
end
|
32
31
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
else
|
42
|
-
puts "u guys so fucking retard"
|
43
|
-
exit(3)
|
44
|
-
end
|
32
|
+
print kimotter.confirm_msg + "[y/N] "
|
33
|
+
if user_input_line = $stdin.gets
|
34
|
+
if user_input_line =~ /^(yes|y)$/i
|
35
|
+
puts "hi kimoto. try to tweet your message"
|
36
|
+
puts message
|
37
|
+
kimotter.tweet(message)
|
38
|
+
puts "done"
|
39
|
+
exit(0)
|
45
40
|
else
|
46
|
-
puts "
|
47
|
-
exit(
|
41
|
+
puts "u guys so fucking retard"
|
42
|
+
exit(3)
|
48
43
|
end
|
44
|
+
else
|
45
|
+
puts "omg?"
|
46
|
+
exit(2)
|
49
47
|
end
|
50
|
-
|