pachca

package module
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

README

Codacy badge GitHub Actions CI Status GitHub Actions CodeQL Status

CI StatusContributingLicense


pachca is Go package for working with Pachca API.

CI Status

Branch Status
master CI
develop CI

Contributing

Before contributing to this project please read our Contributing Guidelines.

License

Apache License, Version 2.0

Documentation

Index

Constants

View Source
const API_URL = "https://api.pachca.com/api/shared/v1"

API_URL is URL of Pachca API

View Source
const APP_URL = "https://app.pachca.com"

APP_URL is application URL used to generate links

Variables

View Source
var (
	ErrNilClient         = errors.New("Client is nil")
	ErrNilUserRequest    = errors.New("User requests is nil")
	ErrNilChatRequest    = errors.New("Chat requests is nil")
	ErrNilMessageRequest = errors.New("Message requests is nil")
	ErrNilProperty       = errors.New("Property requests is nil")
	ErrEmptyToken        = errors.New("Token is empty")
	ErrEmptyTag          = errors.New("Group tag is empty")
	ErrEmptyMessage      = errors.New("Message text is empty")
	ErrEmptyUserEmail    = errors.New("User email is required for creating user account")
	ErrEmptyChatName     = errors.New("Name is required for creating new chat")
	ErrEmptyUsersIDS     = errors.New("Users IDs are empty")
	ErrEmptyTagsIDS      = errors.New("Tags IDs are empty")
	ErrEmptyFilePath     = errors.New("Path to file is empty")
	ErrInvalidToken      = errors.New("Token has wrong format")
	ErrInvalidMessageID  = errors.New("Message ID must be greater than 0")
	ErrInvalidChatID     = errors.New("Chat ID must be greater than 0")
	ErrInvalidUserID     = errors.New("User ID must be greater than 0")
	ErrInvalidThreadID   = errors.New("Thread ID must be greater than 0")
	ErrInvalidTagID      = errors.New("Group tag ID must be greater than 0")
	ErrInvalidEntityID   = errors.New("Entity ID must be greater than 0")
	ErrBlankEmoji        = errors.New("Non-blank emoji is required")
)

Functions

func ValidateToken

func ValidateToken(token string) error

ValidateToken validates API access token

Types

type APIError

type APIError struct {
	Key        string `json:"key"`
	Value      string `json:"value"`
	Message    string `json:"message"`
	Code       string `json:"code"`
	StatusCode int
}

APIError contains API error info

func (APIError) Error

func (e APIError) Error() string

Error returns error text

type Button

type Button struct {
	Text string `json:"text"`
	URL  string `json:"url"`
	Data string `json:"data"`
}

Button contains info about message button

type Buttons

type Buttons []*Button

Buttons is a slice of buttons

type Chat

type Chat struct {
	Members       []uint `json:"member_ids"`
	GroupTags     []uint `json:"group_tag_ids"`
	ID            uint   `json:"id"`
	OwnerID       uint   `json:"owner_id"`
	Name          string `json:"name"`
	MeetRoomURL   string `json:"meet_room_url"`
	CreatedAt     Date   `json:"created_at"`
	LastMessageAt Date   `json:"last_message_at"`
	IsPublic      bool   `json:"public"`
	IsChannel     bool   `json:"channel"`
}

Chat contains info about channel

func (*Chat) URL

func (c *Chat) URL() string

URL returns chat URL

type ChatFilter

type ChatFilter struct {
	LastMessageAfter  time.Time
	LastMessageBefore time.Time
	Public            bool
}

ChatFilter is configuration for filtering chats

func (ChatFilter) ToQuery

func (f ChatFilter) ToQuery() req.Query

ToQuery converts filter struct to request query

type ChatRequest

type ChatRequest struct {
	Name      string `json:"name,omitempty"`
	Members   []uint `json:"member_ids,omitempty"`
	Groups    []uint `json:"group_tag_ids,omitempty"`
	IsChannel bool   `json:"channel,omitempty"`
	IsPublic  bool   `json:"public,omitempty"`
}

ChatRequest is a struct with information needed to create or modify a chat

type ChatRole added in v0.4.0

type ChatRole string

ChatRole is type of user in chat

const (
	CHAT_ROLE_ADMIN  ChatRole = "admin"
	CHAT_ROLE_EDITOR ChatRole = "editor"
	CHAT_ROLE_MEMBER ChatRole = "member"
)

type Chats

type Chats []*Chat

Chats is slice of chats

func (Chats) Channels

func (c Chats) Channels() Chats

Channels returns slice with channels

func (Chats) Communal added in v0.1.0

func (c Chats) Communal() Chats

Communal returns communal chats (non-p2p)

func (Chats) Find added in v0.1.0

func (c Chats) Find(name string) *Chat

Find returns chat with given name

func (Chats) Get

func (c Chats) Get(id uint) *Chat

Get returns chat with given ID

func (Chats) Personal added in v0.1.0

func (c Chats) Personal() Chats

Personal returns p2p chats

func (Chats) Public

func (c Chats) Public() Chats

Public returns slice with public chats

type Client

type Client struct {
	BatchSize   int   // BatchSize is a number of items for paginated requests
	MaxFileSize int64 // Maximum file size to upload
	// contains filtered or unexported fields
}

Client is Pachca API client

func NewClient

func NewClient(token string) (*Client, error)

NewClient creates new client with given token

func (*Client) AddChat

func (c *Client) AddChat(chat *ChatRequest) (*Chat, error)

AddChat creates new chat

https://crm.pachca.com/dev/chats/new/

func (*Client) AddChatTags

func (c *Client) AddChatTags(chatID uint, tagIDs []uint) error

AddChatTags adds group tags to the chat

https://crm.pachca.com/dev/members/tags/new/

func (*Client) AddChatUsers

func (c *Client) AddChatUsers(chatID uint, membersIDs []uint, silent bool) error

AddChatUsers adds users with given IDs to the chat

https://crm.pachca.com/dev/members/users/new/

func (*Client) AddMessage

func (c *Client) AddMessage(message *MessageRequest) (*Message, error)

AddMessage creates new message to user or chat

https://crm.pachca.com/dev/messages/new/

func (*Client) AddReaction

func (c *Client) AddReaction(messageID uint, emoji string) error

AddReaction adds given emoji reaction to the message

https://crm.pachca.com/dev/reactions/new/

func (*Client) AddTag

func (c *Client) AddTag(groupTagName string) (*Tag, error)

AddTag creates new group tag

https://crm.pachca.com/dev/group_tags/new/

func (*Client) AddThreadMessage

func (c *Client) AddThreadMessage(messageID uint, message *MessageRequest) (*Message, error)

AddThreadMessage helper to create thread and add new message to it

func (*Client) AddThreadMessageText added in v0.2.0

func (c *Client) AddThreadMessageText(messageID uint, text string) (*Message, error)

AddThreadMessageText helper to create thread and add new message with given text to it

func (*Client) AddUser

func (c *Client) AddUser(user *UserRequest) (*User, error)

AddUser creates a new user

https://crm.pachca.com/dev/users/new/

func (*Client) ArchiveChat added in v0.3.0

func (c *Client) ArchiveChat(chatID uint) error

ArchiveChat sends chat to archive

https://crm.pachca.com/dev/chats/archive/

func (*Client) ChangeMessageText

func (c *Client) ChangeMessageText(messageID uint, text string) (*Message, error)

ChangeMessageText helper to change message text

func (*Client) DeleteMessage

func (c *Client) DeleteMessage(messageID uint) error

DeleteMessage deletes message with given ID

https://crm.pachca.com/dev/messages/delete/

func (*Client) DeleteReaction

func (c *Client) DeleteReaction(messageID uint, emoji string) error

DeleteReaction removes given emoji reaction from the message

https://crm.pachca.com/dev/reactions/delete/

func (*Client) DeleteTag

func (c *Client) DeleteTag(groupTagID uint) error

DeleteTag removes group tag

https://crm.pachca.com/dev/group_tags/delete/

func (*Client) DeleteUser

func (c *Client) DeleteUser(userID uint) error

DeleteUser deletes an existing user

https://crm.pachca.com/dev/users/delete/

func (*Client) EditChat

func (c *Client) EditChat(chatID uint, chat *ChatRequest) (*Chat, error)

EditChat modifies chat

https://crm.pachca.com/dev/chats/new/

func (*Client) EditMessage

func (c *Client) EditMessage(messageID uint, message *MessageRequest) (*Message, error)

EditMessage modifies message

https://crm.pachca.com/dev/messages/update/

func (*Client) EditTag

func (c *Client) EditTag(groupTagID uint, groupTagName string) (*Tag, error)

EditTag changes name of given group tag

https://crm.pachca.com/dev/group_tags/update/

func (*Client) EditUser

func (c *Client) EditUser(userID uint, user *UserRequest) (*User, error)

EditUser modifies an existing user

https://crm.pachca.com/dev/users/update/

func (*Client) Engine

func (c *Client) Engine() *req.Engine

Engine returns pointer to request engine used for all HTTP requests to API

func (*Client) ExcludeChatTag

func (c *Client) ExcludeChatTag(chatID, tagID uint) error

ExcludeChatTag excludes the group tag from the chat

https://crm.pachca.com/dev/members/tags/delete/

func (*Client) ExcludeChatUser

func (c *Client) ExcludeChatUser(chatID, userID uint) error

ExcludeChatUser excludes the user from the chat

https://crm.pachca.com/dev/members/users/delete/

func (*Client) GetChat

func (c *Client) GetChat(chatID uint) (*Chat, error)

GetChats returns info about specific channel

https://crm.pachca.com/dev/chats/get/

func (*Client) GetChats

func (c *Client) GetChats(filter ...ChatFilter) (Chats, error)

GetChats returns all chats and conversations

https://crm.pachca.com/dev/chats/list/

func (*Client) GetMessage

func (c *Client) GetMessage(messageID uint) (*Message, error)

GetMessage returns info about message

https://crm.pachca.com/dev/messages/get/

func (*Client) GetMessageReads added in v0.4.0

func (c *Client) GetMessageReads(messageID uint) ([]uint, error)

GetMessageReads returns a slice with IDs of users who have read the message

https://crm.pachca.com/dev/read_members/list/

func (*Client) GetProperties

func (c *Client) GetProperties() (Properties, error)

GetProperties returns custom properties

https://crm.pachca.com/dev/common/fields/

func (*Client) GetReactions

func (c *Client) GetReactions(messageID uint) (Reactions, error)

GetReactions returns slice with reactions added to given message

https://crm.pachca.com/dev/reactions/list/

func (*Client) GetTag

func (c *Client) GetTag(groupTagID uint) (*Tag, error)

GetTag returns info about group tag with given ID

https://crm.pachca.com/dev/group_tags/get/

func (*Client) GetTagUsers

func (c *Client) GetTagUsers(groupTagID uint) (Users, error)

GetTagUsers returns slice with users with given tag

https://crm.pachca.com/dev/group_tags/users/

func (*Client) GetTags

func (c *Client) GetTags() (Tags, error)

GetTags returns all group tags

https://crm.pachca.com/dev/group_tags/list/

func (*Client) GetThread

func (c *Client) GetThread(threadID uint) (*Thread, error)

GetThread returns info about thread

https://crm.pachca.com/dev/threads/get/

func (*Client) GetUser

func (c *Client) GetUser(userID uint) (*User, error)

GetUser returns info about user

https://crm.pachca.com/dev/users/get/

func (*Client) GetUsers

func (c *Client) GetUsers(searchQuery ...string) (Users, error)

GetUsers returns info about all users

https://crm.pachca.com/dev/users/list/

func (*Client) NewThread

func (c *Client) NewThread(messageID uint) (*Thread, error)

NewThread creates a new tread

https://crm.pachca.com/dev/threads/new/

func (*Client) PinMessage

func (c *Client) PinMessage(messageID uint) error

PinMessage pins message to chat

https://crm.pachca.com/dev/messages/pin/new/

func (*Client) SendMessageToChat

func (c *Client) SendMessageToChat(chatID uint, text string) (*Message, error)

SendMessageToChat helper to send message to chat with given ID

func (*Client) SendMessageToThread

func (c *Client) SendMessageToThread(threadID uint, text string) (*Message, error)

SendMessageToThread helper to send message to thread with given ID

func (*Client) SendMessageToUser

func (c *Client) SendMessageToUser(userID uint, text string) (*Message, error)

SendMessageToUser helper to send message to user with given ID

func (*Client) SetChatUserRole added in v0.4.0

func (c *Client) SetChatUserRole(chatID, userID uint, role ChatRole) error

SetChatUserRole sets user role in given chat

https://crm.pachca.com/dev/members/users/update/

func (*Client) SetUserAgent

func (c *Client) SetUserAgent(app, ver string)

SetUserAgent sets user-agent info

func (*Client) UnarchiveChat added in v0.3.0

func (c *Client) UnarchiveChat(chatID uint) error

UnarchiveChat restores chat from archive

https://crm.pachca.com/dev/chats/unarchive/

func (*Client) UnpinMessage

func (c *Client) UnpinMessage(messageID uint) error

UnpinMessage unpins message from chat

https://crm.pachca.com/dev/messages/pin/new/

func (*Client) UploadFile

func (c *Client) UploadFile(file string) (*File, error)

UploadFile uploads new file and returns key of it

https://crm.pachca.com/dev/common/files/

type Date

type Date struct {
	time.Time
}

Date is JSON date

func (*Date) UnmarshalJSON

func (d *Date) UnmarshalJSON(b []byte) error

UnmarshalJSON parses JSON date

type EntityType

type EntityType string

EntityType is type of entity type

const (
	ENTITY_TYPE_DISCUSSION EntityType = "discussion"
	ENTITY_TYPE_THREAD     EntityType = "thread"
	ENTITY_TYPE_USER       EntityType = "user"
)

type File

type File struct {
	ID   uint     `json:"id,omitempty"`
	Key  string   `json:"key"`
	Name string   `json:"name"`
	Type FileType `json:"file_type"`
	URL  string   `json:"url,omitempty"`
	Size uint     `json:"size,omitempty"`
}

File contains info about message attachment

type FileType

type FileType string

FileType is type for file type

const (
	FILE_TYPE_FILE  FileType = "file"
	FILE_TYPE_IMAGE FileType = "image"
)

type Files

type Files []*File

Files is a slice of attachments

type Forwarding

type Forwarding struct {
	OriginalMessageID          uint `json:"original_message_id"`
	OriginalChatID             uint `json:"original_chat_id"`
	AuthorID                   uint `json:"author_id"`
	OriginalThreadID           uint `json:"original_thread_id"`
	OriginalThreadMessageID    uint `json:"original_thread_message_id"`
	OriginalThreadParentChatID uint `json:"original_thread_parent_chat_id"`
	OriginalCreatedAt          Date `json:"original_created_at"`
}

Forwarding contains info about message forwarding

type InviteStatus

type InviteStatus string

InviteStatus is type of invite status

const (
	INVITE_SENT      InviteStatus = "sent"
	INVITE_CONFIRMED InviteStatus = "confirmed"
)

type Message

type Message struct {
	ID              uint        `json:"id"`
	EntityID        uint        `json:"entity_id"`
	ChatID          uint        `json:"chat_id"`
	ParentMessageID uint        `json:"parent_message_id"`
	UsedID          uint        `json:"user_id"`
	EntityType      EntityType  `json:"entity_type"`
	Content         string      `json:"content"`
	CreatedAt       Date        `json:"created_at"`
	Thread          *Thread     `json:"thread"`
	Files           Files       `json:"files"`
	Buttons         Buttons     `json:"buttons"`
	Forwarding      *Forwarding `json:"forwarding"`
}

Message contains info about message

func (*Message) URL

func (m *Message) URL() string

URL returns message URL

type MessageRequest

type MessageRequest struct {
	EntityType         EntityType `json:"entity_type,omitempty"`
	EntityID           uint       `json:"entity_id,omitempty"`
	Content            string     `json:"content,omitempty"`
	Files              Files      `json:"files,omitempty"`
	Buttons            Buttons    `json:"buttons,omitempty"`
	ParentMessageID    Buttons    `json:"parent_message_id,omitempty"`
	SkipInviteMentions bool       `json:"skip_invite_mentions,omitempty"`
}

MessageRequest is a struct with information needed to create or modify a message

type Properties

type Properties []*Property

Properties is a slice of properties

func (Properties) Find added in v0.1.0

func (p Properties) Find(name string) *Property

Find returns custom property with given name

func (Properties) FindAny added in v0.1.0

func (p Properties) FindAny(name ...string) *Property

FindAny returns first found property with one of given names

func (Properties) Get

func (p Properties) Get(id uint) *Property

Get returns custom property with given ID

func (Properties) Has added in v0.1.0

func (p Properties) Has(name string) bool

Has returns true if properties contains property with given name

func (Properties) HasAny added in v0.1.0

func (p Properties) HasAny(name ...string) bool

HasAny returns true if properties contains property with one of given names

func (Properties) Names added in v0.0.2

func (p Properties) Names() []string

Names returns slice with properties names

type Property

type Property struct {
	ID    uint         `json:"id"`
	Type  PropertyType `json:"data_type"`
	Name  string       `json:"name"`
	Value string       `json:"value"`
}

Property is custom property

func (*Property) Date added in v0.0.2

func (p *Property) Date() time.Time

Date returns property value as date

func (*Property) Int added in v0.0.2

func (p *Property) Int() int

Int returns property value as int

func (*Property) IsDate added in v0.0.2

func (p *Property) IsDate() bool

IsDate returns true if property has date type

func (p *Property) IsLink() bool

IsLink returns true if property has URL type

func (*Property) IsNumber added in v0.0.2

func (p *Property) IsNumber() bool

IsNumber returns true if property has number type

func (*Property) IsSet added in v0.2.0

func (p *Property) IsSet() bool

IsSet returns true if property has a value

func (*Property) IsText added in v0.0.2

func (p *Property) IsText() bool

IsText returns true if property has text type

func (*Property) String added in v0.0.2

func (p *Property) String() string

String returns property value

func (*Property) ToDate added in v0.0.2

func (p *Property) ToDate() (time.Time, error)

ToDate tries to convert property value to date

func (*Property) ToInt added in v0.0.2

func (p *Property) ToInt() (int, error)

ToInt tries to convert property value to int

type PropertyRequest added in v0.1.1

type PropertyRequest struct {
	ID    uint   `json:"id"`
	Value string `json:"value"`
}

PropertyRequest is a struct with property info

func NewPropertyRequest added in v0.1.1

func NewPropertyRequest(id uint, value any) *PropertyRequest

NewPropertyRequest creates new custom property

type PropertyRequests added in v0.1.1

type PropertyRequests []*PropertyRequest

PropertyRequests is a slice with properties requests

type PropertyType

type PropertyType string

PropertyType is type for property type

const (
	PROP_TYPE_DATE   PropertyType = "date"
	PROP_TYPE_LINK   PropertyType = "link"
	PROP_TYPE_NUMBER PropertyType = "number"
	PROP_TYPE_TEXT   PropertyType = "text"
)

type Reaction

type Reaction struct {
	UserID    uint   `json:"user_id"`
	CreatedAt Date   `json:"created_at"`
	Emoji     string `json:"code"`
}

Reaction contains reaction info

type Reactions

type Reactions []*Reaction

Reactions is a slice of reactions

type Status

type Status struct {
	Emoji     string `json:"emoji"`
	Title     string `json:"title"`
	ExpiresAt Date   `json:"expires_at"`
}

Status is user status

type Tag

type Tag struct {
	ID         uint   `json:"id"`
	Name       string `json:"name"`
	UsersCount int    `json:"users_count"`
}

Tag contains info about tag

type Tags

type Tags []*Tag

Tags is a slice of tags

func (Tags) Find added in v0.1.1

func (t Tags) Find(name string) *Tag

Find returns tag with given name

func (Tags) Get added in v0.1.0

func (t Tags) Get(id uint) *Tag

Get returns tag with given ID

func (Tags) InChat added in v0.1.0

func (t Tags) InChat(chat *Chat) Tags

InChat only returns tags that are present in the given chat

func (Tags) Names added in v0.1.1

func (t Tags) Names() []string

Names returns names of all tags

type Thread

type Thread struct {
	ID            uint `json:"id"`
	ChatID        uint `json:"chat_id"`
	MessageID     uint `json:"message_id"`
	MessageChatID uint `json:"message_chat_id"`
	UpdatedAt     Date `json:"updated_at"`
}

Thread contains info about thread

func (*Thread) URL

func (t *Thread) URL() string

URL returns thread URL

type Upload

type Upload struct {
	ContentDisposition string `json:"Content-Disposition"`
	ACL                string `json:"acl"`
	Policy             string `json:"policy"`
	Credential         string `json:"x-amz-credential"`
	Algorithm          string `json:"x-amz-algorithm"`
	Date               string `json:"x-amz-date"`
	Signature          string `json:"x-amz-signature"`
	Key                string `json:"key"`
	DirectURL          string `json:"direct_url"`
}

Upload contains upload info used for uploading files

type User

type User struct {
	ID           uint         `json:"id"`
	CreatedAt    Date         `json:"created_at"`
	ImageURL     string       `json:"image_url"`
	Email        string       `json:"email"`
	FirstName    string       `json:"first_name"`
	LastName     string       `json:"last_name"`
	Nickname     string       `json:"nickname"`
	Role         UserRole     `json:"role"`
	PhoneNumber  string       `json:"phone_number"`
	TimeZone     string       `json:"time_zone"`
	Title        string       `json:"title"`
	InviteStatus InviteStatus `json:"invite_status"`
	Department   string       `json:"department"`
	Properties   Properties   `json:"custom_properties"`
	Tags         []string     `json:"list_tags"`
	Status       *Status      `json:"user_status"`
	IsBot        bool         `json:"bot"`
	IsSuspended  bool         `json:"suspended"`
}

User contains info about user

func (*User) FullName

func (u *User) FullName() string

FullName returns user full name

func (*User) HasAvatar added in v0.1.0

func (u *User) HasAvatar() bool

HasAvatar returns true if user has custom avatar

func (*User) IsActive added in v0.1.0

func (u *User) IsActive() bool

IsActive returns true if user is active

func (*User) IsAdmin added in v0.1.0

func (u *User) IsAdmin() bool

IsAdmin returns true if user is admin

func (*User) IsGuest added in v0.1.0

func (u *User) IsGuest() bool

IsGuest returns true if user is guest or multi-guest

func (*User) IsInvited added in v0.1.0

func (u *User) IsInvited() bool

IsInvited returns true if user is invited

func (*User) IsRegular added in v0.1.0

func (u *User) IsRegular() bool

IsRegular returns true if user just regular user

func (*User) URL

func (u *User) URL() string

URL returns URL of user profile

type UserRequest

type UserRequest struct {
	Email           string           `json:"email,omitempty"`
	FirstName       string           `json:"first_name,omitempty"`
	LastName        string           `json:"last_name,omitempty"`
	Nickname        string           `json:"nickname,omitempty"`
	Role            UserRole         `json:"role,omitempty"`
	PhoneNumber     string           `json:"phone_number,omitempty"`
	Title           string           `json:"title,omitempty"`
	Department      string           `json:"department,omitempty"`
	Properties      PropertyRequests `json:"custom_properties,omitempty"`
	Tags            []string         `json:"list_tags,omitempty"`
	IsSuspended     bool             `json:"suspended,omitempty"`
	SkipEmailNotify bool             `json:"skip_email_notify,omitempty"`
}

UserRequest is a struct with information needed to create or modify a user

type UserRole

type UserRole string

UserRole is type of user role

const (
	ROLE_ADMIN       UserRole = "admin"
	ROLE_REGULAR     UserRole = "user"
	ROLE_MULTI_GUEST UserRole = "multi_guest"
	ROLE_GUEST       UserRole = "guest"
)

type Users

type Users []*User

Users is a slice of users

func (Users) Active

func (u Users) Active() Users

Active returns slice with active users

func (Users) Admins

func (u Users) Admins() Users

Admins returns slice with admins

func (Users) Bots

func (u Users) Bots() Users

Bots returns slice with bots

func (Users) Find added in v0.1.0

func (u Users) Find(nicknameOrEmail string) *User

Find returns user with given nickname or email

func (Users) Get added in v0.1.0

func (u Users) Get(id uint) *User

Get returns user with given ID or nil

func (Users) Guests

func (u Users) Guests() Users

Guests returns slice with guests

func (Users) InChat added in v0.1.0

func (u Users) InChat(chat *Chat) Users

InChat only returns users that are present in the given chat

func (Users) Invited

func (u Users) Invited() Users

Invited returns all invited users

func (Users) People added in v0.2.1

func (u Users) People() Users

People returns slice with non-bot users

func (Users) Regular

func (u Users) Regular() Users

Regular returns slice with regular users

func (Users) Suspended added in v0.0.3

func (u Users) Suspended() Users

Suspended returns slice with inactive users

type Webhook

type Webhook struct {
	Type            WebhookType  `json:"type"`
	ID              uint         `json:"id"`                // message
	Event           WebhookEvent `json:"event"`             // message, reaction
	EntityType      EntityType   `json:"entity_type"`       // message
	EntityID        uint         `json:"entity_id"`         // message
	Content         string       `json:"content"`           // message
	Emoji           string       `json:"code"`              // reaction
	Data            string       `json:"data"`              // button
	UserID          uint         `json:"user_id"`           // message, reaction
	CreatedAt       Date         `json:"created_at"`        // message, reaction, button
	ChatID          uint         `json:"chat_id"`           // message
	MessageID       uint         `json:"message_id"`        // reaction, button
	ParentMessageID uint         `json:"parent_message_id"` // message
	Thread          *Thread      `json:"thread"`            // message
}

WebhookMessage is message webhook payload

func (*Webhook) Command

func (w *Webhook) Command() string

Command returns slash command name from the beginning of the message

func (*Webhook) IsButton

func (w *Webhook) IsButton() bool

IsReaction returns true if webhook contains data for button event

func (*Webhook) IsDelete

func (w *Webhook) IsDelete() bool

IsDelete returns true if there is a webhook event for deleted message

func (*Webhook) IsMessage

func (w *Webhook) IsMessage() bool

IsReaction returns true if webhook contains data for message event

func (*Webhook) IsNew

func (w *Webhook) IsNew() bool

IsNew returns true if there is a webhook event for new message

func (*Webhook) IsReaction

func (w *Webhook) IsReaction() bool

IsReaction returns true if webhook contains data for reaction event

func (*Webhook) IsUpdate

func (w *Webhook) IsUpdate() bool

IsUpdate returns true if there is a webhook event for updated message

type WebhookEvent

type WebhookEvent string

WebhookEvent is type for webhook events

const (
	WEBHOOK_EVENT_NEW    WebhookEvent = "new"
	WEBHOOK_EVENT_UPDATE WebhookEvent = "update"
	WEBHOOK_EVENT_DELETE WebhookEvent = "delete"
)

type WebhookThread

type WebhookThread struct {
	MessageID     uint `json:"message_id"`
	MessageChatID uint `json:"message_chat_id"`
}

WebhookThread contains info about message thread

type WebhookType

type WebhookType string

WebhookType is type for webhook types

const (
	WEBHOOK_TYPE_MESSAGE  WebhookType = "message"
	WEBHOOK_TYPE_REACTION WebhookType = "reaction"
	WEBHOOK_TYPE_BUTTON   WebhookType = "button"
)

Jump to

Keyboard shortcuts

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