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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: aa7365251d2282f85ae122fd949d775aa5b869e0
4
- data.tar.gz: 9228b3a6ec8e9059e5a2810fb39ed2ad923b956b
3
+ metadata.gz: b5b85c01b693f3ac29dd57d3dff69bdbc261846c
4
+ data.tar.gz: 1edbb9bf2cb403e3940d5f5175f176f4ee54a551
5
5
  SHA512:
6
- metadata.gz: 87bb8722cc559d0a65fe474ea809084c4bbf9a4b1340c5909d438eb939f4f845504b63bfa05b3590ecd28e0694f40e9003922b8a9a47b7b77bd13c370f1af054
7
- data.tar.gz: b9025cd5e292784fa3ab784b5694a6293b69f72c6346bffbf95b7b760811102e93b015385ee1bc33f717425f23ec1b5332138e6c8aef5e8370f47da94fc08ee2
6
+ metadata.gz: 7750236883ff882f7c9d32eb55702bcc448d3ac2fa63cd417760c03e14a5e26900b29e877627fb4b02d2529ecdb48f9082d4532156c33bf8b6c629b5a13c481e
7
+ data.tar.gz: 77498fd591231cbc34c2a18d9f2dcffefe0fe0cc39188c0bbd883a9a8d25acd610058678876195ade2d340ef758475c7daf6965ca8e9320efe0cba5d6622eaec
data/.gitignore CHANGED
@@ -12,4 +12,5 @@
12
12
  .yardoc
13
13
  Gemfile.lock
14
14
  doc
15
- pkg
15
+ pkg
16
+ config.json
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.2
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 :jid, "Jabber ID", type: :string, required: true, short: 'j'
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
- short_room_names = Opts[:rooms].split(',')
41
-
36
+ Config = JSON::parse File::read(Opts[:config]), symbolize_names: true
42
37
 
43
38
  Robut::Connection.configure do |config|
44
- config.jid = Opts[:jid]
45
- config.password = Opts[:pass]
46
- config.mention_name = Opts[:nick]
47
- config.nick = Opts[:name]
48
- config.rooms = Opts[:rooms].split(',')
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 Opts[:api_key]
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
- db[to].each do |name|
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 db[to]}."
97
+ reply "Notified #{to_sentence rooms}." unless rooms.empty?
97
98
  end
98
99
  end
99
100
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: robit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sean Clemmer