timechat

package
v0.1.10 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2026 License: MIT Imports: 12 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
const (
	DefaultChannelLimit  = 30
	MaxChannelLimit      = 200
	DefaultSearchLimit   = 20
	MaxSearchLimit       = 100
	DefaultPerChannelCap = 20
)

Variables

View Source
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

func ParseKind

func ParseKind(s string) ([]model.TimeChannelKind, error)

ParseKind maps a user-facing kind ("dm", "group", "public", "private", "all", "") to a filter; nil means every kind.

func ParseSince

func ParseSince(raw string, now time.Time) (*time.Time, error)

ParseSince accepts a relative duration ("24h", "90m", "3d"), a date ("2026-10-29"), a local "2026-10-29 18:00", or RFC 3339. Empty means nil.

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

type Connector func() (Client, error)

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 New

func New(connect Connector, teamName string) *Service

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

func (s *Service) ResolveChannel(ctx context.Context, query string) (*model.TimeChannel, error)

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

func (s *Service) Thread(ctx context.Context, postID string) (*model.TimeChannelPosts, error)

Thread returns the root post and every reply of the thread containing postID.

func (*Service) Updates

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.

Jump to

Keyboard shortcuts

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