Skip to content

Commit

Permalink
chore: rename triggerMessage -> lastCallback
Browse files Browse the repository at this point in the history
  • Loading branch information
damonto committed Sep 21, 2023
1 parent d1381d9 commit 64c6e7a
Showing 1 changed file with 18 additions and 18 deletions.
36 changes: 18 additions & 18 deletions handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,17 @@ type Handler interface {
}

type handler struct {
chatId int64
isEuicc bool
tgbot *tgbotapi.BotAPI
modem Modem
botHandlers map[string]botHandler
triggeredMessage triggeredMessage
nextAction NextFunc
messages map[int]*tgbotapi.Message
chatId int64
isEuicc bool
tgbot *tgbotapi.BotAPI
modem Modem
botHandlers map[string]botHandler
lastCallback lastCallback
nextAction NextFunc
messages map[int]*tgbotapi.Message
}

type triggeredMessage struct {
type lastCallback struct {
callback *tgbotapi.CallbackQuery
value string
}
Expand All @@ -47,12 +47,12 @@ type botHandler struct {

func NewHandler(chatId int64, isEuicc bool, tgbot *tgbotapi.BotAPI, modem Modem) Handler {
return &handler{
chatId: chatId,
isEuicc: isEuicc,
tgbot: tgbot,
modem: modem,
messages: make(map[int]*tgbotapi.Message, 1),
triggeredMessage: triggeredMessage{},
chatId: chatId,
isEuicc: isEuicc,
tgbot: tgbot,
modem: modem,
messages: make(map[int]*tgbotapi.Message, 1),
lastCallback: lastCallback{},
}
}

Expand Down Expand Up @@ -125,7 +125,7 @@ func (h *handler) HandleRawMessage(message *tgbotapi.Message) error {
if h.nextAction == nil {
return errors.New("undefined next action")
}
return h.nextAction(message, h.triggeredMessage.callback, h.triggeredMessage.value)
return h.nextAction(message, h.lastCallback.callback, h.lastCallback.value)
}

func (h *handler) handleStartCommand(message *tgbotapi.Message) error {
Expand Down Expand Up @@ -619,7 +619,7 @@ func (h *handler) handleRenameProfileCallback(callback *tgbotapi.CallbackQuery,
return err
}

h.triggeredMessage = triggeredMessage{
h.lastCallback = lastCallback{
callback: callback,
value: value,
}
Expand All @@ -638,7 +638,7 @@ func (h *handler) renameProfile(message *tgbotapi.Message, callback *tgbotapi.Ca
}

// clean
h.triggeredMessage = triggeredMessage{}
h.lastCallback = lastCallback{}
h.nextAction = nil

return h.sendText(message.Chat.ID, "The profile name has been changed.", callback.Message.MessageID)
Expand Down

0 comments on commit 64c6e7a

Please sign in to comment.