api

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2025 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var EventMapping = map[string]any{
	"message":               MessageEvent{},
	"reaction_added":        ReactionAddedEvent{},
	"reaction_removed":      ReactionRemovedEvent{},
	"member_joined_channel": ChannelJoinedEvent{},
	"channel_left":          ChannelLeftEvent{},
}

Functions

func ChannelJoinHandler

func ChannelJoinHandler(msgChan chan tea.Msg, ev *ChannelJoinedEvent)

func ChannelLeaveHandler

func ChannelLeaveHandler(msgChan chan tea.Msg, ev *ChannelLeftEvent)

func GetChannelHistory

func GetChannelHistory(api *slack.Client, channelID string) tea.Cmd

func GetLatestMessage

func GetLatestMessage(api *slack.Client, channelID string) (*slack.Message, error)

func GetThread

func GetThread(api *slack.Client, channelID string, ts string) tea.Cmd

func GetUserInfo

func GetUserInfo(api *slack.Client, userID string) (*slack.User, error)

func LoadCache

func LoadCache() *core.Cache

func LoadConfig

func LoadConfig() (core.Config, error)

func MessageHandler

func MessageHandler(msgChan chan tea.Msg, ev *MessageEvent)

func Paginate

func Paginate[T any](fetch func(cursor string) (items []T, nextCursor string, err error)) ([]T, error)

func ReactionAddHandler

func ReactionAddHandler(msgChan chan tea.Msg, ev *ReactionAddedEvent)

func ReactionRemoveHandler

func ReactionRemoveHandler(msgChan chan tea.Msg, ev *ReactionRemovedEvent)

func RunWebsocket

func RunWebsocket(token, cookie string, msgChan chan tea.Msg)

func SaveCache

func SaveCache(cache core.Cache) error

func SaveConfig

func SaveConfig(cfg core.Config) error

func WithRetry

func WithRetry(fn func() error)

Types

type ChannelJoinedEvent

type ChannelJoinedEvent struct {
	User        string `json:"user"`
	Channel     string `json:"channel"`
	ChannelType string `json:"channel_type"`
}

type ChannelLeftEvent

type ChannelLeftEvent struct {
	Channel string `json:"channel"`
}

type InitialEvent

type InitialEvent struct {
	Type string `json:"type"`
}

type MessageEvent

type MessageEvent struct {
	ClientMsgID      string            `json:"client_msg_id,omitempty"`
	Type             string            `json:"type,omitempty"`
	Channel          string            `json:"channel,omitempty"`
	User             string            `json:"user,omitempty"`
	Text             string            `json:"text,omitempty"`
	Timestamp        string            `json:"ts,omitempty"`
	ThreadTimestamp  string            `json:"thread_ts,omitempty"`
	IsStarred        bool              `json:"is_starred,omitempty"`
	PinnedTo         []string          `json:"pinned_to,omitempty"`
	Attachments      []core.Attachment `json:"attachments,omitempty"`
	Files            []core.File       `json:"files,omitempty"`
	LastRead         string            `json:"last_read,omitempty"`
	Subscribed       bool              `json:"subscribed,omitempty"`
	UnreadCount      int               `json:"unread_count,omitempty"`
	ReplyCount       int               `json:"reply_count,omitempty"`
	ReplyUsers       []string          `json:"reply_users,omitempty"`
	SubType          string            `json:"subtype,omitempty"`
	Hidden           bool              `json:"hidden,omitempty"`
	DeletedTimestamp string            `json:"deleted_ts,omitempty"`
	EventTimestamp   string            `json:"event_ts,omitempty"`
	Message          struct {
		Ts   string `json:"ts"`
		Text string `json:"text"`
	} `json:"message,omitempty"`
}

type ReactionAddedEvent

type ReactionAddedEvent ReactionEvent

type ReactionEvent

type ReactionEvent struct {
	Type     string `json:"type"`
	User     string `json:"user"`
	ItemUser string `json:"item_user"`

	Item struct {
		Type        string `json:"type"`
		Channel     string `json:"channel,omitempty"`
		File        string `json:"file,omitempty"`
		FileComment string `json:"file_comment,omitempty"`
		Timestamp   string `json:"ts,omitempty"`
	} `json:"item"`

	Reaction       string `json:"reaction"`
	EventTimestamp string `json:"event_ts"`
}

type ReactionRemovedEvent

type ReactionRemovedEvent ReactionEvent

Jump to

Keyboard shortcuts

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