Documentation ¶
Overview ¶
Package gitter is a Go client library for the Gitter API.
Author: sromku
Index ¶
- type APIError
- type Event
- type Faye
- type Gitter
- func (gitter *Gitter) Faye(roomID string) *Faye
- func (gitter *Gitter) GetMessage(roomID, messageID string) (*Message, error)
- func (gitter *Gitter) GetMessages(roomID string, params *Pagination) ([]Message, error)
- func (gitter *Gitter) GetRoom(roomID string) (*Room, error)
- func (gitter *Gitter) GetRoomId(uri string) (string, error)
- func (gitter *Gitter) GetRooms() ([]Room, error)
- func (gitter *Gitter) GetUser() (*User, error)
- func (gitter *Gitter) GetUserRooms(userID string) ([]Room, error)
- func (gitter *Gitter) GetUsersInRoom(roomID string) ([]User, error)
- func (gitter *Gitter) JoinRoom(roomID, userID string) (*Room, error)
- func (gitter *Gitter) LeaveRoom(roomID, userID string) error
- func (gitter *Gitter) Listen(stream *Stream)
- func (gitter *Gitter) SearchRooms(room string) ([]Room, error)
- func (gitter *Gitter) SendMessage(roomID, text string) (*Message, error)
- func (gitter *Gitter) SetClient(client *http.Client)
- func (gitter *Gitter) SetDebug(debug bool, logWriter io.Writer)
- func (gitter *Gitter) Stream(roomID string) *Stream
- func (gitter *Gitter) UpdateMessage(roomID, msgID, text string) (*Message, error)
- type GitterConnectionClosed
- type Issue
- type Mention
- type Message
- type MessageReceived
- type Pagination
- type Room
- type Stream
- type URL
- type User
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type APIError ¶
type APIError struct {
What string
}
APIError holds data of errors returned from the API.
type Gitter ¶
type Gitter struct {
// contains filtered or unexported fields
}
func New ¶
New initializes the Gitter API client
For example:
api := gitter.New("YOUR_ACCESS_TOKEN")
func (*Gitter) GetMessage ¶
GetMessage returns a message in a room.
func (*Gitter) GetMessages ¶
func (gitter *Gitter) GetMessages(roomID string, params *Pagination) ([]Message, error)
GetMessages returns a list of messages in a room. Pagination is optional. You can pass nil or specific pagination params.
func (*Gitter) GetUserRooms ¶
GetUserRooms returns a list of Rooms the user is part of
func (*Gitter) GetUsersInRoom ¶
GetUsersInRoom returns the users in the room with the passed id
func (*Gitter) Listen ¶
Implemented to conform with https://developer.gitter.im/docs/streaming-api
func (*Gitter) SearchRooms ¶
SearchRooms queries the Rooms resources of gitter API
func (*Gitter) SendMessage ¶
SendMessage sends a message to a room
type GitterConnectionClosed ¶
type GitterConnectionClosed struct { }
type Issue ¶
type Issue struct { // Issue number Number string `json:"number"` }
Issue references issue in the message
type Mention ¶
type Mention struct { // User's username ScreenName string `json:"screenName"` // Gitter User ID UserID string `json:"userID"` }
Mention holds data about mentioned user in the message
type Message ¶
type Message struct { // ID of the message ID string `json:"id"` // Original message in plain-text/markdown Text string `json:"text"` // HTML formatted message HTML string `json:"html"` // ISO formatted date of the message Sent time.Time `json:"sent"` // ISO formatted date of the message if edited EditedAt time.Time `json:"editedAt"` // User that sent the message From User `json:"fromUser"` // Boolean that indicates if the current user has read the message. Unread bool `json:"unread"` // Number of users that have read the message ReadBy int `json:"readBy"` // List of URLs present in the message Urls []URL `json:"urls"` // List of @Mentions in the message Mentions []Mention `json:"mentions"` // List of #Issues referenced in the message Issues []Issue `json:"issues"` // Version Version int `json:"v"` }
type MessageReceived ¶
type MessageReceived struct {
Message Message
}
type Pagination ¶
type Pagination struct { // Skip n messages Skip int // Get messages before beforeId BeforeID string // Get messages after afterId AfterID string // Maximum number of messages to return Limit int // Search query Query string }
Pagination params
type Room ¶
type Room struct { // Room ID ID string `json:"id"` // Room name Name string `json:"name"` // Room topic. (default: GitHub repo description) Topic string `json:"topic"` // Room URI on Gitter URI string `json:"uri"` // Indicates if the room is a one-to-one chat OneToOne bool `json:"oneToOne"` // Count of users in the room UserCount int `json:"userCount"` // Number of unread messages for the current user UnreadItems int `json:"unreadItems"` // Number of unread mentions for the current user Mentions int `json:"mentions"` // Last time the current user accessed the room in ISO format LastAccessTime time.Time `json:"lastAccessTime"` // Indicates if the current user has disabled notifications Lurk bool `json:"lurk"` // Path to the room on gitter URL string `json:"url"` // Type of the room // - ORG: A room that represents a GitHub Organization. // - REPO: A room that represents a GitHub Repository. // - ONETOONE: A one-to-one chat. // - ORG_CHANNEL: A Gitter channel nested under a GitHub Organization. // - REPO_CHANNEL A Gitter channel nested under a GitHub Repository. // - USER_CHANNEL A Gitter channel nested under a GitHub User. GithubType string `json:"githubType"` // Tags that define the room Tags []string `json:"tags"` RoomMember bool `json:"roomMember"` // Room version. Version int `json:"v"` }
A Room in Gitter can represent a GitHub Organization, a GitHub Repository, a Gitter Channel or a One-to-one conversation. In the case of the Organizations and Repositories, the access control policies are inherited from GitHub.
type Stream ¶
type Stream struct { Event chan Event // contains filtered or unexported fields }
Stream holds stream data.
type User ¶
type User struct { // Gitter User ID ID string `json:"id"` // Gitter/GitHub username Username string `json:"username"` // Gitter/GitHub user real name DisplayName string `json:"displayName"` // Path to the user on Gitter URL string `json:"url"` // User avatar URI (small) AvatarURLSmall string `json:"avatarUrlSmall"` // User avatar URI (medium) AvatarURLMedium string `json:"avatarUrlMedium"` }