rjp-twittermoo 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/twittermoo.rb +19 -3
- metadata +1 -1
data/bin/twittermoo.rb
CHANGED
@@ -14,11 +14,12 @@ $options = {
|
|
14
14
|
:once => nil,
|
15
15
|
:wait => 20,
|
16
16
|
:period => 3600,
|
17
|
-
:every => 300
|
17
|
+
:every => 300,
|
18
|
+
:keyfile => nil
|
18
19
|
}
|
19
20
|
|
20
21
|
OptionParser.new do |opts|
|
21
|
-
opts.banner = "Usage: twittermoo.rb [-v] [-p port] [-h host] [-d dbfile] [-c config] [-o] [-w N] [-p N] [-e N]"
|
22
|
+
opts.banner = "Usage: twittermoo.rb [-v] [-p port] [-h host] [-d dbfile] [-c config] [-o] [-w N] [-p N] [-e N] [-k file]"
|
22
23
|
|
23
24
|
opts.on("-v", "--[no-]verbose", "Run verbosely") do |v|
|
24
25
|
$options[:verbose] = v
|
@@ -55,8 +56,18 @@ OptionParser.new do |opts|
|
|
55
56
|
opts.on("-c", "--config CONFIG", String, "config file") do |p|
|
56
57
|
$options[:config] = p
|
57
58
|
end
|
59
|
+
|
60
|
+
opts.on("-k", "--key filename", String, "Shared key file") do |p|
|
61
|
+
$options[:keyfile] = p
|
62
|
+
end
|
63
|
+
|
58
64
|
end.parse!
|
59
65
|
|
66
|
+
if $options[:keyfile] then
|
67
|
+
puts "loading secret key from #{$options[:keyfile]}"
|
68
|
+
$options[:secret_key] = File.open($options[:keyfile]).read.chomp
|
69
|
+
end
|
70
|
+
|
60
71
|
def send_message(x)
|
61
72
|
if $options[:port].nil? then
|
62
73
|
puts "! #{x}"
|
@@ -64,6 +75,9 @@ def send_message(x)
|
|
64
75
|
begin
|
65
76
|
# irc_cat doesn't seem to like persistent connections
|
66
77
|
$socket = TCPSocket.new($options[:host], $options[:port])
|
78
|
+
if $options[:secret_key] then
|
79
|
+
x = "%/#{$options[:secret_key]}/% #{x}"
|
80
|
+
end
|
67
81
|
$socket.puts(x)
|
68
82
|
$socket.close
|
69
83
|
end
|
@@ -81,7 +95,9 @@ config = YAML::load(open($options[:config]))
|
|
81
95
|
|
82
96
|
# allow settings of options from the config file
|
83
97
|
unless config['options'].nil? then
|
84
|
-
|
98
|
+
config['options'].each { |k,v|
|
99
|
+
$options[k.to_sym] = v
|
100
|
+
}
|
85
101
|
end
|
86
102
|
|
87
103
|
# TODO add an option for OAuth
|