handlers

package
v0.0.0-...-9e7b976 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2017 License: MIT Imports: 19 Imported by: 1

Documentation

Index

Constants

View Source
const (
	UserStatsURL     = "/stats"
	MaxFailedUpdates = 100
	UpdateTimeout    = 3 * time.Second

	CommandType  = "command"
	PictureType  = "picture"
	DocumentType = "doc"
)

Variables

View Source
var (
	UserKey       key = "user"
	UpdateTypeKey key = "uptype"
	UpdateKey     key = "update"
	MessageKey    key = "message"
)
View Source
var (
	ErrUnexpectedCommand = errors.New("unexpected command")
	ErrRequestTimeout    = errors.New("request timeout")
	CommandsMatcher      *regexp.Regexp
)

Functions

func AddSubscription

func AddSubscription(user *TGBotAPI.User, chat *TGBotAPI.Chat) (err error)

func BotCommandRouter

func BotCommandRouter(message *TGBotAPI.Message) error

func BotRouter

func BotRouter(next http.Handler) http.Handler

func BotUpdateHandler

func BotUpdateHandler(w http.ResponseWriter, req *http.Request)

func BuildUserStatURL

func BuildUserStatURL(token string) string

func ExtractUpdate

func ExtractUpdate(next http.Handler) http.HandlerFunc

func GetChatTags

func GetChatTags(w http.ResponseWriter, req *http.Request)

func GetChats

func GetChats(w http.ResponseWriter, req *http.Request)

func GetImages

func GetImages(w http.ResponseWriter, req *http.Request)

func GetUserTags

func GetUserTags(w http.ResponseWriter, req *http.Request)

func MiddlewareLogin

func MiddlewareLogin(next http.Handler) http.Handler

func SetUserToken

func SetUserToken(userId int) (string, error)

Types

type ChatsJSON

type ChatsJSON struct {
	Err   string        `json:"error"`
	Chats []models.Chat `json:"chats"`
}

func (*ChatsJSON) Response

func (cj *ChatsJSON) Response(w http.ResponseWriter, r *http.Request, status int)

type ImagesJSON

type ImagesJSON struct {
	Err          string         `json:"error"`
	ImagesPrefix string         `json:"images_prefix, omitempty"`
	Images       []models.Image `json:"images"`
}

func (*ImagesJSON) Response

func (ij *ImagesJSON) Response(w http.ResponseWriter, r *http.Request, status int)

type TagsJSON

type TagsJSON struct {
	Err  string       `json:"error"`
	Tags []models.Tag `json:"tags"`
}

func (*TagsJSON) Response

func (tj *TagsJSON) Response(w http.ResponseWriter, r *http.Request, status int)

type UserJSON

type UserJSON struct {
	Err  string       `json:"error,omitempty"`
	User *models.User `json:"entity,omitempty"`
}

func (*UserJSON) Response

func (uj *UserJSON) Response(w http.ResponseWriter, r *http.Request, status int)

Jump to

Keyboard shortcuts

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