A golang package to communicate with HipChat over XMPP

Overview

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 := "[email protected]"
	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 {}
}
Comments
  • Add a channel for unsupported xmpp event types

    Add a channel for unsupported xmpp event types

    In the process of troubleshooting issues with dying connections I made the change for configurable KeepAlives. When that still didn't solve the problem, I added a new channel for unhandled events as well as changing the way keep alives are done to use the documented mechanism for pings here:

    https://ecosystem.atlassian.net/wiki/display/HCDEV/HipChat+XMPP+Protocol+Documentation#HipChatXMPPProtocolDocumentation-Pings (the XEP-0198 implementation)

    Instead of creating a specific channel for acks, I just used the new channel so my upstream application could handle them.

    opened by lusis 4
  • Support HipChat 2.0.0 build 2.0.7

    Support HipChat 2.0.0 build 2.0.7

    It seems that the XMPP interface at port 5222/5223 will be closed with newer HipChat server versions. Is der any idea how to support this change?

    https://confluence.atlassian.com/hc/hipchat-server-release-notes-608731400.html

    opened by eloo 3
  • Allow configuration of client domain for Hipchat Server

    Allow configuration of client domain for Hipchat Server

    Quick PR to fix #20

    There are probably more elegant ways to fix this, like having a more generic 'xmppDomain' parameter to NewClientWithServerInfo() with a default of 'hipchat.com' and then defining clientDomain like

    "chat." + xmppDomain

    and mucDomain like

    "conf." + xmppDomain

    Let me know what you think.

    opened by hrak 3
  • Cannot filter out old messages when joining a room

    Cannot filter out old messages when joining a room

    Upon joining a room, HipChat sends a dump of the room's recent history, which I want to filter out. This library does not expose any timestamp data (which I assume hipchat provides for these history messages). And I can't seem to connect as a bot by joining rooms with a JID of "bot" as per this support page.

    opened by tune-george 3
  • Certificate issue

    Certificate issue

    Hi, i'm trying to use your library to connect to a self hosted hipchat instance and facing a problem with the TLS connection. I'm everytime getting the following error: client error: x509: certificate has expired or is not yet valid So it seems that the certificate is expired but I want to connect anyway. So how can I disable the Cert verify? Thanks

    opened by eloo 2
  • implement PrivSay to send private messages

    implement PrivSay to send private messages

    Private messages are 1-1 messages between two parties, using an XMPP type of 'chat'. In order to retain full backwards compatibility, this commit adds the new function 'PrivSay' rather than changing the 'Say' function to require an additional flag.

    opened by jschauma 2
  • Receiving unsolicited xmpp.NsDisco or xmpp.NsIqRoster will block listen function

    Receiving unsolicited xmpp.NsDisco or xmpp.NsIqRoster will block listen function

    This problem can be reproduced by connecting to hipchat and changing the name of a user.

    The receivedRooms and receivedUsers channels are unbuffered, so sending data to this channel will block until something receives from this channel. The only time these channels are received from are in the Users() and Rooms() methods.

    However, these messages generate a request so would still leave the listen thread blocked. We exposed the channels and used a goroutine similar to this to avoid the endless block. Note: Rooms() and Users() in this example just return the channels and don't make requests (the same as Messages()).

    go func() {
        for {
            select {
            case message := <-client.Messages():
                log.Printf("Received message: %v", message)
            case rooms := <-client.Rooms():
                log.Printf("Received rooms: %v", rooms)
            case users := <-client.Users():
                log.Printf("Received users: %v", users)
            }
        }
    }()
    

    Obviously there still needs to be work done to communicate received rooms and users to other goroutines, but this is one way to avoid the problem.

    opened by fedyakin 2
  • Timeout after nickname change

    Timeout after nickname change

    While in the reply example you are listening to the incoming messages and someone changes his nickname via the web interface the connection will time out and the bot will shortly disconnect.

    It only happens in this scenario.

    opened by gvisniuc 2
  • XML escape password string

    XML escape password string

    Passwords containing Predefined XML entities should be escaped when used during auth.

    Before

    <iq type='set' id='1234567890'><query xmlns='jabber:iq:auth'><username>12345_67890</username><password>Foob&R</password><resource>bot</resource></query></iq>
    client error: read: connection reset by peer
    

    After

    <iq type='set' id='1234567890'><query xmlns='jabber:iq:auth'><username>12345_67890</username><password>Foob&amp;R</password><resource>bot</resource></query></iq>
    
    opened by dacamp 1
  • Update channel handling to be non-blocking

    Update channel handling to be non-blocking

    This is a PR to fix the issue discussed in #8. We've been using the code with these changes for a couple weeks now and none of our bots are hanging like they used to.

    I also updated the examples to be use the channels instead, as @fedyakin shows in the above issue, a normal structure would probably look something like this:

    go func() {
        for {
            select {
            case message := <-client.Messages():
                log.Printf("Received message: %v", message)
            case rooms := <-client.Rooms():
                log.Printf("Received rooms: %v", rooms)
            case users := <-client.Users():
                log.Printf("Received users: %v", users)
            }
        }
    }()
    

    Let me know if you have any question.

    opened by cjhubert 1
  • Ability to receive and send private messages

    Ability to receive and send private messages

    This adds the ability to receive and send private messages.

    Received private messages are added onto the Messages channel, so the user implementing it will need to parse the message.From themselves to check whether it was from a room or from a user.

    When sending a message, it will check if the to address contains the text @chat.hipchat.com. This means that we're sending it to a user instead of a room (which would be @conf.hipchat.com), and changes the message type of the xml accordingly.

    opened by cjhubert 1
  • Add function for keep alive with arbitrary duration

    Add function for keep alive with arbitrary duration

    Hello,

    Duration of KeepAlive() is hard-coded so we cannot change that. Accordingly, I added a new function KeepAliveBy(sec time.Duration) to configure duration.

    Related: #12

    opened by moznion 1
Owner
Dane Harrigan
@hashicorp. Previously @heroku.
Dane Harrigan
Elastos.ELA.Rosetta.API - How to write a Rosetta server and use either the Client package or Fetcher package to communicate

Examples This folder demonstrates how to write a Rosetta server and how to use e

Elastos Foundation 3 Jan 17, 2022
GoStorm is a Go library that implements the communications protocol required to write Storm spouts and Bolts in Go that communicate with the Storm shells.

gostorm godocs GoStorm is a Go library that implements the communications protocol required for non-Java languages to communicate as part of a storm t

John Gilmore 129 Sep 27, 2022
Plot your repository stars over time.

Plot your repository stars over time.

Carlos Alexandro Becker 947 Dec 30, 2022
Simple program that uploads large files to Amazon S3 over slow connections.

shrimp is a small program that can reliably upload large files to Amazon S3. My personal use case is to upload large files to S3 over a slow residenti

Stefan Sundin 6 Nov 30, 2022
Command line interface to windows clipboard over KiTTY remote-control printing

kclip Command line interface to windows clipboard over KiTTY remote-control printing About This tool behaves like the cat command, it just tries to pa

Jacob Alberty 0 Dec 12, 2021
Pokemon Unite scoreboard HUD and extra tools running over captured game feeds using the OpenCV video processing API and Client/Server architecture.

unite Pokemon Unite scoreboard HUD and extra tools running over captured game feeds using the OpenCV video processing API. Client (OBS Live) Server Ar

pidgy 6 Dec 5, 2022
Go package providing opinionated tools and methods for working with the `aws-sdk-go/service/cloudfront` package.

go-aws-cloudfront Go package providing opinionated tools and methods for working with the aws-sdk-go/service/cloudfront package. Documentation Tools $

aaronland 0 Feb 2, 2022
A package for access aws service using AWS SDK for Golang

goaws ?? A package for access aws service using AWS SDK for Golang Advantage with goaws package Example for get user list IAM with AWS SDK for Golang

Muhammad Ichsanul Fadhil 1 Nov 25, 2021
Package anko provides a golang SDK to the Anko Investor Forecasts gRPC service.

github.com/anglo-korean/anko-go-sdk Package anko provides a golang SDK to the Anko Investor Forecasts gRPC service. import "github.com/anglo-korean/an

Anglo Korean 0 Jan 3, 2022
An unofficial package in Golang to help developers implement ZATCA (Fatoora) QR code easily.

Zatca SDK GO An unofficial package in Golang to help developers to implement ZATCA (Fatoora) QR code easily which required for e-invoicing ✅ The hash

null 16 Jan 1, 2023
A simple package in Golang containing helpers for functional programming

go-functools Golang package containing functools using Go generics functools is

Shaurya Agarwal 2 Nov 3, 2022
Go / Golang package to return a random boolean true or false

github.com/mitchallen/coin Usage Initialize your module $ go mod init example.com/my-demo Get the module Note that you need to include the v in the v

Mitch Allen 0 Jan 15, 2022
advancedsearch is a package to help peoples make search while typing "char" by "char" in Golang.

advancedsearch is a package to help peoples make search while typing "char" by "char" in Golang. Actually he has two main functions, CompareSingleWord and CompareMultipleWords.

Aristoteles Lopes 3 Feb 2, 2022
Package githubv4 is a client library for accessing GitHub GraphQL API v4 (https://developer.github.com/v4/).

githubv4 Package githubv4 is a client library for accessing GitHub GraphQL API v4 (https://docs.github.com/en/graphql). If you're looking for a client

null 956 Dec 26, 2022
A simple Go package to fetch lyrics from Wikia

golyrics This is a simple scrapper package to fetch lyrics data from the Wikia website. Installation go get github.com/mamal72/golyrics Usage package

Mohamad Jahani 40 Dec 24, 2022
Go online translation package

Translate Go online translation package Install go get github.com/nuveo/translate Available Translator API's Microsoft or send us the next Translator

nuveo 33 Nov 27, 2022
Utilcanvas is a package which provides some utilities to interface with the Canvas LMS Api.

Utilcanvas Utilcanvas is a package which provides some utilities to interface with the Canvas LMS Api. Example usage c := utilcanvas.NewClient("https:

Martín Zamorano 1 Dec 21, 2022
Package captcha is a middleware that provides captcha service for Flamego

auth Package captcha is a middleware that provides captcha service for Flamego. Installation The minimum requirement of Go is 1.16. go get github.com/

Flamego 13 Dec 14, 2022
Metrics package helps to create ydb-go-sdk traces with monitoring internal state of driver

metrics metrics package helps to create ydb-go-sdk traces with monitoring internal state of driver Usage import ( "fmt" "sync/mutex" "time

YDB Platform 3 Jan 7, 2023