various improvements

This commit is contained in:
watn3y 2023-12-29 02:35:22 +01:00
parent d5272262da
commit 1a6953900c
14 changed files with 71 additions and 49 deletions

View file

@ -15,6 +15,8 @@ import (
"github.com/rs/zerolog/log"
)
//TODO logging
func Commands(update tgbotapi.Update, bot *tgbotapi.BotAPI) {
cmd := strings.ToLower(update.Message.Command())

View file

@ -22,6 +22,8 @@ import (
"github.com/rs/zerolog/log"
)
//TODO logging
func Download(update tgbotapi.Update, bot *tgbotapi.BotAPI) {
log.Debug().Int64("chat", update.Message.Chat.ID).Int64("user", update.Message.From.ID).Msg("starting download")
@ -30,18 +32,17 @@ func Download(update tgbotapi.Update, bot *tgbotapi.BotAPI) {
msg := tgbotapi.MessageConfig{
BaseChat: tgbotapi.BaseChat{ChatID: update.Message.Chat.ID, ReplyToMessageID: update.Message.MessageID},
Text: "Downloading your media...",
Text: "Downloading your YouTube Video...",
}
workingMessage := botIO.SendMessage(msg, bot)
if len(commandArgs) >= 1 && matchURL(commandArgs[0]) != "" {
//TODO distinguish
//service := matchURL(commandArgs[0])
} else {
log.Error().Int64("chat", update.Message.Chat.ID).Int64("user", update.Message.From.ID).Str("args", update.Message.CommandArguments()).Msg("failed to download. empty arg")
log.Error().Int64("chat", update.Message.Chat.ID).Int64("user", update.Message.From.ID).Str("args", update.Message.CommandArguments()).Msg("Failed to download YouTube Video. Empty args")
message := tgbotapi.EditMessageTextConfig{
BaseEdit: tgbotapi.BaseEdit{ChatID: workingMessage.Chat.ID, MessageID: workingMessage.MessageID},
Text: "Please specify a valid YouTube URL to download something.",
Text: "Please specify a valid YouTube URL.",
}
botIO.EditMessage(message, bot)
return

View file

@ -10,7 +10,7 @@ import (
tgbotapi "github.com/go-telegram-bot-api/telegram-bot-api/v5"
"github.com/rs/zerolog/log"
)
//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")

View file

@ -11,7 +11,8 @@ var gpSelectUser *sql.Stmt
var gpSelectChat *sql.Stmt
var gpSet *sql.Stmt
//TODO logging
//TODO switch to SQL
func sqlGetAllGP(chatid int64) (gaypoints []gaypointShortDetails) {
rows, err := gpSelectChat.Query(chatid)
if err != nil {

View file

@ -10,6 +10,7 @@ import (
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) {
log.Debug().Str("args", update.Message.CommandArguments()).Msg("parsing new reminder")

View file

@ -9,7 +9,8 @@ var notifySetReminder *sql.Stmt
var notifyGetReminders *sql.Stmt
var notifyGetReminderDetails *sql.Stmt
var notifyDeleteReminder *sql.Stmt
//TODO logging
//TODO switch to SQL
func InitDB() {
const dbPath string = "./bloater.db"
log.Info().Str("dbpath", dbPath).Msg("init database")