cli

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddAccountIDs

func AddAccountIDs(params url.Values, accountIDs string)

func AddCSVParam

func AddCSVParam(params url.Values, key, csv string)

func ConfirmPrompt

func ConfirmPrompt(r io.Reader, w io.Writer, prompt string) (bool, error)

func FilterChats

func FilterChats(chats []api.Chat, unreadOnly, mutedOnly, pinnedOnly, archivedOnly bool, typeFilter string) []api.Chat

func FilterUnreadMessages

func FilterUnreadMessages(messages []api.Message, unreadOnly bool) []api.Message

func FormatMessageLine

func FormatMessageLine(m api.Message, otherName string) string

func FormatTime

func FormatTime(t time.Time) string

func LimitSlice

func LimitSlice[T any](items []T, limit int) []T

func LooksLikeChatID

func LooksLikeChatID(s string) bool

LooksLikeChatID returns true if the string looks like a chat ID rather than a name.

func MessageDisplayText

func MessageDisplayText(m api.Message) string

func MessageSender

func MessageSender(m api.Message) string

func MessageSenderDisplay

func MessageSenderDisplay(m api.Message, otherName string) string

func MinInt

func MinInt(a, b int) int

func NewestSortKey

func NewestSortKey(messages []api.Message) string

func NormalizeDateAfter

func NormalizeDateAfter(value string) string

func OldestSortKey

func OldestSortKey(messages []api.Message) string

func OtherChatName

func OtherChatName(chat api.Chat) string

func Poll

func Poll(ctx context.Context, interval time.Duration, fn func(context.Context) error, onError func(error) bool) error

Poll runs fn every interval until the context is canceled. If onError is nil, any error from fn stops polling. If onError returns true, polling continues after an error.

func PrintMessageLine

func PrintMessageLine(w io.Writer, m api.Message, otherName string)

func ReadFile

func ReadFile(path string) (string, error)

func ReadStdin

func ReadStdin(r io.Reader) (string, error)

func ResolveChatByName

func ResolveChatByName(ctx context.Context, client *api.Client, accountIDs string, name string, opts ChatResolveOptions, warn io.Writer) (string, error)

ResolveChatByName searches for a chat by name and returns its ID. If multiple matches are found, it errors unless First is set.

func ResolveChatIDFromArgOrFlag

func ResolveChatIDFromArgOrFlag(ctx context.Context, client *api.Client, accountIDs string, args []string, flagValue, flagName string, opts ChatResolveOptions, warn io.Writer) (string, error)

ResolveChatIDFromArgOrFlag resolves a chat ID using either a flag value (chat name) or a positional chat ID argument.

func ResolveChatIDFromFlags

func ResolveChatIDFromFlags(ctx context.Context, client *api.Client, accountIDs string, nameFlag, idFlag, nameLabel, idLabel string, opts ChatResolveOptions, warn io.Writer) (string, error)

ResolveChatIDFromFlags resolves a chat ID using either a chat name or explicit chat ID flag.

func ResolveMessageInput

func ResolveMessageInput(text string, stdin bool, file string, in io.Reader) (string, error)

func SenderName

func SenderName(senderID string) string

func SortMessagesByTime

func SortMessagesByTime(messages []api.Message) []api.Message

func TailSlice

func TailSlice[T any](items []T, limit int) []T

func Truncate

func Truncate(s string, max int) string

Types

type ChatResolveOptions

type ChatResolveOptions struct {
	Exact bool
	First bool
	DM    bool
}

type NameFlags

type NameFlags struct {
	Name  string
	Exact bool
	First bool
	DM    bool
}

func AddNameFlags

func AddNameFlags(cmd *cobra.Command, flagName, description string, includeDM bool) *NameFlags

func (*NameFlags) ResolveOptions

func (f *NameFlags) ResolveOptions() ChatResolveOptions

Jump to

Keyboard shortcuts

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