groupme

package module
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2023 License: GPL-3.0 Imports: 17 Imported by: 0

README

Version 1.0 Release Date: TBD

I would like to add common helper functions/features inspired by the package use in the community. So please, especially before Version 1.0 release, let me know what you would like to see added to the package, but bear in mind the main objective to be a simple wrapper for the API exposed by the GroupMe team.


GroupMe API Wrapper

GitHub tag (latest SemVer) PkgGoDev

Description

The design of this package is meant to be super simple. Wrap the exposed API endpoints documented by the GroupMe team. While you can achieve the core of this package with cURL, there are some small added features, coupled along with a modern language, that should simplify writing GroupMe bots and applications.

[FUTURE] In addition to the Go package, there is also a CLI application built using this package; all the features are available from the command line.

Why?

I enjoy programming, I use GroupMe with friends, and I wanted to write a fun add-on application for our group. I happened to start using Go around this time, so it was good practice.

Example

package main

import (
	"fmt"

	"github.com/densestvoid/groupme"
)

// This is not a real token. Please find yours by logging
// into the GroupMe development website: https://dev.groupme.com/
const authorizationToken = "0123456789ABCDEF"

// A short program that gets the gets the first 5 groups
// the user is part of, and then the first 10 messages of
// the first group in that list
func main() {
	// Create a new client with your auth token
	client := groupme.NewClient(authorizationToken)

	// Get the groups your user is part of
	groups, err := client.IndexGroups(&groupme.GroupsQuery{
		Page:    0,
		PerPage: 5,
		Omit:    "memberships",
	})

	if err != nil {
		fmt.Println(err)
		return
	}

	fmt.Println(groups)

	// Get first 10 messages of the first group
	if len(groups) <= 0 {
		fmt.Println("No groups")
	}

	messages, err := client.IndexMessages(groups[0].ID, &groupme.IndexMessagesQuery{
		Limit: 10,
	})

	if err != nil {
		fmt.Println(err)
	}

	fmt.Println(messages)
}

Installation

Go Package

go get github.com/densestvoid/groupme

[FUTURE] CLI

Support

You can join the GroupMe support group (you will need to provide a reason for joining), or the Discord server.

Contribute

I find the hours I can spend developing personal projects decreasing every year, so I welcome any help I can get. Feel free to tackle any open issues, or if a feature request catches your eye, feel free to reach out to me and we can discuss adding it to the package. However, once version 1.0 is released, I don't foresee much work happening on this project unless the GroupMe API is updated.

Credits

All credits for the actual platform belong to the GroupMe team; I only used the exposed API they wrote.

License

GPL-3.0 License © DensestVoid

Documentation

Overview

Package groupme defines a client capable of executing API commands for the GroupMe chat service

Package groupme defines a client capable of executing API commands for the GroupMe chat service

Package groupme defines a client capable of executing API commands for the GroupMe chat service

Package groupme defines a client capable of executing API commands for the GroupMe chat service

Package groupme defines a client capable of executing API commands for the GroupMe chat service

Package groupme defines a client capable of executing API commands for the GroupMe chat service

Package groupme defines a client capable of executing API commands for the GroupMe chat service

Package groupme defines a client capable of executing API commands for the GroupMe chat service

Package groupme defines a client capable of executing API commands for the GroupMe chat service

Package groupme defines a client capable of executing API commands for the GroupMe chat service

Package groupme defines a client capable of executing API commands for the GroupMe chat service

Package groupme defines a client capable of executing API commands for the GroupMe chat service

Package groupme defines a client capable of executing API commands for the GroupMe chat service

Package groupme defines a client capable of executing API commands for the GroupMe chat service

Index

Constants

View Source
const (
	ChangeOwnerOk                changeOwnerStatusCode = "200"
	ChangeOwnerRequesterNewOwner changeOwnerStatusCode = "400"
	ChangeOwnerNotOwner          changeOwnerStatusCode = "403"
	ChangeOwnerBadGroupOrOwner   changeOwnerStatusCode = "404"
	ChangeOwnerBadRequest        changeOwnerStatusCode = "405"
)

Change owner Status Codes

View Source
const (
	SenderTypeUser   senderType = "user"
	SenderTypeBot    senderType = "bot"
	SenderTypeSystem senderType = "system"
)

SenderType constants

View Source
const (
	Mentions attachmentType = "mentions"
	Image    attachmentType = "image"
	Location attachmentType = "location"
	Emoji    attachmentType = "emoji"
)

AttachmentType constants

View Source
const (
	PeriodDay   = "day"
	PeriodWeek  = "week"
	PeriodMonth = "month"
)

Define acceptable period values

View Source
const GroupMeAPIBase = "https://api.groupme.com/v3"

GroupMeAPIBase - Endpoints are added on to this to get the full URI. Overridable for testing

View Source
const (
	PushServer = "wss://push.groupme.com/faye"
)

Variables

View Source
var (
	ErrHandlerNotFound    = errors.New("Handler not found")
	ErrListenerNotStarted = errors.New("GroupMe listener not started")
)
View Source
var RealTimeHandlers map[string]func(r *PushSubscription, channel string, data ...interface{})
View Source
var RealTimeSystemHandlers map[string]func(r *PushSubscription, channel string, id ID, rawData []byte)

Functions

This section is empty.

Types

type Attachment

type Attachment struct {
	Type            attachmentType `json:"type,omitempty"`
	Loci            [][]int        `json:"loci,omitempty"`
	UserIDs         []ID           `json:"user_ids,omitempty"`
	URL             string         `json:"url,omitempty"`
	FileID          string         `json:"file_id,omitempty"`
	VideoPreviewURL string         `json:"preview_url,omitempty"`
	Name            string         `json:"name,omitempty"`
	Latitude        string         `json:"lat,omitempty"`
	Longitude       string         `json:"lng,omitempty"`
	Placeholder     string         `json:"placeholder,omitempty"`
	Charmap         [][]int        `json:"charmap,omitempty"`
	ReplyID         ID             `json:"reply_id,omitempty"`
}

Attachment is a GroupMe message attachment, returned in JSON API responses

func (*Attachment) String

func (a *Attachment) String() string

type Block

type Block struct {
	UserID        ID        `json:"user_id,omitempty"`
	BlockedUserID ID        `json:"blocked_user_id,omitempty"`
	CreatedAT     Timestamp `json:"created_at,omitempty"`
}

Block is a GroupMe block between two users, direct messages are not allowed

func (Block) String

func (b Block) String() string

type Bot

type Bot struct {
	BotID          ID     `json:"bot_id,omitempty"`
	GroupID        ID     `json:"group_id,omitempty"`
	Name           string `json:"name,omitempty"`
	AvatarURL      string `json:"avatar_url,omitempty"`
	CallbackURL    string `json:"callback_url,omitempty"`
	DMNotification bool   `json:"dm_notification,omitempty"`
}

Bot is a GroupMe bot, it is connected to a specific group which it can send messages to

func (*Bot) String

func (b *Bot) String() string

type ChangeOwnerRequest

type ChangeOwnerRequest struct {
	// Required
	GroupID string `json:"group_id"`
	// Required. UserId of the new owner of the group
	// who must be an active member of the group
	OwnerID string `json:"owner_id"`
}

ChangeOwnerRequest defines the new owner of a group

func (ChangeOwnerRequest) String

func (r ChangeOwnerRequest) String() string

type ChangeOwnerResult

type ChangeOwnerResult struct {
	GroupID string `json:"group_id"`
	// UserId of the new owner of the group who is
	// an active member of the group
	OwnerID string                `json:"owner_id"`
	Status  changeOwnerStatusCode `json:"status"`
}

ChangeOwnerResult holds the status of the group owner change

func (ChangeOwnerResult) String

func (r ChangeOwnerResult) String() string

type Chat

type Chat struct {
	CreatedAt     Timestamp `json:"created_at,omitempty"`
	UpdatedAt     Timestamp `json:"updated_at,omitempty"`
	LastMessage   *Message  `json:"last_message,omitempty"`
	MessagesCount int       `json:"messages_count,omitempty"`
	OtherUser     User      `json:"other_user,omitempty"`
}

Chat is a GroupMe direct message conversation between two users, returned in JSON API responses

func (*Chat) String

func (c *Chat) String() string

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client communicates with the GroupMe API to perform actions on the basic types, i.e. Listing, Creating, Destroying

func NewClient

func NewClient(authToken string) *Client

NewClient creates a new GroupMe API Client

func (*Client) AddMembers

func (c *Client) AddMembers(ctx context.Context, groupID ID, members ...*Member) (string, error)

AddMembers -

Add members to a group.

Multiple members can be added in a single request, and results are fetchedwith a separate call (since memberships are processed asynchronously). The response includes a results_id that's used in the results request.

In order to correlate request params with resulting memberships, GUIDs can be added to the members parameters. These GUIDs will be reflected in the membership JSON objects.

Parameters:

groupID - required, ID(string)
See Member.
	Nickname - required
	One of the following identifiers must be used:
		UserID - ID(string)
		PhoneNumber - PhoneNumber(string)
		Email - string

func (*Client) AddMembersResults

func (c *Client) AddMembersResults(ctx context.Context, groupID ID, resultID string) ([]*Member, error)

AddMembersResults - Get the membership results from an add call.

Successfully created memberships will be returned, including any GUIDs that were sent up in the add request. If GUIDs were absent, they are filled in automatically. Failed memberships and invites are omitted.

Keep in mind that results are temporary -- they will only be available for 1 hour after the add request.

Parameters:

groupID - required, ID(string)
resultID - required, string

func (*Client) BlockBetween

func (c *Client) BlockBetween(ctx context.Context, userID, otherUserID string) (bool, error)

BlockBetween - Asks if a block exists between you and another user id

func (*Client) ChangeGroupOwner

func (c *Client) ChangeGroupOwner(ctx context.Context, reqs ChangeOwnerRequest) (ChangeOwnerResult, error)

ChangeGroupOwner - Change owner of requested groups.

This action is only available to the group creator.

Response is a result object which contain status field, the result of change owner action for the request

Parameters: See ChangeOwnerRequest

func (*Client) Close

func (c *Client) Close() error

Close safely shuts down the Client

func (*Client) CreateBlock

func (c *Client) CreateBlock(ctx context.Context, userID, otherUserID string) (*Block, error)

CreateBlock - Creates a block between you and the contact

func (*Client) CreateBot

func (c *Client) CreateBot(ctx context.Context, bot *Bot) (*Bot, error)

CreateBot - Create a bot. See the Bots Tutorial (https://dev.groupme.com/tutorials/bots) for a full walkthrough.

func (*Client) CreateDirectMessage

func (c *Client) CreateDirectMessage(ctx context.Context, m *Message) (*Message, error)

CreateDirectMessage - Send a DM to another user

If you want to attach an image, you must first process it through our image service.

Attachments of type emoji rely on data from emoji PowerUps.

Clients use a placeholder character in the message text and specify a replacement charmap to substitute emoji characters

The character map is an array of arrays containing rune data ([[{pack_id,offset}],...]).

func (*Client) CreateGroup

func (c *Client) CreateGroup(ctx context.Context, gs GroupSettings) (*Group, error)

CreateGroup -

Create a new group

Parameters: See GroupSettings

func (*Client) CreateLike

func (c *Client) CreateLike(ctx context.Context, conversationID, messageID ID) error

CreateLike - Like a message.

func (*Client) CreateMessage

func (c *Client) CreateMessage(ctx context.Context, groupID ID, m *Message) (*Message, error)

CreateMessage - Send a message to a group

If you want to attach an image, you must first process it through our image service.

Attachments of type emoji rely on data from emoji PowerUps.

Clients use a placeholder character in the message text and specify a replacement charmap to substitute emoji characters

The character map is an array of arrays containing rune data ([[{pack_id,offset}],...]).

The placeholder should be a high-point/invisible UTF-8 character.

func (*Client) CreateSMSMode

func (c *Client) CreateSMSMode(ctx context.Context, duration int, registrationID *ID) error

CreateSMSMode - Enables SMS mode for N hours, where N is at most 48. After N hours have elapsed, user will receive push notfications.

Parameters:

duration - required, integer
registration_id - string; The push notification ID/token
	that should be suppressed during SMS mode. If this is
	omitted, both SMS and push notifications will be
	delivered to the device.

func (*Client) DeleteSMSMode

func (c *Client) DeleteSMSMode(ctx context.Context) error

DeleteSMSMode -

Disables SMS mode

func (*Client) DestroyBot

func (c *Client) DestroyBot(ctx context.Context, botID ID) error

DestroyBot - Remove a bot that you have created

func (*Client) DestroyGroup

func (c *Client) DestroyGroup(ctx context.Context, groupID ID) error

DestroyGroup -

Disband a group

This action is only available to the group creator

Parameters:

groupID - required, ID(string)

func (*Client) DestroyLike

func (c *Client) DestroyLike(ctx context.Context, conversationID, messageID ID) error

DestroyLike - Unlike a message.

func (*Client) FormerGroups

func (c *Client) FormerGroups(ctx context.Context) ([]*Group, error)

FormerGroups -

List they groups you have left but can rejoin.

func (*Client) IndexBlock

func (c *Client) IndexBlock(ctx context.Context, userID string) ([]*Block, error)

IndexBlock - A list of contacts you have blocked. These people cannot DM you

func (*Client) IndexBots

func (c *Client) IndexBots(ctx context.Context) ([]*Bot, error)

IndexBots - list bots that you have created

func (*Client) IndexChats

func (c *Client) IndexChats(ctx context.Context, req *IndexChatsQuery) ([]*Chat, error)

IndexChats - Returns a paginated list of direct message chats, or conversations, sorted by updated_at descending.

func (*Client) IndexDirectMessages

func (c *Client) IndexDirectMessages(ctx context.Context, otherUserID string, req *IndexDirectMessagesQuery) (IndexDirectMessagesResponse, error)

IndexDirectMessages -

Fetch direct messages between two users.

DMs are returned in groups of 20, ordered by created_at descending.

If no messages are found (e.g. when filtering with since_id) we return code 304.

Note that for historical reasons, likes are returned as an array of user ids in the favorited_by key.

Parameters:

otherUserID - required, ID(string); the other participant in the conversation.
See IndexDirectMessagesQuery

func (*Client) IndexGroups

func (c *Client) IndexGroups(ctx context.Context, req *GroupsQuery) ([]*Group, error)

IndexGroups -

List the authenticated user's active groups.

The response is paginated, with a default of 10 groups per page.

Please consider using of omit=memberships parameter. Not including member lists might significantly improve user experience of your app for users who are participating in huge groups.

Parameters: See GroupsQuery

func (*Client) IndexLeaderboard

func (c *Client) IndexLeaderboard(ctx context.Context, groupID ID, p period) ([]*Message, error)

IndexLeaderboard - A list of the liked messages in the group for a given period of time. Messages are ranked in order of number of likes.

func (*Client) IndexMessages

func (c *Client) IndexMessages(ctx context.Context, groupID ID, req *IndexMessagesQuery) (IndexMessagesResponse, error)

IndexMessages - Retrieves messages for a group. By default, messages are returned in groups of 20, ordered by created_at descending. This can be raised or lowered by passing a limit parameter, up to a maximum of 100 messages. Messages can be scanned by providing a message ID as either the before_id, since_id, or after_id parameter. If before_id is provided, then messages immediately preceding the given message will be returned, in descending order. This can be used to continually page back through a group's messages. The after_id parameter will return messages that immediately follow a given message, this time in ascending order (which makes it easy to pick off the last result for continued pagination). Finally, the since_id parameter also returns messages created after the given message, but it retrieves the most recent messages. For example, if more than twenty messages are created after the since_id message, using this parameter will omit the messages that immediately follow the given message. This is a bit counterintuitive, so take care. If no messages are found (e.g. when filtering with before_id) we return code 304. Note that for historical reasons, likes are returned as an array of user ids in the favorited_by key.

func (*Client) IndexRelations

func (c *Client) IndexRelations(ctx context.Context) ([]*User, error)

func (*Client) JoinGroup

func (c *Client) JoinGroup(ctx context.Context, groupID ID, shareToken string) (*Group, error)

JoinGroup -

Join a shared group

Parameters:

groupID - required, ID(string)
shareToken - required, string

func (*Client) MyHitsLeaderboard

func (c *Client) MyHitsLeaderboard(ctx context.Context, groupID ID) ([]*Message, error)

MyHitsLeaderboard -

A list of messages you have liked. Messages are returned in reverse chrono-order. Note that the payload includes a liked_at timestamp in ISO-8601 format.

Parameters:

groupID - required, ID(string)

func (*Client) MyLikesLeaderboard

func (c *Client) MyLikesLeaderboard(ctx context.Context, groupID ID) ([]*Message, error)

MyLikesLeaderboard -

A list of messages you have liked. Messages are returned in reverse chrono-order. Note that the payload includes a liked_at timestamp in ISO-8601 format.

Parameters:

groupID - required, ID(string)

func (*Client) MyUser

func (c *Client) MyUser(ctx context.Context) (*User, error)

MyUser -

Loads a specific group.

Parameters:

groupID - required, ID(string)

func (*Client) PostBotMessage

func (c *Client) PostBotMessage(ctx context.Context, botID ID, text string, pictureURL *string) error

PostBotMessage - Post a message from a bot TODO: Move PostBotMessage to bot object, since it doesn't require access token

func (*Client) RejoinGroup

func (c *Client) RejoinGroup(ctx context.Context, groupID ID) (*Group, error)

RejoinGroup -

Rejoin a group. Only works if you previously removed yourself.

Parameters:

groupID - required, ID(string)

func (*Client) RemoveMember

func (c *Client) RemoveMember(ctx context.Context, groupID, membershipID ID) error

RemoveMember -

Remove a member (or yourself) from a group.

Note: The creator of the group cannot be removed or exit.

Parameters:

groupID - required, ID(string)
membershipID - required, ID(string). Not the same as userID

func (*Client) ShowGroup

func (c *Client) ShowGroup(ctx context.Context, groupID ID) (*Group, error)

ShowGroup -

Loads a specific group.

Parameters:

groupID - required, ID(string)

func (Client) String

func (c Client) String() string

String returns a json formatted string

func (*Client) Unblock

func (c *Client) Unblock(ctx context.Context, userID, otherUserID string) error

Unblock - Removes block between you and other user

func (*Client) UpdateGroup

func (c *Client) UpdateGroup(ctx context.Context, groupID ID, gs GroupSettings) (*Group, error)

UpdateGroup -

Update a group after creation

Parameters:

groupID - required, ID(string)
See GroupSettings

func (*Client) UpdateMember

func (c *Client) UpdateMember(ctx context.Context, groupID ID, nickname string) (*Member, error)

UpdateMember -

Update your nickname in a group. The nickname must be between 1 and 50 characters.

func (*Client) UpdateMyUser

func (c *Client) UpdateMyUser(ctx context.Context, us UserSettings) (*User, error)

UpdateMyUser -

Update attributes about your own account

Parameters: See UserSettings

type Group

type Group struct {
	ID   ID     `json:"id,omitempty"`
	Name string `json:"name,omitempty"`
	// Type of group (private|public)
	Type          string        `json:"type,omitempty"`
	Description   string        `json:"description,omitempty"`
	ImageURL      string        `json:"image_url,omitempty"`
	CreatorUserID ID            `json:"creator_user_id,omitempty"`
	CreatedAt     Timestamp     `json:"created_at,omitempty"`
	UpdatedAt     Timestamp     `json:"updated_at,omitempty"`
	Members       []*Member     `json:"members,omitempty"`
	ShareURL      string        `json:"share_url,omitempty"`
	Messages      GroupMessages `json:"messages,omitempty"`
}

Group is a GroupMe group, returned in JSON API responses

func (*Group) GetMemberByNickname

func (g *Group) GetMemberByNickname(nickname string) *Member

GetMemberByNickname gets the group member by their Nickname, nil if no member matches

func (*Group) GetMemberByUserID

func (g *Group) GetMemberByUserID(userID ID) *Member

GetMemberByUserID gets the group member by their UserID, nil if no member matches

func (*Group) String

func (g *Group) String() string

type GroupMessages

type GroupMessages struct {
	Count                uint           `json:"count,omitempty"`
	LastMessageID        ID             `json:"last_message_id,omitempty"`
	LastMessageCreatedAt Timestamp      `json:"last_message_created_at,omitempty"`
	Preview              MessagePreview `json:"preview,omitempty"`
}

GroupMessages is a Group field, only returned in Group JSON API responses

type GroupSettings

type GroupSettings struct {
	// Required. Primary name of the group. Maximum 140 characters
	Name string `json:"name"`
	// A subheading for the group. Maximum 255 characters
	Description string `json:"description"`
	// GroupMe Image Service URL
	ImageURL string `json:"image_url"`
	// Defaults false. If true, disables notifications for all members.
	// Documented for use only for UpdateGroup
	OfficeMode bool `json:"office_mode"`
	// Defaults false. If true, generates a share URL.
	// Anyone with the URL can join the group
	Share bool `json:"share"`
}

GroupSettings is the settings for a group, used by CreateGroup and UpdateGroup

func (GroupSettings) String

func (gss GroupSettings) String() string

type GroupsQuery

type GroupsQuery struct {
	// Fetch a particular page of results. Defaults to 1.
	Page int `json:"page"`
	// Define page size. Defaults to 10.
	PerPage int `json:"per_page"`
	// Comma separated list of data to omit from output.
	// Currently supported value is only "memberships".
	// If used then response will contain empty (null) members field.
	Omit string `json:"omit"`
}

GroupsQuery defines optional URL parameters for IndexGroups

func (GroupsQuery) String

func (q GroupsQuery) String() string

type HTTPStatusCode

type HTTPStatusCode int

HTTPStatusCode are returned by HTTP requests in the header and the json "meta" field

const (
	HTTPOk                  HTTPStatusCode = 200
	HTTPCreated             HTTPStatusCode = 201
	HTTPNoContent           HTTPStatusCode = 204
	HTTPNotModified         HTTPStatusCode = 304
	HTTPBadRequest          HTTPStatusCode = 400
	HTTPUnauthorized        HTTPStatusCode = 401
	HTTPForbidden           HTTPStatusCode = 403
	HTTPNotFound            HTTPStatusCode = 404
	HTTPEnhanceYourCalm     HTTPStatusCode = 420
	HTTPInternalServerError HTTPStatusCode = 500
	HTTPBadGateway          HTTPStatusCode = 502
	HTTPServiceUnavailable  HTTPStatusCode = 503
)

Text used as constant name

func (HTTPStatusCode) String

func (c HTTPStatusCode) String() string

String returns the description of the status code according to GroupMe

type HandleGroupAvatar

type HandleGroupAvatar interface {
	HandleGroupAvatar(group ID, newAvatar string)
}

type HandleGroupLikeIcon

type HandleGroupLikeIcon interface {
	HandleLikeIcon(group ID, PackID, PackIndex int, Type string)
}

type HandleGroupName

type HandleGroupName interface {
	HandleGroupName(group ID, newName string)
}

type HandleGroupTopic

type HandleGroupTopic interface {
	HandleGroupTopic(group ID, newTopic string)
}

Group Handlers

type HandleMemberNewAvatar

type HandleMemberNewAvatar interface {
	HandleNewAvatarInGroup(group ID, user ID, avatarURL string)
}

type HandleMemberNewNickname

type HandleMemberNewNickname interface {
	HandleNewNickname(group ID, user ID, newName string)
}

Group member handlers

type HandleMembers

type HandleMembers interface {
	//HandleNewMembers returns only partial member with id and nickname; added is false if removing
	HandleMembers(group ID, members []Member, added bool)
}

type Handler

type Handler interface {
	HandleError(error)
}

type HandlerLike

type HandlerLike interface {
	HandleLike(Message)
}

type HandlerMembership

type HandlerMembership interface {
	HandleJoin(ID)
}

type HandlerText

type HandlerText interface {
	HandleTextMessage(Message)
}

type ID

type ID string

ID is an unordered alphanumeric string

func (ID) String

func (id ID) String() string

func (ID) Valid

func (id ID) Valid() bool

Valid checks if the ID string is alpha numeric

type IndexChatsQuery

type IndexChatsQuery struct {
	// Page Number
	Page int `json:"page"`
	// Number of chats per page
	PerPage int `json:"per_page"`
}

IndexChatsQuery defines the optional URL parameters for IndexChats

type IndexDirectMessagesQuery

type IndexDirectMessagesQuery struct {
	// Returns 20 messages created before the given message ID
	BeforeID ID `json:"before_id"`
	// Returns 20 messages created after the given message ID
	SinceID ID `json:"since_id"`
}

IndexDirectMessagesQuery defines the optional URL parameters for IndexDirectMessages

func (IndexDirectMessagesQuery) String

func (q IndexDirectMessagesQuery) String() string

type IndexDirectMessagesResponse

type IndexDirectMessagesResponse struct {
	Count    int        `json:"count"`
	Messages []*Message `json:"direct_messages"`
}

IndexDirectMessagesResponse contains the count and set of messages returned by the IndexDirectMessages API request

func (IndexDirectMessagesResponse) String

type IndexMessagesQuery

type IndexMessagesQuery struct {
	// Returns messages created before the given message ID
	BeforeID ID
	// Returns most recent messages created after the given message ID
	SinceID ID
	// Returns messages created immediately after the given message ID
	AfterID ID
	// Number of messages returned. Default is 20. Max is 100.
	Limit int
}

IndexMessagesQuery defines the optional URL parameters for IndexMessages

func (IndexMessagesQuery) String

func (q IndexMessagesQuery) String() string

type IndexMessagesResponse

type IndexMessagesResponse struct {
	Count    int        `json:"count"`
	Messages []*Message `json:"messages"`
}

IndexMessagesResponse contains the count and set of messages returned by the IndexMessages API request

func (IndexMessagesResponse) String

func (r IndexMessagesResponse) String() string

type Member

type Member struct {
	ID           ID     `json:"id,omitempty"`
	UserID       ID     `json:"user_id,omitempty"`
	Nickname     string `json:"nickname,omitempty"`
	Muted        bool   `json:"muted,omitempty"`
	ImageURL     string `json:"image_url,omitempty"`
	AutoKicked   bool   `json:"autokicked,omitempty"`
	AppInstalled bool   `json:"app_installed,omitempty"`
	GUID         string `json:"guid,omitempty"`
	PhoneNumber  string `json:"phone_number,omitempty"` // Only used when searching for the member to add to a group.
	Email        string `json:"email,omitempty"`        // Only used when searching for the member to add to a group.
}

Member is a GroupMe group member, returned in JSON API responses

func (*Member) String

func (m *Member) String() string

type Message

type Message struct {
	ID          ID         `json:"id,omitempty"`
	SourceGUID  string     `json:"source_guid,omitempty"`
	CreatedAt   Timestamp  `json:"created_at,omitempty"`
	GroupID     ID         `json:"group_id,omitempty"`
	UserID      ID         `json:"user_id,omitempty"`
	BotID       ID         `json:"bot_id,omitempty"`
	SenderID    ID         `json:"sender_id,omitempty"`
	SenderType  senderType `json:"sender_type,omitempty"`
	System      bool       `json:"system,omitempty"`
	Name        string     `json:"name,omitempty"`
	RecipientID ID         `json:"recipient_id,omitempty"`
	//ChatID - over push ConversationID seems to be called ChatID
	ChatID         ID     `json:"chat_id,omitempty"`
	ConversationID ID     `json:"conversation_id,omitempty"`
	AvatarURL      string `json:"avatar_url,omitempty"`
	// Maximum length of 1000 characters
	Text string `json:"text,omitempty"`
	// Must be an image service URL (i.groupme.com)
	ImageURL    string        `json:"image_url,omitempty"`
	FavoritedBy []string      `json:"favorited_by,omitempty"`
	Attachments []*Attachment `json:"attachments,omitempty"`
}

Message is a GroupMe group message, returned in JSON API responses

func (*Message) String

func (m *Message) String() string

type MessagePreview

type MessagePreview struct {
	Nickname    string        `json:"nickname,omitempty"`
	Text        string        `json:"text,omitempty"`
	ImageURL    string        `json:"image_url,omitempty"`
	Attachments []*Attachment `json:"attachments,omitempty"`
}

MessagePreview is a GroupMessages field, only returned in Group JSON API responses. Abbreviated form of Message type

type Meta

type Meta struct {
	Code   HTTPStatusCode `json:"code,omitempty"`
	Errors []string       `json:"errors,omitempty"`
}

Meta is the error type returned in the GroupMe response. Meant for clients that can't read HTTP status codes

func (Meta) Error

func (m Meta) Error() string

Error returns the code and the error list as a string. Satisfies the error interface

type PhoneNumber

type PhoneNumber string

PhoneNumber is the country code plus the number of the user

func (PhoneNumber) String

func (pn PhoneNumber) String() string

func (PhoneNumber) Valid

func (pn PhoneNumber) Valid() bool

Valid checks if the ID string is alpha numeric

type PushSubscription

type PushSubscription struct {
	LastConnected int64
	// contains filtered or unexported fields
}

PushSubscription manages real time subscription

func NewPushSubscription

func NewPushSubscription(context context.Context) PushSubscription

NewPushSubscription creates and returns a push subscription object

func (*PushSubscription) AddFullHandler

func (r *PushSubscription) AddFullHandler(h HandlerAll)

AddFullHandler is the same as AddHandler except it ensures the interface implements everything

func (*PushSubscription) AddHandler

func (r *PushSubscription) AddHandler(h Handler)

func (*PushSubscription) Connect

func (r *PushSubscription) Connect(context context.Context, authorizationToken string) error

Listen connects to GroupMe. Runs in Goroutine.

func (*PushSubscription) Connected

func (r *PushSubscription) Connected() bool

Connected check if connected

func (*PushSubscription) SubscribeToDM

func (r *PushSubscription) SubscribeToDM(context context.Context, id ID) error

SubscribeToDM to users

func (*PushSubscription) SubscribeToGroup

func (r *PushSubscription) SubscribeToGroup(context context.Context, id ID) error

SubscribeToGroup to groups for typing notification

func (*PushSubscription) SubscribeToUser

func (r *PushSubscription) SubscribeToUser(context context.Context, id ID) error

SubscribeToUser to users

type Timestamp

type Timestamp uint64

Timestamp is the number of seconds since the UNIX epoch

func FromTime

func FromTime(t time.Time) Timestamp

FromTime returns the time.Time as a Timestamp

func (Timestamp) String

func (t Timestamp) String() string

String returns the Timestamp in the default time.Time string format

func (Timestamp) ToTime

func (t Timestamp) ToTime() time.Time

ToTime returns the Timestamp as a UTC Time

type User

type User struct {
	ID          ID          `json:"id,omitempty"`
	PhoneNumber PhoneNumber `json:"phone_number,omitempty"`
	ImageURL    string      `json:"image_url,omitempty"`
	Name        string      `json:"name,omitempty"`
	CreatedAt   Timestamp   `json:"created_at,omitempty"`
	UpdatedAt   Timestamp   `json:"updated_at,omitempty"`
	AvatarURL   string      `json:"avatar_url,omitempty"`
	Email       string      `json:"email,omitempty"`
	SMS         bool        `json:"sms,omitempty"`
}

User is a GroupMe user, returned in JSON API responses

func (*User) String

func (u *User) String() string

type UserSettings

type UserSettings struct {
	// URL to valid JPG/PNG/GIF image. URL will be converted into
	// an image service link (https://i.groupme.com/....)
	AvatarURL string `json:"avatar_url"`
	// Name must be of the form FirstName LastName
	Name string `json:"name"`
	// Email address. Must be in name@domain.com form
	Email   string `json:"email"`
	ZipCode string `json:"zip_code"`
}

UserSettings are the settings for a GroupMe user

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

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