hipchat

package module
v0.0.0-...-835dc87 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 12, 2017 License: BSD-3-Clause Imports: 5 Imported by: 19

README

hipchat

This is a abstraction in golang to Hipchat's implementation of XMPP. It communicates over TLS and requires zero knowledge of XML or the XMPP protocol.

bot building

Hipchat treats the "bot" resource differently from any other resource connected to their service. When connecting to Hipchat with a resource of "bot", a chat history will not be sent. Any other resource will receive a chat history.

example/hello.go
package main

import (
	"github.com/daneharrigan/hipchat"
)

func main() {
	user := "11111_22222"
	pass := "secret"
	resource := "bot"
	roomJid := "11111_room_name@conf.hipchat.com"
	fullName := "Some Bot"

	client, err := hipchat.NewClient(user, pass, resource)
	if err != nil {
		fmt.Printf("client error: %s\n", err)
		return
	}

	client.Status("chat")
	client.Join(roomJid, fullName)
	client.Say(roomJid, fullName, "Hello")
	select {}
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	AuthType string
	Username string
	Password string
	Resource string
	Id       string
	// contains filtered or unexported fields
}

A Client represents the connection between the application to the HipChat service.

func NewClient

func NewClient(user, pass, resource, authType string) (*Client, error)

NewClient creates a new Client connection from the user name, password and resource passed to it. It uses default host URL and conf URL.

func NewClientWithServerInfo

func NewClientWithServerInfo(user, pass, resource, authType, host, domain, conf string) (*Client, error)

NewClientWithServerInfo creates a new Client connection from the user name, password, resource, host URL and conf URL passed to it.

func (*Client) Join

func (c *Client) Join(roomId, resource string)

Join accepts the room id and the name used to display the client in the room.

func (*Client) KeepAlive

func (c *Client) KeepAlive()

KeepAlive is meant to run as a goroutine. It sends a single whitespace character to HipChat every 60 seconds. This keeps the connection from idling after 150 seconds.

func (*Client) Messages

func (c *Client) Messages() <-chan *Message

Messages returns a read-only channel of Message structs. After joining a room, messages will be sent on the channel.

func (*Client) Part

func (c *Client) Part(roomId, name string)

Part accepts the room id to part.

func (*Client) PrivSay

func (c *Client) PrivSay(user, name, body string)

PrivSay accepts a client id, the name of the client, and the message body and sends the private message to the HipChat user.

func (*Client) RequestRooms

func (c *Client) RequestRooms()

RequestRooms will send an outgoing request to get the room information for all rooms

func (*Client) RequestUsers

func (c *Client) RequestUsers()

RequestUsers will send an outgoing request to get the user information for all users

func (*Client) Rooms

func (c *Client) Rooms() <-chan []*Room

Rooms returns a channel of Room slices

func (*Client) Say

func (c *Client) Say(roomId, name, body string)

Say accepts a room id, the name of the client in the room, and the message body and sends the message to the HipChat room.

func (*Client) Status

func (c *Client) Status(s string)

Status sends a string to HipChat to indicate whether the client is available to chat, away or idle.

func (*Client) Users

func (c *Client) Users() <-chan []*User

Users returns a channel of User slices

type Message

type Message struct {
	From        string
	To          string
	Body        string
	MentionName string
}

A Message represents a message received from HipChat.

type Room

type Room struct {
	Id              string
	LastActive      string
	Name            string
	NumParticipants string
	Owner           string
	Privacy         string
	RoomId          string
	Topic           string
}

A Room represents a room in HipChat the Client can join to communicate with other members..

type User

type User struct {
	Email       string
	Id          string
	Name        string
	MentionName string
}

A User represents a member of the HipChat service.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL