Documentation
¶
Overview ¶
Package timechat reads time.cu.ru (Mattermost) channels, direct messages and threads. It never posts, edits or marks anything as read.
Index ¶
- Constants
- Variables
- func ParseKind(s string) ([]model.TimeChannelKind, error)
- func ParseSince(raw string, now time.Time) (*time.Time, error)
- type ChannelsFilter
- type Client
- type Connector
- type Service
- func (s *Service) ChannelPosts(ctx context.Context, query string, since *time.Time, limit int) (*model.TimeChannelPosts, error)
- func (s *Service) ListChannels(ctx context.Context, f ChannelsFilter) ([]model.TimeChannel, error)
- func (s *Service) ResolveChannel(ctx context.Context, query string) (*model.TimeChannel, error)
- func (s *Service) Search(ctx context.Context, terms string, limit int) (*model.TimeSearchOutput, error)
- func (s *Service) Thread(ctx context.Context, postID string) (*model.TimeChannelPosts, error)
- func (s *Service) Updates(ctx context.Context, in model.TimeUpdatesInput) (*model.TimeUpdatesOutput, error)
Constants ¶
const ( DefaultChannelLimit = 30 MaxChannelLimit = 200 DefaultSearchLimit = 20 MaxSearchLimit = 100 DefaultPerChannelCap = 20 )
Variables ¶
var ErrNotLoggedIn = errors.New(
"нет входа в time.cu.ru или сессия истекла — войдите: `cu login --time`")
ErrNotLoggedIn is returned when there is no saved token or the session has expired.
Functions ¶
Types ¶
type ChannelsFilter ¶
type ChannelsFilter struct {
Kinds []model.TimeChannelKind
UnreadOnly bool
}
ChannelsFilter narrows ListChannels.
type Client ¶
type Client interface {
GetMe(ctx context.Context) (*tc.User, error)
GetTeamByName(ctx context.Context, name string) (*tc.Team, error)
GetUser(ctx context.Context, userID string) (*tc.User, error)
GetUserChannelsForTeam(ctx context.Context, userID, teamID string) ([]tc.Channel, error)
GetChannelMembersForUser(ctx context.Context, userID, teamID string) ([]tc.ChannelMember, error)
GetChannelPosts(ctx context.Context, channelID string, q tc.PostsQuery) (*tc.PostList, error)
GetPostThread(ctx context.Context, postID string) (*tc.PostList, error)
SearchTeamPosts(ctx context.Context, teamID string, req tc.SearchRequest) (*tc.PostList, error)
}
Client is the read-only subset of the time.cu.ru gateway used here.
type Connector ¶
Connector builds a client; it is called lazily so a fresh `cu login --time` is picked up without restarting the MCP server.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
func (*Service) ChannelPosts ¶
func (s *Service) ChannelPosts( ctx context.Context, query string, since *time.Time, limit int, ) (*model.TimeChannelPosts, error)
ChannelPosts returns messages of one channel in chronological order: the last `limit` messages, or all messages after `since` (capped to the latest `limit`).
func (*Service) ListChannels ¶
func (s *Service) ListChannels(ctx context.Context, f ChannelsFilter) ([]model.TimeChannel, error)
ListChannels returns the user's channels, DMs and group chats in the team with unread and mention counters, most relevant first.
func (*Service) ResolveChannel ¶
ResolveChannel finds a channel by ID, slug, display name, or DM partner username ("@ivanov" or "ivanov"). A unique substring of the title also matches.
func (*Service) Search ¶
func (s *Service) Search(ctx context.Context, terms string, limit int) (*model.TimeSearchOutput, error)
Search runs a Mattermost message search across the team. Terms support the usual modifiers: from:username, in:channel-name, after:YYYY-MM-DD, before:, on:, "exact phrase".
func (*Service) Thread ¶
Thread returns the root post and every reply of the thread containing postID.
func (*Service) Updates ¶
func (s *Service) Updates(ctx context.Context, in model.TimeUpdatesInput) (*model.TimeUpdatesOutput, error)
Updates collects new messages across channels. With in.Since == nil it returns what is unread for the user; otherwise every message posted after Since in channels with activity, read or not. Muted channels are listed in Skipped unless they mention the user or IncludeMuted is set.