robit 0.0.2 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -1
- data/VERSION +1 -1
- data/bin/robit +13 -16
- data/lib/robit/plugins/alias_nick.rb +3 -2
- 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: b5b85c01b693f3ac29dd57d3dff69bdbc261846c
|
4
|
+
data.tar.gz: 1edbb9bf2cb403e3940d5f5175f176f4ee54a551
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7750236883ff882f7c9d32eb55702bcc448d3ac2fa63cd417760c03e14a5e26900b29e877627fb4b02d2529ecdb48f9082d4532156c33bf8b6c629b5a13c481e
|
7
|
+
data.tar.gz: 77498fd591231cbc34c2a18d9f2dcffefe0fe0cc39188c0bbd883a9a8d25acd610058678876195ade2d340ef758475c7daf6965ca8e9320efe0cba5d6622eaec
|
data/.gitignore
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0
|
1
|
+
1.0.0
|
data/bin/robit
CHANGED
@@ -16,6 +16,7 @@ require 'ostruct'
|
|
16
16
|
require 'logger'
|
17
17
|
require 'trollop'
|
18
18
|
require 'hipchat'
|
19
|
+
require 'json'
|
19
20
|
|
20
21
|
require_relative '../lib/robit'
|
21
22
|
|
@@ -29,36 +30,32 @@ Opts = Trollop::options do
|
|
29
30
|
|
30
31
|
Options:
|
31
32
|
EOS
|
32
|
-
opt :
|
33
|
-
opt :pass, "Jabber password", type: :string, required: true, short: 'p'
|
34
|
-
opt :nick, "HipChat @mention name", type: :string, required: true, short: 'n'
|
35
|
-
opt :name, "HipChat full name", type: :string, required: true, short: 'N'
|
36
|
-
opt :rooms, "Hipchat rooms", type: :string, required: true, short: 'r'
|
37
|
-
opt :api_key, "HipChat v1 API key", type: :string, required: true, short: 'k'
|
33
|
+
opt :config, "Path to configuration", type: :string, required: true, short: 'c'
|
38
34
|
end
|
39
35
|
|
40
|
-
|
41
|
-
|
36
|
+
Config = JSON::parse File::read(Opts[:config]), symbolize_names: true
|
42
37
|
|
43
38
|
Robut::Connection.configure do |config|
|
44
|
-
config.jid =
|
45
|
-
config.password =
|
46
|
-
config.mention_name =
|
47
|
-
config.nick =
|
48
|
-
config.rooms =
|
39
|
+
config.jid = Config[:jabber_user]
|
40
|
+
config.password = Config[:jabber_pass]
|
41
|
+
config.mention_name = Config[:hipchat_nick]
|
42
|
+
config.nick = Config[:hipchat_name]
|
43
|
+
config.rooms = Config[:hipchat_rooms]
|
49
44
|
Robut::Storage::YamlStore.file = ".robut_store"
|
50
45
|
config.store = Robut::Storage::YamlStore
|
51
46
|
config.logger = Logger.new(STDOUT)
|
52
47
|
|
53
48
|
config.nick_db = Daybreak::DB.new '.nick.db', default: []
|
54
49
|
|
55
|
-
config.hipchat = HipChat::Client.new
|
50
|
+
config.hipchat = HipChat::Client.new Config[:hipchat_api_key]
|
56
51
|
|
57
52
|
config.hipchat_rooms = []
|
58
53
|
hipchat_rooms = config.hipchat.rooms
|
59
54
|
|
60
55
|
raise 'No rooms!' if hipchat_rooms.length.zero?
|
61
56
|
|
57
|
+
short_room_names = Config[:hipchat_rooms].dup
|
58
|
+
|
62
59
|
hipchat_rooms.each_with_index do |r, i|
|
63
60
|
next unless short_room_names.include? r.xmpp_jid
|
64
61
|
puts 'room_name: %s, room: %s' % [
|
@@ -72,9 +69,9 @@ Robut::Connection.configure do |config|
|
|
72
69
|
short_room_names.delete r.xmpp_jid
|
73
70
|
sleep 3 # So we don't blow the API rate limit
|
74
71
|
end
|
75
|
-
end
|
76
72
|
|
77
|
-
raise short_room_names.inspect unless short_room_names.empty?
|
73
|
+
raise short_room_names.inspect unless short_room_names.empty?
|
74
|
+
end
|
78
75
|
|
79
76
|
|
80
77
|
Robut::Plugin.plugins = [
|
@@ -67,8 +67,9 @@ private
|
|
67
67
|
|
68
68
|
|
69
69
|
tos.each do |to|
|
70
|
+
rooms = db[to]
|
70
71
|
|
71
|
-
|
72
|
+
rooms.each do |name|
|
72
73
|
rroom, hroom = nil, nil
|
73
74
|
|
74
75
|
if name =~ /^@/
|
@@ -93,7 +94,7 @@ private
|
|
93
94
|
end
|
94
95
|
end
|
95
96
|
|
96
|
-
reply "Notified #{to_sentence
|
97
|
+
reply "Notified #{to_sentence rooms}." unless rooms.empty?
|
97
98
|
end
|
98
99
|
end
|
99
100
|
|