diff --git a/src/internal/database/counter.go b/src/internal/database/counter.go deleted file mode 100644 index d30530e..0000000 --- a/src/internal/database/counter.go +++ /dev/null @@ -1,72 +0,0 @@ -package database - -import ( - "fmt" - "time" -) - -// GetLastUsedPic -func (db *Database) GetCounterFor(key string) (time.Time, error) { - var id int64 - var timestamp time.Time - - row, err := db.db.Query("SELECT `id`, `timestamp` FROM `counter` WHERE `key` = ? LIMIT 1", key) - if err != nil { - return timestamp, err - } - - defer row.Close() - for row.Next() { - row.Scan(&id, ×tamp) - } - - if id == 0 { - return timestamp, fmt.Errorf("%s not found", key) - } - - return timestamp, nil -} - -// UpdateCounterFor - Add counter -func (db *Database) UpdateCounterFor(key string, timestamp time.Time) (int64, error) { - exec, err := db.db.Exec( - "REPLACE INTO `counter` (`key`, `timestamp`) VALUES (?,?)", - key, - timestamp, - ) - - if err != nil { - return 0, err - } - - return exec.LastInsertId() -} - -// GetAllCounters -func (db *Database) GetAllCounters() (map[string]time.Time, error) { - counters := make(map[string]time.Time) - row, err := db.db.Query("SELECT key, timestamp FROM counter order by key ASC") - if err != nil { - return counters, err - } - - defer row.Close() - for row.Next() { - var key string - var timestamp time.Time - row.Scan(&key, ×tamp) - counters[key] = timestamp - } - - return counters, nil -} - -// DeleteCounter - Deletes a counter by key -func (db *Database) DeleteCounter(key string) (int64, error) { - res, err := db.db.Exec("DELETE FROM `counter` WHERE `key` = ?", key) - if err != nil { - return 0, err - } - - return res.RowsAffected() -} diff --git a/src/internal/database/main.go b/src/internal/database/main.go index 49ba72f..2c477c3 100644 --- a/src/internal/database/main.go +++ b/src/internal/database/main.go @@ -46,12 +46,6 @@ func (db *Database) runMigrations() (*Database, error) { return db, err } - _, err = db.db.Exec("CREATE TABLE IF NOT EXISTS `counter` " + - "(`id` INTEGER PRIMARY KEY AUTOINCREMENT, `key` TEXT, `timestamp` DATETIME)") - if err != nil { - return db, err - } - return db, nil } diff --git a/src/internal/gomatrixbot/birds.go b/src/internal/gomatrixbot/birds.go index 5ea0a43..14fec59 100644 --- a/src/internal/gomatrixbot/birds.go +++ b/src/internal/gomatrixbot/birds.go @@ -16,7 +16,7 @@ import ( const fontSize = 42 -const BIRB_PATH = BASE_PATH + "/reaction_pics" +const BIRB_PATH = "/root/data/reaction_pics" func (mtrx *MtrxClient) postBirb(ctx context.Context, evt *event.Event) { idd, birb, err := mtrx.db.GetLastUsedPic(true) diff --git a/src/internal/gomatrixbot/commands.go b/src/internal/gomatrixbot/commands.go index 3486e8d..7b4dcca 100644 --- a/src/internal/gomatrixbot/commands.go +++ b/src/internal/gomatrixbot/commands.go @@ -24,9 +24,6 @@ var COMMANDS = []string{ "☝️ react to set room topic", "📷️ react to save picture for future lulz", "", - ".counter - List all counters", - ".counter - Get a counter for a key", - ".counterreset - Reset a counter for a key", ".r - Returns a random quote (can search quotes)", ".rb - Returns a random quote on a random bird pic (with optional search)", ".remindme