chathistories

package
v0.24.0 Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2024 License: MIT Imports: 33 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var RecapOutputTemplate = lo.Must(template.
	New("recap output markdown template").
	Funcs(template.FuncMap{
		"join":   strings.Join,
		"sub":    func(a, b int) int { return a - b },
		"add":    func(a, b int) int { return a + b },
		"escape": tgbot.EscapeHTMLSymbols,
	}).
	Parse(`{{ $chatID := .ChatID }}{{ if .Recap.SinceID }}## <a href="https://t.me/c/{{ $chatID }}/{{ .Recap.SinceID }}">{{ escape .Recap.TopicName }}</a>{{ else }}## {{ escape .Recap.TopicName }}{{ end }}
参与人:{{ join .Recap.Participants "," }}
讨论:{{ range $di, $d := .Recap.Discussion }}
 - {{ escape $d.Point }}{{ if len $d.KeyIDs }} {{ range $cIndex, $c := $d.KeyIDs }}<a href="https://t.me/c/{{ $chatID }}/{{ $c }}">[{{ add $cIndex 1 }}]</a>{{ if not (eq $cIndex (sub (len $d.KeyIDs) 1)) }} {{ end }}{{ end }}{{ end }}{{ end }}{{ if .Recap.Conclusion }}
结论:{{ escape .Recap.Conclusion }}{{ end }}`))
View Source
var RecapWithoutLinksOutputTemplate = lo.Must(template.
	New("recap output markdown template").
	Funcs(template.FuncMap{
		"join":   strings.Join,
		"sub":    func(a, b int) int { return a - b },
		"add":    func(a, b int) int { return a + b },
		"escape": tgbot.EscapeHTMLSymbols,
	}).
	Parse(`{{ $chatID := .ChatID }}{{ if .Recap.SinceID }}## {{ escape .Recap.TopicName }}{{ else }}## {{ escape .Recap.TopicName }}{{ end }}
参与人:{{ join .Recap.Participants "," }}
讨论:{{ range $di, $d := .Recap.Discussion }}
 - {{ escape $d.Point }}{{ end }}{{ if .Recap.Conclusion }}
结论:{{ escape .Recap.Conclusion }}{{ end }}`))

Functions

func NewModel

func NewModel() func(NewModelParams) (*Model, error)

Types

type FeedbackChatHistoriesRecapsReactionsCounts added in v0.19.0

type FeedbackChatHistoriesRecapsReactionsCounts struct {
	UpVotes   int
	DownVotes int
	Lmao      int
}

type FromPlatform

type FromPlatform int
const (
	FromPlatformTelegram FromPlatform = iota
)

type Model

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

func (*Model) DeleteAllChatHistoriesByChatID added in v0.17.0

func (m *Model) DeleteAllChatHistoriesByChatID(chatID int64) error

func (*Model) DisableRecapForwardedFromPrivateMessages added in v0.14.0

func (m *Model) DisableRecapForwardedFromPrivateMessages(userID int64) error

func (*Model) EnabledRecapForwardedFromPrivateMessages added in v0.14.0

func (m *Model) EnabledRecapForwardedFromPrivateMessages(userID int64) error

func (*Model) ExtractTextFromMessage

func (m *Model) ExtractTextFromMessage(message *tgbotapi.Message) string

func (*Model) FeedbackRecapsReactToChatIDAndLogID added in v0.19.0

func (m *Model) FeedbackRecapsReactToChatIDAndLogID(chatID int64, logID uuid.UUID, userID int64, reactionType feedbackchathistoriesrecapsreactions.Type) error

func (*Model) FindChatHistoriesByTimeBefore

func (m *Model) FindChatHistoriesByTimeBefore(chatID int64, before time.Duration) ([]*ent.ChatHistories, error)

func (*Model) FindFeedbackRecapsReactionCountsForChatIDAndLogID added in v0.19.0

func (m *Model) FindFeedbackRecapsReactionCountsForChatIDAndLogID(chatID int64, logID uuid.UUID) (FeedbackChatHistoriesRecapsReactionsCounts, error)

func (*Model) FindLast12HourChatHistories added in v0.23.2

func (m *Model) FindLast12HourChatHistories(chatID int64) ([]*ent.ChatHistories, error)

func (*Model) FindLast6HourChatHistories added in v0.23.2

func (m *Model) FindLast6HourChatHistories(chatID int64) ([]*ent.ChatHistories, error)

func (*Model) FindLast8HourChatHistories added in v0.23.2

func (m *Model) FindLast8HourChatHistories(chatID int64) ([]*ent.ChatHistories, error)

func (*Model) FindLastOneHourChatHistories

func (m *Model) FindLastOneHourChatHistories(chatID int64) ([]*ent.ChatHistories, error)

func (*Model) FindPrivateForwardedChatHistories added in v0.14.0

func (m *Model) FindPrivateForwardedChatHistories(userID int64) ([]telegramPrivateForwardedReplayChatHistory, error)

func (*Model) HasOngoingRecapForwardedFromPrivateMessages added in v0.14.0

func (m *Model) HasOngoingRecapForwardedFromPrivateMessages(userID int64) (bool, error)

func (*Model) MigrateChatHistoriesOfChatFromChatIDToChatID added in v0.20.0

func (m *Model) MigrateChatHistoriesOfChatFromChatIDToChatID(fromChatID, toChatID int64) error

func (*Model) NewFeedbackRecapsDownVoteButton added in v0.19.0

func (m *Model) NewFeedbackRecapsDownVoteButton(bot *tgbot.Bot, chatID int64, logID uuid.UUID, downVoteCount int) (tgbotapi.InlineKeyboardButton, error)

func (*Model) NewFeedbackRecapsLmaoButton added in v0.19.0

func (m *Model) NewFeedbackRecapsLmaoButton(bot *tgbot.Bot, chatID int64, logID uuid.UUID, downVoteCount int) (tgbotapi.InlineKeyboardButton, error)

func (*Model) NewFeedbackRecapsUpVoteButton added in v0.19.0

func (m *Model) NewFeedbackRecapsUpVoteButton(bot *tgbot.Bot, chatID int64, logID uuid.UUID, upVoteCount int) (tgbotapi.InlineKeyboardButton, error)

func (*Model) NewVoteRecapInlineKeyboardMarkup added in v0.19.0

func (m *Model) NewVoteRecapInlineKeyboardMarkup(bot *tgbot.Bot, chatID int64, logID uuid.UUID, upVoteCount int, downVoteCount int, lmaoCount int) (tgbotapi.InlineKeyboardMarkup, error)

func (*Model) NewVoteRecapWithUnsubscribeInlineKeyboardMarkup added in v0.19.0

func (m *Model) NewVoteRecapWithUnsubscribeInlineKeyboardMarkup(bot *tgbot.Bot, chatID int64, chatTitle string, fromID int64, logID uuid.UUID, upVoteCount int, downVoteCount int, lmaoCount int) (tgbotapi.InlineKeyboardMarkup, error)

func (*Model) SaveOneTelegramChatHistory

func (m *Model) SaveOneTelegramChatHistory(message *tgbotapi.Message) error

func (*Model) SaveOneTelegramPrivateForwardedReplayChatHistory added in v0.14.0

func (m *Model) SaveOneTelegramPrivateForwardedReplayChatHistory(message *tgbotapi.Message) error

func (*Model) SummarizeChatHistories

func (m *Model) SummarizeChatHistories(chatID int64, chatType telegram.ChatType, histories []*ent.ChatHistories) (uuid.UUID, []string, error)

func (*Model) SummarizePrivateForwardedChatHistories added in v0.14.0

func (m *Model) SummarizePrivateForwardedChatHistories(userID int64, histories []telegramPrivateForwardedReplayChatHistory) ([]string, error)

func (*Model) UpdateOneTelegramChatHistory

func (m *Model) UpdateOneTelegramChatHistory(message *tgbotapi.Message) error

type NewModelParams

type NewModelParams struct {
	fx.In

	Lifecycle fx.Lifecycle

	Config *configs.Config
	Logger *logger.Logger
	Ent    *datastore.Ent
	OpenAI openai.Client
	Redis  *datastore.Redis
}

type RecapOutputTemplateInputs

type RecapOutputTemplateInputs struct {
	ChatID string
	Recap  *openai.ChatHistorySummarizationOutputs
}

type RecapType added in v0.14.0

type RecapType int
const (
	RecapTypeForGroup RecapType = iota
	RecapTypeForPrivateForwarded
)

Jump to

Keyboard shortcuts

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