lita-hcadmin

Build Status

Why?

This handler for Lita (https://www.lita.io/) extends the Lita HipChat adapter (https://github.com/litaio/lita-hipchat) and focuses on allowing admin type commands and visibility into the HipChat account. See commands below.

Installation

Add lita-hcadmin to your Lita instance's Gemfile:

gem "lita-hcadmin"

Setup

Only validated with Lita v4.4 and newer. Only validated with HipChat SaaS.

Configuration

Lita.configure do |config|
  config.handlers.hcadmin.v1_notify_token = '<v1_notification_token>' # for using HipChat API V1 notification scopes; required
  config.handlers.hcadmin.v1_admin_token = '<v1_admin_token>' # for using HipChat API V1 administration scopes; required
  config.handlers.hcadmin.v2_admin_token = '<v2_admin_token>' # for using HipChat API V2 administration scopes; required
  config.handlers.hcadmin.http_proxy = "<some_company_proxy>" # if a proxy is used; optional
  config.handlers.hcadmin.email_dist_list = "[email protected]" # valid email address to send sponsor requests
  config.handlers.hcadmin.smtp_server = "smtp.company.com" # to specify the smtp server for emails
  config.handlers.hcadmin.room_change_admins = ["hipchat", "user", "array", "of", "menionnames"] #
  config.handlers.hcadmin. = "<name of account>"
end

Usage

Help output:

identify room owner ROOM_NAME - Returns the mention name of the room owner.
identify hipchat admins - Returns the mention name of the HipChat Admins.
identify user count - Returns the count of users in <account_name>.
identify room count - Returns the count of rooms in <account_name>.
identify room change admins - Returns a list of who can change room ownership
identify status - Returns the status of HipChat.
hipchat sponsor EMAIL ADDRESS - Generates an invite to the person being sponsoered. Use a valid Target.com email address

identify room owner

identify room owner foobar
bot: Getting rooms ... one moment
Getting room id ... another moment
Getting the user name from the user ID ... almost there

Either a room owner is identified:

The owner of foobar is MentionName

or, the bot responds with details

Room foobar apparently does not have an owner or I could not find a room with that name ( 8 s. to respond )

identify hipchat Admins

identify hipchat admins
bot: Admin search takes a moment ...

bot: MentionName1
MentionName2
MentionName3
MentionName4

data above is sample information

identify room count

identify room count
bot: Rooms in hipchat: 2213 ( 2 s. to respond )

data above is sample information

identify user count

identify user count
bot: Users in hipchat: 4971 ( 15 s. to respond )

data above is sample information

identify status

identify status
bot: Status of hipchat: Code: 200 => {"status": "okay"} ( 0 s. to respond )

-- data above is sample information

hipchat sponsor

hipchat sponsor <[email protected]>
The email address of [email protected] was not found. Generating request to admins
Admins have been notified of your request to add [email protected], @requestor_name
Message to admins sent

This generates an email to the address defined in Lita.config.handlers.hcadmin.email_dist_list

identify room change admins

identify room change admins
bot: Users who can change room ownership
MentionName1
MentionName2

The list of names is defined in Lita.config.handlers.hcadmin.room_change_admins as an array of MentionNames

room owner change NewOwnerMentionName RoomName

room owner change NewOwner RoomName
bot: Room update request sent. HTTP response code: 204

If the user can't be found

room owner change FakeName RoomName
bot: Uh-oh, 404 returned! The user FakeName not found

If the room can't be found

room owner change RealName FakeRoom
bot: Uh-oh, 404 returned! The room FakeRoom not found

room unarchive RoomName

room unarchive RoomName
bot: Room update request sent. HTTP response code: 204

If the room can't be found

room owner change RealName FakeRoom
bot: Uh-oh, 404 returned! The room FakeRoom not found

identify user change admins

identify user change admins
bot: Users who can change user details
MentionName1
MentionName2

The list of names is defined in Lita.config.handlers.hcadmin.user_change_admins as an array of MentionNames

user activate

user activate <[email protected]>
bot: Added user with status code 201

A couple of checks:

user activate <bad_email@companyom>
bot: First value needs to be a valid email address
user activate <[email protected]>
bot: That email is already in use.

user invite

user invite <[email protected]>
bot: Invite sent to user with status code 200

A couple of checks:

user invite <bad_email@companyom>
bot: First value needs to be a valid email address
user invite <[email protected]>
bot: That email is already in use.

TO-DOs

The Issues for this repo will be used to accept, collaborate, and complete TO-DOs

License and Author

Author:: Jason Walker ([email protected] , [desktophero])

Copyright:: 2016, Target Corporation

See License for details