37 lines
1.1 KiB
Go
37 lines
1.1 KiB
Go
package main
|
|
|
|
import (
|
|
neco "git.nefrace.ru/nefrace/nechotron"
|
|
)
|
|
|
|
var MainState = neco.State{
|
|
Fn: func(u *neco.Update) error {
|
|
adminDispatcher := neco.NewDispatcher().
|
|
HandleCallback(neco.CallbackExact("delete"), handleDeleteCallback).
|
|
HandleCommand(commandSay, handleSay).
|
|
HandleCommand(commandFeed, handleRegisterFeed).
|
|
HandleCommand(commandFeedUnsub, handleDeleteFeed).
|
|
HandleFilter(isFile, handleUsersImport)
|
|
adminOnly := neco.NewDispatcher().
|
|
HandleFilter(neco.IsUserAdmin, adminDispatcher.Run)
|
|
|
|
mainCommands := neco.NewDispatcher().
|
|
HandleCommand(commandMe, handleMe).
|
|
HandleCommand(commandHelp, handleHelp).
|
|
HandleCommand(commandTop, handleTop)
|
|
|
|
replyDispatcher := neco.NewDispatcher().
|
|
HandleFilter(karmaTriggers, handleKarma)
|
|
replies := neco.NewDispatcher().
|
|
HandleFilter(neco.IsReply, replyDispatcher.Run)
|
|
|
|
docs := neco.NewDispatcher().
|
|
HandleFilter(docRequest, handleDocRequest).
|
|
HandleCallback(neco.CallbackPrefix("docs"), handleDocCallback)
|
|
|
|
// triggers := neco.NewDispatcher()
|
|
|
|
return neco.RunEach(u, mainCommands, replies, docs, adminOnly)
|
|
},
|
|
}
|