go-dette/main.go

34 lines
967 B
Go

package main
import (
"log"
"os"
"git.nefrace.ru/nefrace/nechotron"
"git.nefrace.ru/nefrace/tongo"
"github.com/NicoNex/echotron/v3"
"github.com/joho/godotenv"
)
var BuildTime string
func main() {
godotenv.Load()
db, err := tongo.NewConnection(os.Getenv("MONGO_URI"), "godette")
if err != nil {
log.Fatalf("Can't connect to database: %v", err)
}
token := os.Getenv("TELEGRAM_TOKEN")
neco := nechotron.NewTron(token, &MainState)
neco.
Use(UserDBUpdater(db)).
Use(ErrorLogger)
api := echotron.NewAPI(token)
defaultCommands := []*nechotron.Command{commandHelp, commandMe}
adminCommands := []*nechotron.Command{commandSay, commandWarn}
allCommands := append(defaultCommands, adminCommands...)
nechotron.SetMyCommands(api, "", echotron.BotCommandScope{Type: echotron.Any}, defaultCommands...)
nechotron.SetMyCommands(api, "", echotron.BotCommandScope{Type: echotron.BCSTAllChatAdministrators}, allCommands...)
log.Fatal(neco.DispatchPoll())
}