A bunch of Changes

Docker is broken as of now, will fix later
This commit is contained in:
watn3y 2023-12-29 05:15:23 +01:00
parent 1a6953900c
commit 6375fe5af1
27 changed files with 258 additions and 81 deletions

View file

@ -0,0 +1,29 @@
package nenefoot
import (
//"watn3y.de/bloaterbot/botIO"
//"watn3y.de/bloaterbot/config"
"fmt"
tgbotapi "github.com/go-telegram-bot-api/telegram-bot-api/v5"
//"github.com/rs/zerolog/log"
)
func Nenefoot(update tgbotapi.Update, bot *tgbotapi.BotAPI) {
msg3 := tgbotapi.NewInlineQueryResultVideo("hihi", "https://bloater.watn3y.de/5r5NJELyDKYSdPsX6fzK/7000%20Dollars%20for%20this%20car%2C%20but%20i%20got%20a%20slight%20dent.mp4")
msg3.MimeType = "video/mp4"
msg3.Title = "Rat Pencilcase"
msg3.ThumbURL = "https://i.imgur.com/XjCWMco.jpeg"
inline := tgbotapi.InlineConfig{
InlineQueryID: update.InlineQuery.ID,
Results: []interface{}{msg3},
CacheTime: 0,
}
if _, err := bot.Request(inline); err != nil {
fmt.Println(err)
}
}

47
inline/nenefoot/sql.go Normal file
View file

@ -0,0 +1,47 @@
package nenefoot
import (
"database/sql"
_ "modernc.org/sqlite"
"github.com/rs/zerolog/log"
)
var gpSelectUser *sql.Stmt
var gpSelectChat *sql.Stmt
var gpSet *sql.Stmt
func InitDB() {
const dbPath string = "data/db/nenefoot.db"
log.Info().Str("dbpath", dbPath).Msg("init database")
db, err := sql.Open("sqlite", dbPath)
if err != nil {
log.Panic().Err(err).Msg("failed to open sqlite database")
}
_, err = db.Exec("CREATE TABLE IF NOT EXISTS nenefoot (title string, type string, ID string, URL string, UNIQUE(title), UNIQUE(ID), UNIQUE(URL))")
if err != nil {
log.Panic().Err(err).Msg("failed to create table")
}
gpSelectUser, err = db.Prepare("SELECT gaypoints FROM gaypoints WHERE chatid = ? AND userid = ?")
if err != nil {
log.Panic().Err(err).Msg("failed to create sql statement")
}
gpSelectChat, err = db.Prepare("SELECT userid,gaypoints FROM gaypoints WHERE chatid = ? ORDER BY gaypoints DESC")
if err != nil {
log.Panic().Err(err).Msg("failed to create sql statement")
}
gpSet, err = db.Prepare("INSERT OR REPLACE INTO gaypoints (chatid, userid, gaypoints) values (?,?,?)")
if err != nil {
log.Panic().Err(err).Msg("failed to create sql statement")
}
log.Info().Msg("init database: done")
}