go-dette/states.go

30 lines
1.0 KiB
Go

package main
import (
neco "git.nefrace.ru/nefrace/nechotron"
)
var MainState = neco.State{
Fn: func(u *neco.Update) error {
callbackDispatcher := neco.NewDispatcher().
HandleCallback(neco.CallbackExact("delete"), handleDeleteCallback)
// HandleCallback(neco.CallbackPrefix("docs3"), handleDocRequest3)
adminOnly := neco.NewDispatcher().
HandleFilter(neco.IsUserAdmin, callbackDispatcher.Run)
mainCommands := neco.NewDispatcher().
HandleCommand(commandMe, handleMe).
HandleCommand(commandHelp, handleHelp).
HandleCommand(commandSay, handleSay)
replyDispatcher := neco.NewDispatcher().
HandleCommand(commandWarn, handleWarn).
HandleFilter(karmaTriggers, handleKarma)
replies := neco.NewDispatcher().
HandleFilter(neco.IsReply, replyDispatcher.Run)
docs := neco.NewDispatcher().
HandleFilter(docRequest, handleDocRequest)
triggers := neco.NewDispatcher().
HandleFilter(offtopTrigger, handleOfftop)
return neco.ChainRun(u, mainCommands, replies, docs, adminOnly, triggers)
},
}