Turso
This commit is contained in:
@ -25,11 +25,6 @@ func HandleCommand(commandName string, cooldownDuration time.Duration, handler C
|
||||
log.Printf("Error storing user: %v", dbErr)
|
||||
}
|
||||
|
||||
// Rest of your existing HandleCommand logic...
|
||||
if !CheckAndApplyCooldown(s, i, commandName, cooldownDuration) {
|
||||
return
|
||||
}
|
||||
|
||||
if !CheckAndApplyCooldown(s, i, commandName, cooldownDuration) {
|
||||
return
|
||||
}
|
||||
|
16
lib/db.go
16
lib/db.go
@ -10,7 +10,7 @@ import (
|
||||
"sort"
|
||||
"strings"
|
||||
|
||||
"github.com/tursodatabase/go-libsql"
|
||||
_ "github.com/tursodatabase/libsql-client-go/libsql"
|
||||
)
|
||||
|
||||
var DBClient *sql.DB
|
||||
@ -23,17 +23,15 @@ func InitDB() error {
|
||||
return fmt.Errorf("database configuration missing")
|
||||
}
|
||||
|
||||
connector, err := libsql.NewEmbeddedReplicaConnector(
|
||||
"./himbot.db",
|
||||
dbUrl,
|
||||
libsql.WithAuthToken(dbToken),
|
||||
)
|
||||
finalDBUrl := fmt.Sprintf("%s?authToken=%s", dbUrl, dbToken)
|
||||
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to create client: %w", err)
|
||||
client, clientError := sql.Open("libsql", finalDBUrl)
|
||||
|
||||
if clientError != nil {
|
||||
fmt.Fprintf(os.Stderr, "failed to open db %s: %s", dbUrl, clientError)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
client := sql.OpenDB(connector)
|
||||
DBClient = client
|
||||
|
||||
return runMigrations()
|
||||
|
Reference in New Issue
Block a user