sendxmpp 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/sendxmpp/cli.rb +6 -5
- data/lib/sendxmpp/log.rb +1 -1
- data/lib/sendxmpp/message.rb +11 -8
- data/lib/sendxmpp/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 727afe5351444d8aeffcce48ffef45ffde53476b
|
4
|
+
data.tar.gz: 437f238d2cf65f544a26b23ca45cc2b0acf8fdce
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e2ee32f8db58c583ab877e512dda685b12ebef5f750082b9002dd8948f9db76fd53b3d11cb4f0a37813affbf6c0f45f03c93ee422d071766ad1c95a3a243f40f
|
7
|
+
data.tar.gz: c5567d460b9bda1342632de165c16b488cc91ff6647767516955aacf7b8ba71a9b674ef72c48ac71dd68e1e4b989fe6fef0b8e5c95df23d69b8cdd867461b788
|
data/lib/sendxmpp/cli.rb
CHANGED
@@ -23,7 +23,7 @@ module Sendxmpp
|
|
23
23
|
class_option :resource, default: "Sendxmpp", type: :string, required: false
|
24
24
|
class_option :password, default: "", type: :string, required: false
|
25
25
|
class_option :message, default: "", type: :string, aliases: '-m', required: false
|
26
|
-
class_option :jid, default: "", type: :string, required: false
|
26
|
+
class_option :jid, default: "", type: :string, required: false, aliases: '-j'
|
27
27
|
class_option :config, default: "#{ENV['HOME']}/.sendxmpprbrc", type: :string, aliases: "-c", required: false
|
28
28
|
class_option :logfile, default: nil, aliases: '-l', required: false
|
29
29
|
|
@@ -38,15 +38,16 @@ module Sendxmpp
|
|
38
38
|
# Raises ArgumentError if the main hash key was not found
|
39
39
|
def initialize(*args)
|
40
40
|
super
|
41
|
+
local_conf = options.dup
|
42
|
+
local_conf.delete_if{|k,v|v.nil?||(v.kind_of?(String) && v.empty?)}
|
43
|
+
update_config(local_conf)
|
41
44
|
if File.exists?(options[:config])
|
42
45
|
conf = IniFile.load(options[:config])["sendxmpp"]
|
43
46
|
if conf.nil? || conf.empty?
|
44
47
|
raise ArgumentError, "No [sendxmpp] section in ini file found!"
|
45
48
|
end
|
46
|
-
|
47
|
-
|
48
|
-
conf.merge!(local_conf)
|
49
|
-
update_config(conf)
|
49
|
+
conf.merge!(local_conf)
|
50
|
+
update_config(conf)
|
50
51
|
end
|
51
52
|
Log.logger.debug("finished loading configuration.")
|
52
53
|
$stdout.sync = true
|
data/lib/sendxmpp/log.rb
CHANGED
data/lib/sendxmpp/message.rb
CHANGED
@@ -28,24 +28,26 @@ module Sendxmpp
|
|
28
28
|
def initialize
|
29
29
|
@batch=false
|
30
30
|
if config.jid.nil? || config.jid.empty?
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
RAISE
|
31
|
+
Log.logger.error("JID is not defined.")
|
32
|
+
Log.logger.error("Please use the -j option or the directive jid=... in .sendxmpprbrc")
|
33
|
+
exit 1
|
35
34
|
end
|
36
|
-
|
37
35
|
jid = JID.new(config.jid)
|
38
36
|
Log.logger.debug("Initializing a new Jabber client instance.")
|
39
37
|
self.client = Client.new(jid)
|
40
38
|
Log.logger.debug("Initialized a new Jabber client instance.")
|
41
|
-
|
42
39
|
Log.logger.debug("Connecting to Jabber server.")
|
43
40
|
client.connect(config.server, config.port)
|
44
41
|
Log.logger.debug("Connected to Jabber server.")
|
45
|
-
|
46
42
|
Log.logger.debug("Authenticating with Jabber server.")
|
47
43
|
client.auth(config.password)
|
48
44
|
Log.logger.debug("Authenticating with Jabber server.")
|
45
|
+
rescue Jabber::ClientAuthenticationFailure => e
|
46
|
+
Log.logger.error("Authentication error for jid %s" % config.jid)
|
47
|
+
exit 1
|
48
|
+
rescue SocketError => e
|
49
|
+
Log.logger.error("There was an error connecting to the server: %s" % e.message)
|
50
|
+
exit 1
|
49
51
|
end
|
50
52
|
|
51
53
|
# Public: Singleton object getter
|
@@ -116,7 +118,8 @@ module Sendxmpp
|
|
116
118
|
def process_batch(&block)
|
117
119
|
Log.logger.info("Batch procession started.")
|
118
120
|
unless block_given?
|
119
|
-
|
121
|
+
Log.logger.error("Please specify a block to use this function.")
|
122
|
+
exit 1
|
120
123
|
end
|
121
124
|
@batch=true
|
122
125
|
yield
|
data/lib/sendxmpp/version.rb
CHANGED