app

package
v0.0.0-...-51aff30 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2020 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ReqTypeText = map[ReqType]string{
	Confirm:       "confirmation",
	MessageTyping: "message_typing_state",
	MessageNew:    "message_new",
}

Functions

func GetReason

func GetReason(s string) (string, error)

func ParseRoll

func ParseRoll(s string) (int64, int64, int64, bool)

func SendMessage

func SendMessage(method string, params map[string]string, c config.Config) ([]byte, error)

func SplitRollWithAdder

func SplitRollWithAdder(s string) (int64, int64, int64)

func SplitRollWithSubtr

func SplitRollWithSubtr(s string) (int64, int64, int64)

Types

type CreateResult

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

func (*CreateResult) Comment

func (h *CreateResult) Comment() string

func (*CreateResult) HTML

func (h *CreateResult) HTML() string

func (*CreateResult) VKString

func (h *CreateResult) VKString() string

type ErrorResult

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

func NewErrorResult

func NewErrorResult(err error) *ErrorResult

func (*ErrorResult) Comment

func (h *ErrorResult) Comment() string

func (*ErrorResult) HTML

func (h *ErrorResult) HTML() string

func (*ErrorResult) VKString

func (h *ErrorResult) VKString() string

type HelpResult

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

func (*HelpResult) Comment

func (h *HelpResult) Comment() string

func (*HelpResult) HTML

func (h *HelpResult) HTML() string

func (*HelpResult) VKString

func (h *HelpResult) VKString() string

type Maloi

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

func (*Maloi) Comment

func (h *Maloi) Comment() string

func (*Maloi) HTML

func (h *Maloi) HTML() string

func (*Maloi) VKString

func (h *Maloi) VKString() string

type PResult

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

type PercentResult

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

func (*PercentResult) Comment

func (h *PercentResult) Comment() string

func (*PercentResult) HTML

func (h *PercentResult) HTML() string

func (*PercentResult) VKString

func (h *PercentResult) VKString() string

type ReqType

type ReqType uint8
const (
	UnknownReqType ReqType = iota
	Confirm
	MessageTyping
	MessageNew
)

func (*ReqType) UnmarshalJSON

func (rt *ReqType) UnmarshalJSON(data []byte) error

type Resulter

type Resulter interface {
	HTML() string
	VKString() string
	Comment() string
}

type RollBot

type RollBot struct {
	Config    config.Config
	DB        storage.Storage
	Generator *generator.Generator
}

func CreateRollBot

func CreateRollBot(conf config.Config, store storage.Storage) *RollBot

func (*RollBot) CreateCharacteristics

func (app *RollBot) CreateCharacteristics() ([]characteristic, error)

func (*RollBot) CreateCommand

func (app *RollBot) CreateCommand(vk VKReq) (Resulter, error)

func (*RollBot) FindUser

func (rb *RollBot) FindUser(userId int) (string, error)

func (*RollBot) GetCharacter

func (rb *RollBot) GetCharacter(w http.ResponseWriter, req *http.Request)

func (*RollBot) GetHistory

func (rb *RollBot) GetHistory(w http.ResponseWriter, req *http.Request)

func (*RollBot) GetUserHistory

func (rb *RollBot) GetUserHistory(w http.ResponseWriter, req *http.Request)

func (*RollBot) GetUsers

func (rb *RollBot) GetUsers(w http.ResponseWriter, req *http.Request)

func (*RollBot) HelpCommand

func (app *RollBot) HelpCommand(vk VKReq) (Resulter, error)

func (*RollBot) Homepage

func (rb *RollBot) Homepage(w http.ResponseWriter, req *http.Request)

func (*RollBot) ParseCommand

func (app *RollBot) ParseCommand(vkr *VKReq) (func(VKReq) (Resulter, error), error)

func (*RollBot) PercentCommand

func (app *RollBot) PercentCommand(vk VKReq) (Resulter, error)

func (*RollBot) RollCommand

func (app *RollBot) RollCommand(vk VKReq) (Resulter, error)

func (*RollBot) RollMaloi

func (app *RollBot) RollMaloi(vk VKReq) (Resulter, error)

func (RollBot) SendResult

func (rb RollBot) SendResult(vkr *VKReq, text string) error

func (*RollBot) VKHandle

func (rb *RollBot) VKHandle(w http.ResponseWriter, req *http.Request)

type RollResult

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

func (*RollResult) Comment

func (r *RollResult) Comment() string

func (*RollResult) HTML

func (r *RollResult) HTML() string

func (*RollResult) VKString

func (r *RollResult) VKString() string

type UserResponse

type UserResponse struct {
	Response []struct {
		ID              int    `json:"id"`
		FirstName       string `json:"first_name"`
		LastName        string `json:"last_name"`
		IsClosed        bool   `json:"is_closed"`
		CanAccessClosed bool   `json:"can_access_closed"`
	} `json:"response"`
}

type VKReq

type VKReq struct {
	Type   ReqType `json:"type"`
	Object struct {
		Message struct {
			Date                  int           `json:"date"`
			FromID                int           `json:"from_id"`
			ID                    int           `json:"id"`
			Out                   int           `json:"out"`
			PeerID                int           `json:"peer_id"`
			Text                  string        `json:"text"`
			ConversationMessageID int           `json:"conversation_message_id"`
			FwdMessages           []interface{} `json:"fwd_messages"`
			Important             bool          `json:"important"`
			RandomID              int           `json:"random_id"`
			Attachments           []interface{} `json:"attachments"`
			IsHidden              bool          `json:"is_hidden"`
		} `json:"message"`
		ClientInfo struct {
			ButtonActions  []string `json:"button_actions"`
			Keyboard       bool     `json:"keyboard"`
			InlineKeyboard bool     `json:"inline_keyboard"`
			Carousel       bool     `json:"carousel"`
			LangID         int      `json:"lang_id"`
		} `json:"client_info"`
	} `json:"object"`
	GroupID int    `json:"group_id"`
	EventID string `json:"event_id"`
	Secret  string `json:"secret"`
}

func (*VKReq) RemoveQuotesAndCheckIsCommand

func (vkr *VKReq) RemoveQuotesAndCheckIsCommand() bool

Jump to

Keyboard shortcuts

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