models

package
v0.0.0-...-01159b3 Latest Latest
Warning

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

Go to latest
Published: May 7, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultState if sender don't have active topic or not in queue or just any message
	DefaultState = "default-state"
	// QueueState add user to queue when topic created but wait decision
	QueueState = "queue-state"
	// RoomState when support accept topic and start "chat" with user
	RoomState = "room-state"
	// UnknownState something wrong
	UnknownState = "unknown-state"
)
View Source
const (
	StartBotCommand   = "/start"
	BreakTopicCommand = "/break"
)
View Source
const (
	AcceptHelp  = "accept"
	DeclineHelp = "decline"
	NoRight     = "no_right"
	Rating      = "rating"
)
View Source
const (
	// BotWasBlockedError telegram api message
	BotWasBlockedError = "Forbidden: bot was blocked by the user"
)
View Source
const (
	TopicsTable = "public.topics"
)

Variables

View Source
var (
	ActiveTopic = 1
	ClosedTopic = 0
)

Functions

This section is empty.

Types

type CreateTopicAttrs

type CreateTopicAttrs struct {
	Message TopicMessage `json:"message" db:"-"`
	Creator TopicCreator `json:"creator" db:"-"`
}

type CreateTopicFeedbackAttrs

type CreateTopicFeedbackAttrs struct {
	*Topic
	Rating  uint8  `json:"rating"`
	Content string `json:"content"`
}

type FeedbackTemplatePayload

type FeedbackTemplatePayload struct {
	TicketId int64 `template:"TicketID"`
}

type MessageKey

type MessageKey string
const (
	// HelloMessageKey greeting message
	HelloMessageKey MessageKey = "hello"
	// QueueStartMessageKey user in queue state
	QueueStartMessageKey MessageKey = "queue_start"
	// RoomStartMessageKey user in room state
	RoomStartMessageKey MessageKey = "room_start"
	// GotTicketKey service got user question
	GotTicketKey MessageKey = "got_ticket"
	// NewTicketCreatedMessageKey send message to support group
	NewTicketCreatedMessageKey MessageKey = "new_ticket"
	// TicketAcceptedMessageKey when request accepted
	TicketAcceptedMessageKey MessageKey = "ticket_accepted"
	// TicketDeclinedMessageKey when request declined
	TicketDeclinedMessageKey MessageKey = "ticket_declined"
	// SuccessAcceptTicketMessageKey when help accepted
	SuccessAcceptTicketMessageKey MessageKey = "success_accept_ticket"
	// SuccessDeclineTicketMessageKey when help declined
	SuccessDeclineTicketMessageKey MessageKey = "success_decline_ticket"
	// AcceptTicketMessageKey accept help button text
	AcceptTicketMessageKey MessageKey = "accept_ticket"
	// DeclineTicketMessageKey decline help button text
	DeclineTicketMessageKey MessageKey = "decline_ticket"
	// NewTicketMessageKey new message topic (for user)
	NewTicketMessageKey MessageKey = "new_message"
	// NewTicketCommentMessageKey new comment (for support)
	NewTicketCommentMessageKey MessageKey = "new_comment"
	// CompletePrevTicketMessageKey suggestion for support
	CompletePrevTicketMessageKey MessageKey = "complete_last_ticket"
	// UserNoExpectHelpMessageKey if user already got help
	UserNoExpectHelpMessageKey MessageKey = "user_no_expect"
	// LeaveFeedbackMessageKey leave feedback message
	LeaveFeedbackMessageKey MessageKey = "leave_rating"
	// FeedbackSendMessageKey feedback send success
	FeedbackSendMessageKey MessageKey = "feedback_received"
	RatingOk               MessageKey = "rating_ok"
	RatingNormal           MessageKey = "rating_normal"
	RatingBad              MessageKey = "rating_bad"
	NoRating               MessageKey = "no_rating"
	TicketClosedMessageKey MessageKey = "ticket_end"
	NoRightMessageKey      MessageKey = "no_rights"
)

type TicketDecisionPayload

type TicketDecisionPayload struct {
	TicketId      int64  `template:"TicketID"`
	FromUserId    int64  `template:"FromUserID"`
	FromUsername  string `template:"FromUsername"`
	FromFirstName string `template:"FromFirstName"`
	Text          string `template:"Text"`
}

type TicketPayload

type TicketPayload struct {
	TicketId      int64  `template:"TicketID"`
	FromUsername  string `template:"FromUsername"`
	FromFirstName string `template:"FromFirstName"`
	Text          string `template:"Text"`
}

type Topic

type Topic struct {
	Id         int64        `json:"id"`
	Message    TopicMessage `json:"message" db:"-"`
	Creator    TopicCreator `json:"creator" db:"-"`
	Support    TopicSupport `json:"support"`
	FeedbackId string       `json:"f_id"`
	Status     int          `json:"status"`
	CreatedAt  time.Time    `json:"created_at"`
	UpdatedAt  time.Time    `json:"updated_at"`
}

func (*Topic) IsClosed

func (t *Topic) IsClosed() bool

func (*Topic) IsNeedFeedback

func (t *Topic) IsNeedFeedback() bool

type TopicCreator

type TopicCreator struct {
	TelegramId       int64  `json:"a_tid"`
	TelegramUsername string `json:"a_tun"`
	TelegramChatId   int64  `json:"c_tid" db:"-"`
}

type TopicFeedback

type TopicFeedback struct {
	CreateTopicFeedbackAttrs
	Id        string    `json:"id"`
	CreatedAt time.Time `json:"created_at"`
}

type TopicMessage

type TopicMessage struct {
	TelegramChatId    int64  `json:"c_tid" db:"-"`
	TelegramMessageId int    `json:"m_tid" db:"msg_id"`
	Question          string `json:"content" db:"content"`
}

type TopicRoom

type TopicRoom struct {
	Id        int64 `json:"topic_id"`
	From      int64 `json:"from_tid"`
	To        int64 `json:"to_tid"`
	IsSupport bool  `json:"is_s"`
}

type TopicSupport

type TopicSupport struct {
	UserId           string `json:"s_uid"`
	TelegramId       int64  `json:"s_tid"`
	TelegramUsername string `json:"s_tun"`
	TelegramChatId   int64  `json:"c_tid" db:"-"`
}

type TopicTable

type TopicTable struct {
	Id                      int64       `db:"id"`
	FeedbackId              pgtype.Text `db:"feedback_id"`
	AuthorTelegramId        int64       `db:"author_tid"`
	AuthorTelegramUsername  string      `db:"author_tun"`
	SupportTelegramId       int64       `db:"support_tid"`
	SupportTelegramUsername pgtype.Text `db:"support_tun"`
	MessageTelegramId       int         `db:"msg_tid"`
	MessageContent          string      `db:"content"`
	Status                  int         `db:"status"`
	CreatedAt               time.Time   `db:"created_at"`
	UpdatedAt               time.Time   `db:"updated_at"`
}

type UserInfoPayload

type UserInfoPayload struct {
	Username string `template:"Username"`
}

type UserMessage

type UserMessage struct {
	TelegramMessageId int    `json:"m_tid"`
	TelegramUserId    int64  `json:"u_tid"`
	ChatId            int64  `json:"chat_id"`
	Content           string `json:"content"`
}

type UserOptions

type UserOptions struct {
	TelegramId int64  `json:"t_id"`
	ChatId     int64  `json:"chat_id"`
	Lang       string `json:"lang"`
}

func (*UserOptions) SaveLang

func (uo *UserOptions) SaveLang(lang string)

Jump to

Keyboard shortcuts

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