Documentation ¶
Overview ¶
Package tgchain has chained wrapper for handling tg updates
Index ¶
- func GetEventName(eventID EventType) string
- type AbstractHandler
- func (h *AbstractHandler) Decorate(next IEventHandler)
- func (h *AbstractHandler) GetDescription() (descr string)
- func (h *AbstractHandler) GetName() string
- func (h *AbstractHandler) Next(ctx context.Context, upd tgbotapi.Update) error
- func (h *AbstractHandler) ReplyToMsg(msg *tgbotapi.Message, text string, api ITgAPI) (err error)
- type CtxEventKeyType
- type ErrUpd
- type EventType
- type IEventHandler
- type IListener
- type ITgAPI
- type Listener
- type WarnUpd
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetEventName ¶
GetEventName return event name by it's ID.
Types ¶
type AbstractHandler ¶
type AbstractHandler struct {
// contains filtered or unexported fields
}
AbstractHandler is a abstract event handler.
func (*AbstractHandler) Decorate ¶
func (h *AbstractHandler) Decorate(next IEventHandler)
Decorate is a setter for next handler.
func (*AbstractHandler) GetDescription ¶
func (h *AbstractHandler) GetDescription() (descr string)
GetDescription returns handler description.
func (*AbstractHandler) GetName ¶
func (h *AbstractHandler) GetName() string
GetName returns handler name.
func (*AbstractHandler) ReplyToMsg ¶
ReplyToMsg sends reply to tg message.
type CtxEventKeyType ¶
type CtxEventKeyType int
CtxEventKeyType is a type for event name in context.
const ( // CtxEventKey context key for storing event type ID. CtxEventKey CtxEventKeyType = iota )
type EventType ¶
type EventType int
EventType variable type for event type ID.
const ( // EventUndefined undefined event. EventUndefined EventType = iota // EventMessage receiving message event. EventMessage // EventCommand receiving command event. EventCommand // EventInlineQuery receiving inline query event. EventInlineQuery // EventCallbackQuery receiving callback query event. EventCallbackQuery )
func GetEventFrom ¶
GetEventFrom return event type from tg update.
func GetEventFromCtx ¶
GetEventFromCtx return event ID from context struct.
type IEventHandler ¶
type IEventHandler interface { GetName() string GetDescription() string Decorate(IEventHandler) Next(context.Context, tgbotapi.Update) error Handle(context.Context, tgbotapi.Update) error }
IEventHandler is event handler interface.
type IListener ¶
type IListener interface { Add(EventType, ...IEventHandler) IListener Listen(context.Context, tgbotapi.UpdatesChannel) }
IListener is a tg updates listener interface.
type ITgAPI ¶
type ITgAPI interface { GetUpdatesChan(tgbotapi.UpdateConfig) (tgbotapi.UpdatesChannel, error) Send(tgbotapi.Chattable) (tgbotapi.Message, error) GetMe() (tgbotapi.User, error) GetChatMember(tgbotapi.ChatConfigWithUser) (tgbotapi.ChatMember, error) LeaveChat(tgbotapi.ChatConfig) (tgbotapi.APIResponse, error) AnswerInlineQuery(tgbotapi.InlineConfig) (tgbotapi.APIResponse, error) }
ITgAPI is interface for Telegram API instance.
type Listener ¶
type Listener struct {
// contains filtered or unexported fields
}
Listener is struct which is listening and handling events.
func NewListener ¶
NewListener constructor for Listener struct.