Refactor post handling and add command setup for Telegram bot

This commit is contained in:
dela
2026-02-05 00:52:29 +08:00
parent d82badc6e3
commit 8a6859269c
9 changed files with 612 additions and 21 deletions

View File

@@ -12,6 +12,7 @@ type PostStep int
const (
StepAwaitForward PostStep = iota
StepAwaitCategory
StepAwaitTitle
StepAwaitConfirm
)
@@ -19,6 +20,7 @@ type PostState struct {
UserID int64
ForwardedMsg *tele.Message
SelectedCat string
Title string
Step PostStep
CreatedAt time.Time
}
@@ -86,6 +88,20 @@ func (sm *StateManager) SetCategory(userID int64, category string) *PostState {
}
state.SelectedCat = category
state.Step = StepAwaitTitle
return state
}
func (sm *StateManager) SetTitle(userID int64, title string) *PostState {
sm.mu.Lock()
defer sm.mu.Unlock()
state := sm.states[userID]
if state == nil {
return nil
}
state.Title = title
state.Step = StepAwaitConfirm
return state
}