You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
41 lines
908 B
41 lines
908 B
package main
|
|
|
|
import (
|
|
"context"
|
|
"log"
|
|
"os"
|
|
"os/signal"
|
|
"strings"
|
|
"syscall"
|
|
|
|
"git.aiterp.net/rpdata/logbot3/internal/bot"
|
|
"git.aiterp.net/rpdata/logbot3/internal/config"
|
|
|
|
"git.aiterp.net/rpdata/logbot3/internal/models/users"
|
|
)
|
|
|
|
func main() {
|
|
conf := config.Get()
|
|
|
|
user, err := users.CheckToken(context.Background())
|
|
if user.LoggedIn() {
|
|
log.Printf("Logged in: %s (%s)", user.ID, strings.Join(user.Permissions, ", "))
|
|
} else {
|
|
log.Println("Warning: API key did not gain us access:", err)
|
|
os.Exit(1)
|
|
}
|
|
|
|
bot := bot.New(context.Background(), conf.Bot.Nicks[0], conf.Bot.Nicks[1:])
|
|
err = bot.Connect(conf.Bot.Server, false)
|
|
if err != nil {
|
|
log.Println("Warning:", err)
|
|
os.Exit(1)
|
|
}
|
|
|
|
// Listen for a quit signal.
|
|
interrupt := make(chan os.Signal, 1)
|
|
signal.Notify(interrupt, os.Interrupt)
|
|
signal.Notify(interrupt, syscall.SIGTERM)
|
|
|
|
log.Println("Interrupt received, stopping...")
|
|
}
|