storage

package
v0.0.0-...-f7e2f16 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConversationYAML

type ConversationYAML struct {
	Messages map[int]*MessageYAML `yaml:"messages"` // Messages.
}

ConversationYAML is a YAML model for conversation.

type Message

type Message struct {
	Side MessageSide // Conversation side.
	Text string      // Message text.
}

Message is a message in a conversation.

type MessageChain

type MessageChain struct {
	// contains filtered or unexported fields
}

MessageChain is a single conversation.

func (*MessageChain) Read

func (c *MessageChain) Read(messageID int) []Message

Store reads all messages from the conversation.

func (*MessageChain) Store

func (c *MessageChain) Store(msgID int, replyToID *int, side MessageSide, text string) error

Store writes new message into the conversation.

type MessageSide

type MessageSide string

MessageSide is a side of conversation.

const (
	Bot  MessageSide = "bot"  // Bot.
	User MessageSide = "user" // User.
)

type MessageYAML

type MessageYAML struct {
	ReplyTo *int        `yaml:"reply_to,omitempty"` // ID of message (if this one is a reply).
	Side    MessageSide `yaml:"side"`               // Conversation side.
	Text    string      `yaml:"text"`               // Message text.
}

MessageYAML is a YAML model for a message.

type RootYAML

type RootYAML struct {
	Conversations map[int64]*ConversationYAML `yaml:"conversations"` // Conversations.
}

RootYAML is a YAML model for data root.

type Storage

type Storage struct {
	// contains filtered or unexported fields
}

Storage stores conversation data.

func New

func New(filename string) (*Storage, error)

New creates new storage.

func (*Storage) TX

func (s *Storage) TX(userID int64, fn func(chain *MessageChain) error) error

TX runs a function within a transaction.

Jump to

Keyboard shortcuts

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