lita-hcadmin 0.3.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +20 -0
- data/.rspec +2 -0
- data/.rubocop.yml +28 -0
- data/.travis.yml +16 -0
- data/CHANGELOG.md +41 -0
- data/Gemfile +10 -0
- data/LICENSE.md +21 -0
- data/README.md +163 -0
- data/Rakefile +26 -0
- data/lib/lita/handlers/hcadmin.rb +441 -0
- data/lib/lita-hcadmin.rb +13 -0
- data/lita-hcadmin.gemspec +25 -0
- data/locales/en.yml +4 -0
- data/spec/fixtures/bad_gateway.txt +1 -0
- data/spec/fixtures/room_data.json +40 -0
- data/spec/fixtures/room_v2_data.json +45 -0
- data/spec/fixtures/stats.json +6 -0
- data/spec/fixtures/status.json +3 -0
- data/spec/fixtures/user_data.json +17 -0
- data/spec/fixtures/user_v2_data.json +39 -0
- data/spec/fixtures/user_v2_notreal_email.json +7 -0
- data/spec/fixtures/users_data.json +49 -0
- data/spec/fixtures/v2_room_not_found.json +7 -0
- data/spec/fixtures/v2_user_data.json +41 -0
- data/spec/fixtures/v2_user_not_found.json +7 -0
- data/spec/lita/handlers/hcadmin_spec.rb +561 -0
- data/spec/spec_helper.rb +17 -0
- data/templates/.gitkeep +0 -0
- metadata +186 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: dbb668a3f1776c2b498ad15764a56d7f1b309347
|
4
|
+
data.tar.gz: 27af7e8a66abb2e65e4ba40c38ab87688c28331a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 7b888e6b7888f5d3412797d9cd28a33d293beb350861c9ec7b2eb72647ca5fc4ea918b05a99bb96b99c254033ef5f331bf5670346a810e0af543e3b3224fe27e
|
7
|
+
data.tar.gz: 57975f9f90f363f2f24ddee9ababc163da5f785ee6b0280298c18a3b8efbb47087a93f40a695cbf6be0c384dda39b4feff423c7eb3220a921a0c60b4b78f91ed
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
AlignParameters:
|
2
|
+
Enabled: false
|
3
|
+
|
4
|
+
Encoding:
|
5
|
+
Enabled: false
|
6
|
+
|
7
|
+
LineLength:
|
8
|
+
Max: 240
|
9
|
+
|
10
|
+
Documentation:
|
11
|
+
Enabled: false
|
12
|
+
|
13
|
+
ClassLength:
|
14
|
+
Max: 400
|
15
|
+
|
16
|
+
AbcSize:
|
17
|
+
Max: 60
|
18
|
+
|
19
|
+
MethodLength:
|
20
|
+
Max: 30
|
21
|
+
|
22
|
+
GuardCause:
|
23
|
+
Enabled: false
|
24
|
+
|
25
|
+
AllCops:
|
26
|
+
Exclude:
|
27
|
+
- 'Rakefile'
|
28
|
+
- 'lita-hcadmin.gemspec'
|
data/.travis.yml
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
language: ruby
|
2
|
+
rvm:
|
3
|
+
- 2.0
|
4
|
+
sudo: false
|
5
|
+
addons:
|
6
|
+
apt:
|
7
|
+
sources:
|
8
|
+
- chef-current-precise
|
9
|
+
packages:
|
10
|
+
- chefdk
|
11
|
+
|
12
|
+
before_script:
|
13
|
+
- eval "$(/opt/chefdk/bin/chef shell-init bash)"
|
14
|
+
script:
|
15
|
+
- /opt/chefdk/embedded/bin/bundle install
|
16
|
+
- /opt/chefdk/embedded/bin/bundle exec rake
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
# lita-hcadmin
|
2
|
+
|
3
|
+
[0.3.3]
|
4
|
+
---------
|
5
|
+
- [desktophero] - Fix unarchive logic for multi-word names
|
6
|
+
|
7
|
+
[0.3.2]
|
8
|
+
---------
|
9
|
+
- [desktophero] - Fix unarchive logic for unfound rooms
|
10
|
+
|
11
|
+
[0.3.1]
|
12
|
+
---------
|
13
|
+
- [desktophero] - Unarchive room as a room change admin
|
14
|
+
|
15
|
+
[0.2.19]
|
16
|
+
---------
|
17
|
+
- [desktophero] - Allow an existing user to send an invite request to admins (hipchat sponsor <email>)
|
18
|
+
|
19
|
+
[0.2.1]
|
20
|
+
---------
|
21
|
+
- [desktophero] - Room Count request method update
|
22
|
+
|
23
|
+
[0.2.0]
|
24
|
+
---------
|
25
|
+
- [desktophero] - Switch HTTP Client to Faraday; response includes HTTP response and body for HipChatAPI commands
|
26
|
+
|
27
|
+
[0.1.15]
|
28
|
+
---------
|
29
|
+
- [desktophero] - Added time to respond to room owner request; updated help return text
|
30
|
+
|
31
|
+
[0.1.15]
|
32
|
+
---------
|
33
|
+
- [desktophero] - Added time to respond to more functions; update to README
|
34
|
+
|
35
|
+
[0.1.13]
|
36
|
+
---------
|
37
|
+
- [desktophero] - Identify hipchat status
|
38
|
+
|
39
|
+
[0.1.0]
|
40
|
+
---------
|
41
|
+
- [desktophero] - Initial cookbook
|
data/Gemfile
ADDED
data/LICENSE.md
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016, Target Corporation
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,163 @@
|
|
1
|
+
# lita-hcadmin
|
2
|
+
|
3
|
+
[![Build Status](https://travis-ci.org/target/lita-hipchat-admin.svg?branch=master)](https://travis-ci.org/target/lita-hipchat-admin)
|
4
|
+
|
5
|
+
## Why?
|
6
|
+
This handler for Lita (https://www.lita.io/) extends the Lita HipChat adapter (https://github.com/litaio/lita-hipchat)
|
7
|
+
and focuses on allowing admin type commands and visibility into the HipChat account. See commands below.
|
8
|
+
|
9
|
+
## Installation
|
10
|
+
|
11
|
+
Add lita-hcadmin to your Lita instance's Gemfile:
|
12
|
+
|
13
|
+
``` ruby
|
14
|
+
gem "lita-hcadmin"
|
15
|
+
```
|
16
|
+
|
17
|
+
## Setup
|
18
|
+
Only validated with Lita v4.4 and newer.
|
19
|
+
Only validated with HipChat SaaS.
|
20
|
+
|
21
|
+
## Configuration
|
22
|
+
|
23
|
+
```ruby
|
24
|
+
Lita.configure do |config|
|
25
|
+
config.handlers.hcadmin.v1_notify_token = '<v1_notification_token>' # for using HipChat API V1 notification scopes; required
|
26
|
+
config.handlers.hcadmin.v1_admin_token = '<v1_admin_token>' # for using HipChat API V1 administration scopes; required
|
27
|
+
config.handlers.hcadmin.v2_admin_token = '<v2_admin_token>' # for using HipChat API V2 administration scopes; required
|
28
|
+
config.handlers.hcadmin.http_proxy = "<some_company_proxy>" # if a proxy is used; optional
|
29
|
+
config.handlers.hcadmin.email_dist_list = "user@company.com" # valid email address to send sponsor requests
|
30
|
+
config.handlers.hcadmin.smtp_server = "smtp.company.com" # to specify the smtp server for emails
|
31
|
+
config.handlers.hcadmin.room_change_admins = ["hipchat", "user", "array", "of", "menionnames"] #
|
32
|
+
config.handlers.hcadmin.hipchat_account_name = "<name of account>"
|
33
|
+
end
|
34
|
+
```
|
35
|
+
|
36
|
+
|
37
|
+
## Usage
|
38
|
+
|
39
|
+
Help output:
|
40
|
+
```
|
41
|
+
identify room owner ROOM_NAME - Returns the mention name of the room owner.
|
42
|
+
identify hipchat admins - Returns the mention name of the HipChat Admins.
|
43
|
+
identify user count - Returns the count of users in <account_name>.
|
44
|
+
identify room count - Returns the count of rooms in <account_name>.
|
45
|
+
identify room change admins - Returns a list of who can change room ownership
|
46
|
+
identify status - Returns the status of HipChat.
|
47
|
+
hipchat sponsor EMAIL ADDRESS - Generates an invite to the person being sponsoered. Use a valid Target.com email address
|
48
|
+
```
|
49
|
+
|
50
|
+
|
51
|
+
### identify room owner
|
52
|
+
```
|
53
|
+
identify room owner foobar
|
54
|
+
bot: Getting rooms ... one moment
|
55
|
+
Getting room id ... another moment
|
56
|
+
Getting the user name from the user ID ... almost there
|
57
|
+
```
|
58
|
+
Either a room owner is identified:
|
59
|
+
```
|
60
|
+
The owner of foobar is MentionName
|
61
|
+
```
|
62
|
+
or, the bot responds with details
|
63
|
+
```
|
64
|
+
Room foobar apparently does not have an owner or I could not find a room with that name ( 8 s. to respond )
|
65
|
+
```
|
66
|
+
|
67
|
+
|
68
|
+
### identify hipchat Admins
|
69
|
+
```
|
70
|
+
identify hipchat admins
|
71
|
+
bot: Admin search takes a moment ...
|
72
|
+
|
73
|
+
bot: MentionName1
|
74
|
+
MentionName2
|
75
|
+
MentionName3
|
76
|
+
MentionName4
|
77
|
+
```
|
78
|
+
#### data above is sample information
|
79
|
+
|
80
|
+
### identify room count
|
81
|
+
```
|
82
|
+
identify room count
|
83
|
+
bot: Rooms in hipchat: 2213 ( 2 s. to respond )
|
84
|
+
```
|
85
|
+
#### data above is sample information
|
86
|
+
|
87
|
+
### identify user count
|
88
|
+
```
|
89
|
+
identify user count
|
90
|
+
bot: Users in hipchat: 4971 ( 15 s. to respond )
|
91
|
+
```
|
92
|
+
#### data above is sample information
|
93
|
+
|
94
|
+
### identify status
|
95
|
+
```
|
96
|
+
identify status
|
97
|
+
bot: Status of hipchat: Code: 200 => {"status": "okay"} ( 0 s. to respond )
|
98
|
+
```
|
99
|
+
-- data above is sample information
|
100
|
+
|
101
|
+
### hipchat sponsor <EMAIL_ADDRESS>
|
102
|
+
```
|
103
|
+
hipchat sponsor <email_account@company.com>
|
104
|
+
The email address of email_account@company.com was not found. Generating request to admins
|
105
|
+
Admins have been notified of your request to add email_account@company.com, @requestor_name
|
106
|
+
Message to admins sent
|
107
|
+
```
|
108
|
+
|
109
|
+
This generates an email to the address defined in `Lita.config.handlers.hcadmin.email_dist_list`
|
110
|
+
|
111
|
+
### identify room change admins
|
112
|
+
```
|
113
|
+
identify room change admins
|
114
|
+
bot: Users who can change room ownership
|
115
|
+
MentionName1
|
116
|
+
MentionName2
|
117
|
+
```
|
118
|
+
|
119
|
+
The list of names is defined in `Lita.config.handlers.hcadmin.room_change_admins` as an array of MentionNames
|
120
|
+
|
121
|
+
### room owner change NewOwnerMentionName RoomName
|
122
|
+
```
|
123
|
+
room owner change NewOwner RoomName
|
124
|
+
bot: Room update request sent. HTTP response code: 204
|
125
|
+
```
|
126
|
+
|
127
|
+
If the user can't be found
|
128
|
+
```
|
129
|
+
room owner change FakeName RoomName
|
130
|
+
bot: Uh-oh, 404 returned! The user FakeName not found
|
131
|
+
```
|
132
|
+
|
133
|
+
If the room can't be found
|
134
|
+
```
|
135
|
+
room owner change RealName FakeRoom
|
136
|
+
bot: Uh-oh, 404 returned! The room FakeRoom not found
|
137
|
+
```
|
138
|
+
|
139
|
+
### room unarchive RoomName
|
140
|
+
```
|
141
|
+
room unarchive RoomName
|
142
|
+
bot: Room update request sent. HTTP response code: 204
|
143
|
+
```
|
144
|
+
|
145
|
+
If the room can't be found
|
146
|
+
```
|
147
|
+
room owner change RealName FakeRoom
|
148
|
+
bot: Uh-oh, 404 returned! The room FakeRoom not found
|
149
|
+
```
|
150
|
+
|
151
|
+
|
152
|
+
## TO-DOs
|
153
|
+
The Issues for this repo will be used to accept, collaborate, and complete `TO-DOs`
|
154
|
+
|
155
|
+
## License and Author
|
156
|
+
|
157
|
+
Author:: Jason Walker (<jason.walker@target.com> , [desktophero])
|
158
|
+
|
159
|
+
```text
|
160
|
+
Copyright:: 2016, Target Corporation
|
161
|
+
|
162
|
+
See License for details
|
163
|
+
```
|
data/Rakefile
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'bundler/gem_tasks'
|
2
|
+
require 'rspec/core/rake_task'
|
3
|
+
require 'rubocop/rake_task'
|
4
|
+
|
5
|
+
task default: :ci_checks
|
6
|
+
|
7
|
+
RSpec::Core::RakeTask.new(:spec)
|
8
|
+
|
9
|
+
desc 'Run all style tests'
|
10
|
+
|
11
|
+
namespace :style do
|
12
|
+
desc 'Test ruby style against guidelines from rubocop'
|
13
|
+
task :rubocop do
|
14
|
+
RuboCop::RakeTask.new
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
task :style do
|
19
|
+
Rake.application.in_namespace(:style) { |x| x.tasks.each { |t| t.invoke } }
|
20
|
+
end
|
21
|
+
|
22
|
+
task :ci_checks do
|
23
|
+
# Rake::Task['style'].invoke
|
24
|
+
Rake::Task['spec'].invoke
|
25
|
+
Rake::Task['style'].invoke
|
26
|
+
end
|