telegram: add callback handler

This commit is contained in:
c9s 2022-01-17 20:48:05 +08:00
parent ad3f038dc6
commit 2cf29bd1ec
2 changed files with 13 additions and 0 deletions

View File

@ -97,6 +97,10 @@ func (it *Interact) getNextState(session Session, currentState State) (nextState
return session.GetOriginState(), final
}
func (it *Interact) handleCallback(session Session, payload string) error {
return nil
}
func (it *Interact) handleResponse(session Session, text string, ctxObjects ...interface{}) error {
// We only need response when executing a command
switch session.GetState() {

View File

@ -119,6 +119,15 @@ func (tm *Telegram) SetTextMessageResponder(textMessageResponder Responder) {
}
func (tm *Telegram) Start(context.Context) {
tm.Bot.Handle(telebot.OnCallback, func(c *telebot.Callback) {
log.Infof("[telegram] onCallback: %+v", c)
if c.Message != nil {
session := tm.loadSession(c.Message)
_ = session
}
// c.Sender
})
tm.Bot.Handle(telebot.OnText, func(m *telebot.Message) {
log.Infof("[telegram] onText: %+v", m)