1
0
mirror of https://github.com/pinpox/gitea-matrix-bot synced 2024-11-22 19:31:58 +01:00

fixed db, implemented missing methods

This commit is contained in:
Pablo Ovelleiro Corral 2019-04-19 23:54:13 +02:00
parent e0f207590e
commit 362d9d0296
No known key found for this signature in database
GPG Key ID: F7C1D57C8464E825
2 changed files with 10 additions and 6 deletions

1
.gitignore vendored

@ -1,3 +1,4 @@
tags
config.ini
gitea-matrix-bot
tokens.db

@ -50,7 +50,7 @@ func (dbg *GiteaDB) GetToken(room string) string {
}
defer db.Close()
stmt, err := db.Prepare("select name from foo where id = ?")
stmt, err := db.Prepare("select token from tokens where room = ?")
if err != nil {
log.Fatal(err)
}
@ -134,17 +134,20 @@ func (dbg *GiteaDB) Set(room, token string) {
if err != nil {
log.Fatal(err)
}
fmt.Println("inserting")
stmt, err := tx.Prepare("insert into tokens(room, token) values(?, ?)")
if err != nil {
log.Fatal(err)
}
defer stmt.Close()
for i := 0; i < 100; i++ {
_, err = stmt.Exec(room, token)
if err != nil {
log.Fatal(err)
}
_, err = stmt.Exec(room, token)
if err != nil {
log.Fatal(err)
}
tx.Commit()
dbg.GetAll()
}