0

[WIP] Partial bot skeleton, non-functional though

This commit is contained in:
eleksir
2024-02-09 19:40:54 +03:00
parent ea4652cefa
commit 9eac899a5c
1460 changed files with 625051 additions and 492 deletions

38
main.go
View File

@@ -5,13 +5,14 @@ import (
"fmt"
"os"
"os/signal"
"path/filepath"
"syscall"
"github.com/go-redis/redis/v8"
log "github.com/sirupsen/logrus"
)
// Производит некоторую инициализацию перед запуском main()
// init производит некоторую инициализацию перед запуском main()
func init() {
log.SetFormatter(&log.TextFormatter{
DisableQuote: true,
@@ -21,8 +22,6 @@ func init() {
TimestampFormat: "2006-01-02 15:04:05",
})
readConfig()
// no panic, no trace
switch config.Loglevel {
case "fatal":
@@ -38,7 +37,40 @@ func init() {
default:
log.SetLevel(log.InfoLevel)
}
var err error
executablePath, err := os.Executable()
if err != nil {
log.Errorf("Unable to get current executable path: %s", err)
os.Exit(1)
}
configJSONPath := fmt.Sprintf("%s/data/config.json", filepath.Dir(executablePath))
locations := []string{
"~/.aleesa-telegram-go.json",
"~/aleesa-telegram-go.json",
"/etc/aleesa-telegram-go.json",
configJSONPath,
}
for _, location := range locations {
config, err = parseConfig(location)
if err == nil {
break
}
log.Errorf("Unable to parse config at %s: %s", location, err)
}
if err != nil {
os.Exit(1)
}
}
func main() {
// Main context
var ctx = context.Background()