init
This commit is contained in:
commit
70b506036a
13 changed files with 796 additions and 0 deletions
30
cmd/bot/main.go
Normal file
30
cmd/bot/main.go
Normal file
|
@ -0,0 +1,30 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"os"
|
||||
"os/signal"
|
||||
"syscall"
|
||||
|
||||
"git.kmsign.ru/royalcat/konfachcloud-discord-bot/src/bot"
|
||||
)
|
||||
|
||||
func main() {
|
||||
botToken, ok := os.LookupEnv("DISCORD_BOT_TOKEN")
|
||||
if !ok {
|
||||
panic("DISCORD_BOT_TOKEN env var is not set")
|
||||
}
|
||||
b, err := bot.Run(bot.Settings{
|
||||
BotToken: botToken,
|
||||
HashLength: 1,
|
||||
DistanceThreshold: 4,
|
||||
})
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
defer b.Close(context.Background())
|
||||
|
||||
sc := make(chan os.Signal, 1)
|
||||
signal.Notify(sc, syscall.SIGINT, syscall.SIGTERM, os.Interrupt)
|
||||
<-sc
|
||||
}
|
35
cmd/dbviewer/main.go
Normal file
35
cmd/dbviewer/main.go
Normal file
|
@ -0,0 +1,35 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/dgraph-io/badger/v4"
|
||||
)
|
||||
|
||||
func main() {
|
||||
opts := badger.DefaultOptions("./db/hash")
|
||||
db, err := badger.Open(opts)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
defer db.Close()
|
||||
|
||||
err = db.View(func(txn *badger.Txn) error {
|
||||
it := txn.NewIterator(badger.DefaultIteratorOptions)
|
||||
defer it.Close()
|
||||
|
||||
for it.Rewind(); it.Valid(); it.Next() {
|
||||
item := it.Item()
|
||||
val, err := item.ValueCopy(nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
fmt.Println(string(item.Key()) + " " + string(val))
|
||||
}
|
||||
|
||||
return nil
|
||||
})
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue