Archived
1
This repository has been archived on 2022-11-04. You can view files and clone it, but cannot push or open issues or pull requests.
fwzookeeper/internal/router/exported.go

40 lines
1.2 KiB
Go
Raw Normal View History

2018-11-29 20:32:51 +04:00
// Fantasy World Zookeeper Bot
// Copyright (c) 2018 Vladimir "fat0troll" Hodakov
package router
import (
"github.com/rs/zerolog"
"gitlab.com/toby3d/telegram"
2019-10-08 09:13:54 +04:00
"source.hodakov.me/fat0troll/fwzookeeper/context"
2018-11-29 20:32:51 +04:00
"regexp"
)
var (
c *context.Context
log zerolog.Logger
// Router is a struct which handles router functions
router struct {
privateCommands map[string]func(update *telegram.Update)
groupCommands map[string]func(update *telegram.Update)
privateRegulars map[*regexp.Regexp]func(update *telegram.Update)
groupRegulars map[*regexp.Regexp]func(update *telegram.Update)
inlineQueries map[*regexp.Regexp]func(update *telegram.Update)
}
2018-11-29 20:32:51 +04:00
)
// New initializes package
func New(cc *context.Context) {
c = cc
log = c.Logger.With().Str("domain", "router").Int("version", 1).Logger()
router.privateCommands = make(map[string]func(update *telegram.Update))
router.groupCommands = make(map[string]func(update *telegram.Update))
router.privateRegulars = make(map[*regexp.Regexp]func(update *telegram.Update))
router.groupRegulars = make(map[*regexp.Regexp]func(update *telegram.Update))
router.inlineQueries = make(map[*regexp.Regexp]func(update *telegram.Update))
2018-11-29 20:32:51 +04:00
log.Info().Msg("Initialized requests router")
}