go-dette/main.go

34 lines
967 B
Go
Raw Normal View History

2023-01-19 23:12:55 +03:00
package main
import (
"log"
"os"
2023-01-20 00:30:21 +03:00
"git.nefrace.ru/nefrace/nechotron"
"git.nefrace.ru/nefrace/tongo"
2023-01-24 03:11:15 +03:00
"github.com/NicoNex/echotron/v3"
"github.com/joho/godotenv"
2023-01-19 23:12:55 +03:00
)
2023-01-24 00:37:27 +03:00
var BuildTime string
2023-01-19 23:12:55 +03:00
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)
}
2023-01-24 03:11:15 +03:00
token := os.Getenv("TELEGRAM_TOKEN")
neco := nechotron.NewTron(token, &MainState)
neco.
Use(UserDBUpdater(db)).
2023-01-24 03:11:15 +03:00
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...)
2023-01-24 00:37:27 +03:00
log.Fatal(neco.DispatchPoll())
2023-01-19 23:12:55 +03:00
}