A bunch of Changes
Docker is broken as of now, will fix later
This commit is contained in:
parent
1a6953900c
commit
6375fe5af1
27 changed files with 258 additions and 81 deletions
|
@ -5,11 +5,12 @@ import (
|
|||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
"watn3y/bloaterbot/botIO"
|
||||
"watn3y/bloaterbot/commands/download"
|
||||
"watn3y/bloaterbot/commands/gaypoints"
|
||||
"watn3y/bloaterbot/commands/notify"
|
||||
"watn3y/bloaterbot/config"
|
||||
|
||||
"watn3y.de/bloaterbot/botIO"
|
||||
"watn3y.de/bloaterbot/commands/download"
|
||||
"watn3y.de/bloaterbot/commands/gaypoints"
|
||||
"watn3y.de/bloaterbot/commands/notify"
|
||||
"watn3y.de/bloaterbot/config"
|
||||
|
||||
tgbotapi "github.com/go-telegram-bot-api/telegram-bot-api/v5"
|
||||
"github.com/rs/zerolog/log"
|
||||
|
@ -25,25 +26,35 @@ func Commands(update tgbotapi.Update, bot *tgbotapi.BotAPI) {
|
|||
|
||||
switch cmd {
|
||||
case "shutup":
|
||||
shutup(update, bot)
|
||||
go shutup(update, bot)
|
||||
break
|
||||
case "shut":
|
||||
shutup(update, bot)
|
||||
go shutup(update, bot)
|
||||
break
|
||||
case "gp":
|
||||
gaypoints.GetGP(update, bot)
|
||||
break
|
||||
case "addgp":
|
||||
gaypoints.SetGP(update, bot)
|
||||
break
|
||||
case "subtractgp":
|
||||
gaypoints.SetGP(update, bot)
|
||||
break
|
||||
case "remindme":
|
||||
notify.Reminder(update, bot)
|
||||
break
|
||||
case "download":
|
||||
go download.Download(update, bot)
|
||||
break
|
||||
case "dl":
|
||||
go download.Download(update, bot)
|
||||
break
|
||||
case "help":
|
||||
help(update, bot)
|
||||
break
|
||||
case "info":
|
||||
info(update, bot)
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -82,7 +93,8 @@ func info(update tgbotapi.Update, bot *tgbotapi.BotAPI) {
|
|||
if commit == "" {
|
||||
commit = "not available"
|
||||
}
|
||||
info, _ := os.Stat("./bloater.db")
|
||||
//TODO calculate total size
|
||||
info, _ := os.Stat("data/db/gaypoints.db")
|
||||
dbSizeInKiloBytes := info.Size() / 1000
|
||||
|
||||
textInfo := "<b>" + me.FirstName + "</b>" + "\n\n" +
|
||||
|
|
|
@ -14,9 +14,10 @@ import (
|
|||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
"watn3y/bloaterbot/botIO"
|
||||
"watn3y/bloaterbot/commonlogic"
|
||||
"watn3y/bloaterbot/config"
|
||||
|
||||
"watn3y.de/bloaterbot/botIO"
|
||||
"watn3y.de/bloaterbot/commonlogic"
|
||||
"watn3y.de/bloaterbot/config"
|
||||
|
||||
tgbotapi "github.com/go-telegram-bot-api/telegram-bot-api/v5"
|
||||
"github.com/rs/zerolog/log"
|
||||
|
@ -61,7 +62,7 @@ func Download(update tgbotapi.Update, bot *tgbotapi.BotAPI) {
|
|||
return
|
||||
}
|
||||
|
||||
files, err := os.ReadDir("./videos/" + downloadTarget)
|
||||
files, err := os.ReadDir("data/videos/" + downloadTarget)
|
||||
|
||||
if err != nil {
|
||||
log.Error().Err(err).Msg("failed to download. unable to read target directory")
|
||||
|
@ -112,7 +113,7 @@ func randomString(n int) string {
|
|||
|
||||
func runYTDL(URL string, targetDir string) (success bool) {
|
||||
|
||||
cmd := exec.Command("yt-dlp", "-f", "bv*[ext=mp4]+ba[ext=m4a] / bv*+ba/b", "--no-playlist", "-o", "videos/"+targetDir+"/"+"%(title)s.%(ext)s", "--write-thumbnail", "--convert-thumbnails", "jpg", "-o", "thumbnail:videos/"+targetDir+"thumb"+"/"+"%(title)s.%(ext)s", URL)
|
||||
cmd := exec.Command("yt-dlp", "-f", "bv*[ext=mp4]+ba[ext=m4a] / bv*+ba/b", "--no-playlist", "-o", "data/videos/"+targetDir+"/"+"%(title)s.%(ext)s", "--write-thumbnail", "--convert-thumbnails", "jpg", "-o", "thumbnail:data/videos/"+targetDir+"thumb"+"/"+"%(title)s.%(ext)s", URL)
|
||||
|
||||
out, err := cmd.CombinedOutput()
|
||||
var (
|
||||
|
@ -181,8 +182,8 @@ func shortURL(URL string) (shorturl string) {
|
|||
}
|
||||
|
||||
func serveMedia(update tgbotapi.Update, bot *tgbotapi.BotAPI, randomNoise string, file string) {
|
||||
fsPath := "./videos/" + randomNoise + "/" + file
|
||||
fsThumbPath := "./videos/" + randomNoise + "thumb" + "/" + strings.TrimSuffix(file, "mp4") + "jpg"
|
||||
fsPath := "data/videos/" + randomNoise + "/" + file
|
||||
fsThumbPath := "data/videos/" + randomNoise + "thumb" + "/" + strings.TrimSuffix(file, "mp4") + "jpg"
|
||||
fExt := filepath.Ext(fsPath)
|
||||
|
||||
imageTypes := []string{".jpg", ".jpeg", ".png"}
|
||||
|
|
|
@ -3,14 +3,16 @@ package gaypoints
|
|||
import (
|
||||
"strconv"
|
||||
"strings"
|
||||
"watn3y/bloaterbot/botIO"
|
||||
"watn3y/bloaterbot/commonlogic"
|
||||
"watn3y/bloaterbot/config"
|
||||
|
||||
"watn3y.de/bloaterbot/botIO"
|
||||
"watn3y.de/bloaterbot/commonlogic"
|
||||
"watn3y.de/bloaterbot/config"
|
||||
|
||||
tgbotapi "github.com/go-telegram-bot-api/telegram-bot-api/v5"
|
||||
"github.com/rs/zerolog/log"
|
||||
)
|
||||
//TODO logging
|
||||
|
||||
// TODO logging
|
||||
func GetGP(update tgbotapi.Update, bot *tgbotapi.BotAPI) {
|
||||
|
||||
log.Debug().Int64("chat", update.Message.Chat.ID).Int64("user", update.Message.From.ID).Msg("getting gaypoints")
|
||||
|
@ -97,7 +99,7 @@ func SetGP(update tgbotapi.Update, bot *tgbotapi.BotAPI) {
|
|||
log.Debug().Int64("chat", update.Message.Chat.ID).Ints64("enabledChats", config.BotConfig.GayPoints.ModifyUsers).Msg("not setting gaypoints, user not authorised")
|
||||
sticker := tgbotapi.StickerConfig{BaseFile: tgbotapi.BaseFile{
|
||||
BaseChat: tgbotapi.BaseChat{ChatID: update.Message.Chat.ID, ReplyToMessageID: update.Message.MessageID},
|
||||
File: tgbotapi.FilePath("bloater.webp"),
|
||||
File: tgbotapi.FilePath("data/bloater.webp"),
|
||||
}}
|
||||
|
||||
botIO.SendSticker(sticker, bot)
|
||||
|
|
|
@ -2,7 +2,7 @@ package gaypoints
|
|||
|
||||
import (
|
||||
"database/sql"
|
||||
_ "github.com/mattn/go-sqlite3"
|
||||
_ "modernc.org/sqlite"
|
||||
"github.com/rs/zerolog/log"
|
||||
)
|
||||
|
||||
|
@ -68,9 +68,9 @@ func sqlSetGP(chatid int64, userid int64, gaypoints int64) {
|
|||
}
|
||||
|
||||
func InitDB() {
|
||||
const dbPath string = "./bloater.db"
|
||||
const dbPath string = "data/db/gaypoints.db"
|
||||
log.Info().Str("dbpath", dbPath).Msg("init database")
|
||||
db, err := sql.Open("sqlite3", dbPath)
|
||||
db, err := sql.Open("sqlite", dbPath)
|
||||
if err != nil {
|
||||
log.Panic().Err(err).Msg("failed to open sqlite database")
|
||||
}
|
||||
|
|
|
@ -5,11 +5,13 @@ import (
|
|||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
"watn3y/bloaterbot/botIO"
|
||||
|
||||
"watn3y.de/bloaterbot/botIO"
|
||||
|
||||
tgbotapi "github.com/go-telegram-bot-api/telegram-bot-api/v5"
|
||||
"github.com/rs/zerolog/log"
|
||||
)
|
||||
|
||||
//TODO logging
|
||||
|
||||
func Reminder(update tgbotapi.Update, bot *tgbotapi.BotAPI) {
|
||||
|
|
|
@ -3,6 +3,7 @@ package notify
|
|||
import (
|
||||
"database/sql"
|
||||
"github.com/rs/zerolog/log"
|
||||
_ "modernc.org/sqlite"
|
||||
)
|
||||
|
||||
var notifySetReminder *sql.Stmt
|
||||
|
@ -12,9 +13,9 @@ var notifyDeleteReminder *sql.Stmt
|
|||
//TODO logging
|
||||
//TODO switch to SQL
|
||||
func InitDB() {
|
||||
const dbPath string = "./bloater.db"
|
||||
const dbPath string = "data/db/notify.db"
|
||||
log.Info().Str("dbpath", dbPath).Msg("init database")
|
||||
db, err := sql.Open("sqlite3", dbPath)
|
||||
db, err := sql.Open("sqlite", dbPath)
|
||||
if err != nil {
|
||||
log.Panic().Err(err).Msg("failed to open sqlite database")
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue