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
4
.gitignore
vendored
4
.gitignore
vendored
|
@ -108,6 +108,4 @@ fabric.properties
|
||||||
|
|
||||||
# CUSTOM
|
# CUSTOM
|
||||||
|
|
||||||
config.toml
|
data/
|
||||||
bloater.db
|
|
||||||
|
|
||||||
|
|
2
TODO.md
2
TODO.md
|
@ -1,4 +1,4 @@
|
||||||
## ;todolist
|
//TODO
|
||||||
|
|
||||||
- Improve logging
|
- Improve logging
|
||||||
- differentiate between debug and non-debug logs
|
- differentiate between debug and non-debug logs
|
||||||
|
|
36
bot.go
36
bot.go
|
@ -2,30 +2,42 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"time"
|
"time"
|
||||||
"watn3y/bloaterbot/botIO"
|
|
||||||
"watn3y/bloaterbot/commands"
|
|
||||||
"watn3y/bloaterbot/commands/notify"
|
|
||||||
"watn3y/bloaterbot/text"
|
|
||||||
"github.com/rs/zerolog/log"
|
"github.com/rs/zerolog/log"
|
||||||
|
"watn3y.de/bloaterbot/botIO"
|
||||||
|
"watn3y.de/bloaterbot/commands"
|
||||||
|
"watn3y.de/bloaterbot/commands/notify"
|
||||||
|
"watn3y.de/bloaterbot/inline/nenefoot"
|
||||||
|
"watn3y.de/bloaterbot/text"
|
||||||
)
|
)
|
||||||
|
|
||||||
func bot() {
|
func bot() {
|
||||||
updates, bot := botIO.Authenticate()
|
updates, bot := botIO.Authenticate()
|
||||||
|
|
||||||
go notify.NotifyHandler(bot)
|
go notify.NotifyHandler(bot)
|
||||||
now := time.Now().UTC()
|
|
||||||
for update := range updates {
|
for update := range updates {
|
||||||
if update.Message == nil || update.Message.Time().UTC().Unix() < now.UTC().Unix() {
|
log.Debug().Interface("update", update).Msg("Recieved update")
|
||||||
|
|
||||||
|
if update.InlineQuery != nil && update.Message == nil {
|
||||||
|
nenefoot.Nenefoot(update, bot)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Info().Int64("user", update.Message.From.ID).Int64("chat", update.Message.Chat.ID).Str("msg", update.Message.Text).Msg("Recieved update:")
|
if update.Message != nil {
|
||||||
log.Debug().Interface("update", update).Msg("")
|
if update.Message.Time().UTC().Unix() < time.Now().UTC().Unix() {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if update.Message.IsCommand() {
|
||||||
|
commands.Commands(update, bot)
|
||||||
|
} else {
|
||||||
|
text.Matcher(update, bot)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
if update.Message.IsCommand() {
|
|
||||||
commands.Commands(update, bot)
|
|
||||||
} else {
|
|
||||||
text.Matcher(update, bot)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
log.Info().Interface("update", update).Msg("Unable to parse update")
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
package botIO
|
package botIO
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"watn3y/bloaterbot/config"
|
|
||||||
tgbotapi "github.com/go-telegram-bot-api/telegram-bot-api/v5"
|
tgbotapi "github.com/go-telegram-bot-api/telegram-bot-api/v5"
|
||||||
"github.com/rs/zerolog/log"
|
"github.com/rs/zerolog/log"
|
||||||
|
"watn3y.de/bloaterbot/config"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Authenticate() (tgbotapi.UpdatesChannel, *tgbotapi.BotAPI) {
|
func Authenticate() (tgbotapi.UpdatesChannel, *tgbotapi.BotAPI) {
|
||||||
|
|
|
@ -5,11 +5,12 @@ import (
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
"watn3y/bloaterbot/botIO"
|
|
||||||
"watn3y/bloaterbot/commands/download"
|
"watn3y.de/bloaterbot/botIO"
|
||||||
"watn3y/bloaterbot/commands/gaypoints"
|
"watn3y.de/bloaterbot/commands/download"
|
||||||
"watn3y/bloaterbot/commands/notify"
|
"watn3y.de/bloaterbot/commands/gaypoints"
|
||||||
"watn3y/bloaterbot/config"
|
"watn3y.de/bloaterbot/commands/notify"
|
||||||
|
"watn3y.de/bloaterbot/config"
|
||||||
|
|
||||||
tgbotapi "github.com/go-telegram-bot-api/telegram-bot-api/v5"
|
tgbotapi "github.com/go-telegram-bot-api/telegram-bot-api/v5"
|
||||||
"github.com/rs/zerolog/log"
|
"github.com/rs/zerolog/log"
|
||||||
|
@ -25,25 +26,35 @@ func Commands(update tgbotapi.Update, bot *tgbotapi.BotAPI) {
|
||||||
|
|
||||||
switch cmd {
|
switch cmd {
|
||||||
case "shutup":
|
case "shutup":
|
||||||
shutup(update, bot)
|
go shutup(update, bot)
|
||||||
|
break
|
||||||
case "shut":
|
case "shut":
|
||||||
shutup(update, bot)
|
go shutup(update, bot)
|
||||||
|
break
|
||||||
case "gp":
|
case "gp":
|
||||||
gaypoints.GetGP(update, bot)
|
gaypoints.GetGP(update, bot)
|
||||||
|
break
|
||||||
case "addgp":
|
case "addgp":
|
||||||
gaypoints.SetGP(update, bot)
|
gaypoints.SetGP(update, bot)
|
||||||
|
break
|
||||||
case "subtractgp":
|
case "subtractgp":
|
||||||
gaypoints.SetGP(update, bot)
|
gaypoints.SetGP(update, bot)
|
||||||
|
break
|
||||||
case "remindme":
|
case "remindme":
|
||||||
notify.Reminder(update, bot)
|
notify.Reminder(update, bot)
|
||||||
|
break
|
||||||
case "download":
|
case "download":
|
||||||
go download.Download(update, bot)
|
go download.Download(update, bot)
|
||||||
|
break
|
||||||
case "dl":
|
case "dl":
|
||||||
go download.Download(update, bot)
|
go download.Download(update, bot)
|
||||||
|
break
|
||||||
case "help":
|
case "help":
|
||||||
help(update, bot)
|
help(update, bot)
|
||||||
|
break
|
||||||
case "info":
|
case "info":
|
||||||
info(update, bot)
|
info(update, bot)
|
||||||
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,7 +93,8 @@ func info(update tgbotapi.Update, bot *tgbotapi.BotAPI) {
|
||||||
if commit == "" {
|
if commit == "" {
|
||||||
commit = "not available"
|
commit = "not available"
|
||||||
}
|
}
|
||||||
info, _ := os.Stat("./bloater.db")
|
//TODO calculate total size
|
||||||
|
info, _ := os.Stat("data/db/gaypoints.db")
|
||||||
dbSizeInKiloBytes := info.Size() / 1000
|
dbSizeInKiloBytes := info.Size() / 1000
|
||||||
|
|
||||||
textInfo := "<b>" + me.FirstName + "</b>" + "\n\n" +
|
textInfo := "<b>" + me.FirstName + "</b>" + "\n\n" +
|
||||||
|
|
|
@ -14,9 +14,10 @@ import (
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
"watn3y/bloaterbot/botIO"
|
|
||||||
"watn3y/bloaterbot/commonlogic"
|
"watn3y.de/bloaterbot/botIO"
|
||||||
"watn3y/bloaterbot/config"
|
"watn3y.de/bloaterbot/commonlogic"
|
||||||
|
"watn3y.de/bloaterbot/config"
|
||||||
|
|
||||||
tgbotapi "github.com/go-telegram-bot-api/telegram-bot-api/v5"
|
tgbotapi "github.com/go-telegram-bot-api/telegram-bot-api/v5"
|
||||||
"github.com/rs/zerolog/log"
|
"github.com/rs/zerolog/log"
|
||||||
|
@ -61,7 +62,7 @@ func Download(update tgbotapi.Update, bot *tgbotapi.BotAPI) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
files, err := os.ReadDir("./videos/" + downloadTarget)
|
files, err := os.ReadDir("data/videos/" + downloadTarget)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error().Err(err).Msg("failed to download. unable to read target directory")
|
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) {
|
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()
|
out, err := cmd.CombinedOutput()
|
||||||
var (
|
var (
|
||||||
|
@ -181,8 +182,8 @@ func shortURL(URL string) (shorturl string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func serveMedia(update tgbotapi.Update, bot *tgbotapi.BotAPI, randomNoise string, file string) {
|
func serveMedia(update tgbotapi.Update, bot *tgbotapi.BotAPI, randomNoise string, file string) {
|
||||||
fsPath := "./videos/" + randomNoise + "/" + file
|
fsPath := "data/videos/" + randomNoise + "/" + file
|
||||||
fsThumbPath := "./videos/" + randomNoise + "thumb" + "/" + strings.TrimSuffix(file, "mp4") + "jpg"
|
fsThumbPath := "data/videos/" + randomNoise + "thumb" + "/" + strings.TrimSuffix(file, "mp4") + "jpg"
|
||||||
fExt := filepath.Ext(fsPath)
|
fExt := filepath.Ext(fsPath)
|
||||||
|
|
||||||
imageTypes := []string{".jpg", ".jpeg", ".png"}
|
imageTypes := []string{".jpg", ".jpeg", ".png"}
|
||||||
|
|
|
@ -3,14 +3,16 @@ package gaypoints
|
||||||
import (
|
import (
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"watn3y/bloaterbot/botIO"
|
|
||||||
"watn3y/bloaterbot/commonlogic"
|
"watn3y.de/bloaterbot/botIO"
|
||||||
"watn3y/bloaterbot/config"
|
"watn3y.de/bloaterbot/commonlogic"
|
||||||
|
"watn3y.de/bloaterbot/config"
|
||||||
|
|
||||||
tgbotapi "github.com/go-telegram-bot-api/telegram-bot-api/v5"
|
tgbotapi "github.com/go-telegram-bot-api/telegram-bot-api/v5"
|
||||||
"github.com/rs/zerolog/log"
|
"github.com/rs/zerolog/log"
|
||||||
)
|
)
|
||||||
//TODO logging
|
|
||||||
|
// TODO logging
|
||||||
func GetGP(update tgbotapi.Update, bot *tgbotapi.BotAPI) {
|
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")
|
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")
|
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{
|
sticker := tgbotapi.StickerConfig{BaseFile: tgbotapi.BaseFile{
|
||||||
BaseChat: tgbotapi.BaseChat{ChatID: update.Message.Chat.ID, ReplyToMessageID: update.Message.MessageID},
|
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)
|
botIO.SendSticker(sticker, bot)
|
||||||
|
|
|
@ -2,7 +2,7 @@ package gaypoints
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"database/sql"
|
"database/sql"
|
||||||
_ "github.com/mattn/go-sqlite3"
|
_ "modernc.org/sqlite"
|
||||||
"github.com/rs/zerolog/log"
|
"github.com/rs/zerolog/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -68,9 +68,9 @@ func sqlSetGP(chatid int64, userid int64, gaypoints int64) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func InitDB() {
|
func InitDB() {
|
||||||
const dbPath string = "./bloater.db"
|
const dbPath string = "data/db/gaypoints.db"
|
||||||
log.Info().Str("dbpath", dbPath).Msg("init database")
|
log.Info().Str("dbpath", dbPath).Msg("init database")
|
||||||
db, err := sql.Open("sqlite3", dbPath)
|
db, err := sql.Open("sqlite", dbPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Panic().Err(err).Msg("failed to open sqlite database")
|
log.Panic().Err(err).Msg("failed to open sqlite database")
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,11 +5,13 @@ import (
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
"watn3y/bloaterbot/botIO"
|
|
||||||
|
"watn3y.de/bloaterbot/botIO"
|
||||||
|
|
||||||
tgbotapi "github.com/go-telegram-bot-api/telegram-bot-api/v5"
|
tgbotapi "github.com/go-telegram-bot-api/telegram-bot-api/v5"
|
||||||
"github.com/rs/zerolog/log"
|
"github.com/rs/zerolog/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
//TODO logging
|
//TODO logging
|
||||||
|
|
||||||
func Reminder(update tgbotapi.Update, bot *tgbotapi.BotAPI) {
|
func Reminder(update tgbotapi.Update, bot *tgbotapi.BotAPI) {
|
||||||
|
|
|
@ -3,6 +3,7 @@ package notify
|
||||||
import (
|
import (
|
||||||
"database/sql"
|
"database/sql"
|
||||||
"github.com/rs/zerolog/log"
|
"github.com/rs/zerolog/log"
|
||||||
|
_ "modernc.org/sqlite"
|
||||||
)
|
)
|
||||||
|
|
||||||
var notifySetReminder *sql.Stmt
|
var notifySetReminder *sql.Stmt
|
||||||
|
@ -12,9 +13,9 @@ var notifyDeleteReminder *sql.Stmt
|
||||||
//TODO logging
|
//TODO logging
|
||||||
//TODO switch to SQL
|
//TODO switch to SQL
|
||||||
func InitDB() {
|
func InitDB() {
|
||||||
const dbPath string = "./bloater.db"
|
const dbPath string = "data/db/notify.db"
|
||||||
log.Info().Str("dbpath", dbPath).Msg("init database")
|
log.Info().Str("dbpath", dbPath).Msg("init database")
|
||||||
db, err := sql.Open("sqlite3", dbPath)
|
db, err := sql.Open("sqlite", dbPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Panic().Err(err).Msg("failed to open sqlite database")
|
log.Panic().Err(err).Msg("failed to open sqlite database")
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,14 +38,14 @@ var BotConfig config
|
||||||
|
|
||||||
func LoadConfig() {
|
func LoadConfig() {
|
||||||
|
|
||||||
configFile, err := os.ReadFile("config.toml")
|
configFile, err := os.ReadFile("data/config.toml")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Panic().Err(err).Msg("error opening config file")
|
log.Panic().Err(err).Msg("error opening data/config.toml")
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = toml.Decode(string(configFile), &BotConfig)
|
_, err = toml.Decode(string(configFile), &BotConfig)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Panic().Err(err).Msg("error decoding config file")
|
log.Panic().Err(err).Msg("error decoding data/config.toml")
|
||||||
}
|
}
|
||||||
|
|
||||||
BotConfig.Shutup = make(map[int64]time.Time)
|
BotConfig.Shutup = make(map[int64]time.Time)
|
||||||
|
@ -102,18 +102,18 @@ func EncodeToml() {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
f, err := os.Create("config.toml.example")
|
f, err := os.Create("data/config.toml.example")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Panic().Err(err).Msg("error encoding config file. Cannot open config.toml.example")
|
log.Panic().Err(err).Msg("error encoding config file. Cannot open data/config.toml.example")
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := toml.NewEncoder(f).Encode(exampleConfig); err != nil {
|
if err := toml.NewEncoder(f).Encode(exampleConfig); err != nil {
|
||||||
log.Panic().Err(err).Msg("error encoding config file")
|
log.Panic().Err(err).Msg("error encoding config file")
|
||||||
}
|
}
|
||||||
if err := f.Close(); err != nil {
|
if err := f.Close(); err != nil {
|
||||||
log.Panic().Err(err).Msg("error encoding config file. Cannot close config.toml.example")
|
log.Panic().Err(err).Msg("error encoding config file. Cannot close data/config.toml.example")
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Info().Msg("Wrote example config to config.toml.example. Bye Bye")
|
log.Info().Msg("Wrote example config to data/config.toml.example. Bye Bye")
|
||||||
}
|
}
|
||||||
|
|
BIN
data/204.jpg
Normal file
BIN
data/204.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 22 KiB |
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 17 KiB |
0
data/db/placeholder
Normal file
0
data/db/placeholder
Normal file
0
data/nenefoot/placeholder
Normal file
0
data/nenefoot/placeholder
Normal file
0
data/videos/placeholder
Normal file
0
data/videos/placeholder
Normal file
|
@ -5,8 +5,7 @@ services:
|
||||||
container_name: bloaterbot
|
container_name: bloaterbot
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
volumes:
|
volumes:
|
||||||
- /opt/bloaterbot/config.toml:/app/config.toml
|
- /opt/bloaterbot/data:/app/data
|
||||||
- /opt/bloaterbot/bloater.db:/app/bloater.db
|
|
||||||
networks:
|
networks:
|
||||||
- expose
|
- expose
|
||||||
networks:
|
networks:
|
||||||
|
|
21
go.mod
21
go.mod
|
@ -1,16 +1,33 @@
|
||||||
module watn3y/bloaterbot
|
module watn3y.de/bloaterbot
|
||||||
|
|
||||||
go 1.21
|
go 1.21
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/BurntSushi/toml v1.3.2
|
github.com/BurntSushi/toml v1.3.2
|
||||||
github.com/go-telegram-bot-api/telegram-bot-api/v5 v5.5.1
|
github.com/go-telegram-bot-api/telegram-bot-api/v5 v5.5.1
|
||||||
github.com/mattn/go-sqlite3 v1.14.19
|
|
||||||
github.com/rs/zerolog v1.31.0
|
github.com/rs/zerolog v1.31.0
|
||||||
|
modernc.org/sqlite v1.28.0
|
||||||
)
|
)
|
||||||
|
|
||||||
|
require github.com/mattn/go-sqlite3 v1.14.19 // indirect
|
||||||
|
|
||||||
require (
|
require (
|
||||||
|
github.com/dustin/go-humanize v1.0.1 // indirect
|
||||||
|
github.com/google/uuid v1.5.0 // indirect
|
||||||
|
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect
|
||||||
github.com/mattn/go-colorable v0.1.13 // indirect
|
github.com/mattn/go-colorable v0.1.13 // indirect
|
||||||
github.com/mattn/go-isatty v0.0.20 // indirect
|
github.com/mattn/go-isatty v0.0.20 // indirect
|
||||||
|
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
|
||||||
|
golang.org/x/mod v0.14.0 // indirect
|
||||||
golang.org/x/sys v0.15.0 // indirect
|
golang.org/x/sys v0.15.0 // indirect
|
||||||
|
golang.org/x/tools v0.16.1 // indirect
|
||||||
|
lukechampine.com/uint128 v1.3.0 // indirect
|
||||||
|
modernc.org/cc/v3 v3.41.0 // indirect
|
||||||
|
modernc.org/ccgo/v3 v3.16.15 // indirect
|
||||||
|
modernc.org/libc v1.38.0 // indirect
|
||||||
|
modernc.org/mathutil v1.6.0 // indirect
|
||||||
|
modernc.org/memory v1.7.2 // indirect
|
||||||
|
modernc.org/opt v0.1.3 // indirect
|
||||||
|
modernc.org/strutil v1.2.0 // indirect
|
||||||
|
modernc.org/token v1.1.0 // indirect
|
||||||
)
|
)
|
||||||
|
|
48
go.sum
48
go.sum
|
@ -1,9 +1,19 @@
|
||||||
github.com/BurntSushi/toml v1.3.2 h1:o7IhLm0Msx3BaB+n3Ag7L8EVlByGnpq14C4YWiu/gL8=
|
github.com/BurntSushi/toml v1.3.2 h1:o7IhLm0Msx3BaB+n3Ag7L8EVlByGnpq14C4YWiu/gL8=
|
||||||
github.com/BurntSushi/toml v1.3.2/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ=
|
github.com/BurntSushi/toml v1.3.2/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ=
|
||||||
github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
|
github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
|
||||||
|
github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY=
|
||||||
|
github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=
|
||||||
github.com/go-telegram-bot-api/telegram-bot-api/v5 v5.5.1 h1:wG8n/XJQ07TmjbITcGiUaOtXxdrINDz1b0J1w0SzqDc=
|
github.com/go-telegram-bot-api/telegram-bot-api/v5 v5.5.1 h1:wG8n/XJQ07TmjbITcGiUaOtXxdrINDz1b0J1w0SzqDc=
|
||||||
github.com/go-telegram-bot-api/telegram-bot-api/v5 v5.5.1/go.mod h1:A2S0CWkNylc2phvKXWBBdD3K0iGnDBGbzRpISP2zBl8=
|
github.com/go-telegram-bot-api/telegram-bot-api/v5 v5.5.1/go.mod h1:A2S0CWkNylc2phvKXWBBdD3K0iGnDBGbzRpISP2zBl8=
|
||||||
github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
|
github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
|
||||||
|
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
|
||||||
|
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
||||||
|
github.com/google/pprof v0.0.0-20221118152302-e6195bd50e26 h1:Xim43kblpZXfIBQsbuBVKCudVG457BR2GZFIz3uw3hQ=
|
||||||
|
github.com/google/pprof v0.0.0-20221118152302-e6195bd50e26/go.mod h1:dDKJzRmX4S37WGHujM7tX//fmj1uioxKzKxz3lo4HJo=
|
||||||
|
github.com/google/uuid v1.5.0 h1:1p67kYwdtXjb0gL0BPiP1Av9wiZPo5A8z2cWkTZ+eyU=
|
||||||
|
github.com/google/uuid v1.5.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||||
|
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 h1:Z9n2FFNUXsshfwJMBgNA0RU6/i7WVaAegv3PtuIHPMs=
|
||||||
|
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51/go.mod h1:CzGEWj7cYgsdH8dAjBGEr58BoE7ScuLd+fwFZ44+/x8=
|
||||||
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
|
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
|
||||||
github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg=
|
github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg=
|
||||||
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
|
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
|
||||||
|
@ -13,11 +23,49 @@ github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D
|
||||||
github.com/mattn/go-sqlite3 v1.14.19 h1:fhGleo2h1p8tVChob4I9HpmVFIAkKGpiukdrgQbWfGI=
|
github.com/mattn/go-sqlite3 v1.14.19 h1:fhGleo2h1p8tVChob4I9HpmVFIAkKGpiukdrgQbWfGI=
|
||||||
github.com/mattn/go-sqlite3 v1.14.19/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg=
|
github.com/mattn/go-sqlite3 v1.14.19/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg=
|
||||||
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||||
|
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||||
|
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||||
|
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec h1:W09IVJc94icq4NjY3clb7Lk8O1qJ8BdBEF8z0ibU0rE=
|
||||||
|
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo=
|
||||||
github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg=
|
github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg=
|
||||||
github.com/rs/zerolog v1.31.0 h1:FcTR3NnLWW+NnTwwhFWiJSZr4ECLpqCm6QsEnyvbV4A=
|
github.com/rs/zerolog v1.31.0 h1:FcTR3NnLWW+NnTwwhFWiJSZr4ECLpqCm6QsEnyvbV4A=
|
||||||
github.com/rs/zerolog v1.31.0/go.mod h1:/7mN4D5sKwJLZQ2b/znpjC3/GQWY/xaDXUM0kKWRHss=
|
github.com/rs/zerolog v1.31.0/go.mod h1:/7mN4D5sKwJLZQ2b/znpjC3/GQWY/xaDXUM0kKWRHss=
|
||||||
|
golang.org/x/mod v0.14.0 h1:dGoOF9QVLYng8IHTm7BAyWqCqSheQ5pYWGhzW00YJr0=
|
||||||
|
golang.org/x/mod v0.14.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
|
||||||
|
golang.org/x/sync v0.5.0 h1:60k92dhOjHxJkrqnwsfl8KuaHbn/5dl0lUPUklKo3qE=
|
||||||
|
golang.org/x/sync v0.5.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
|
||||||
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc=
|
golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc=
|
||||||
golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||||
|
golang.org/x/tools v0.16.1 h1:TLyB3WofjdOEepBHAU20JdNC1Zbg87elYofWYAY5oZA=
|
||||||
|
golang.org/x/tools v0.16.1/go.mod h1:kYVVN6I1mBNoB1OX+noeBjbRk4IUEPa7JJ+TJMEooJ0=
|
||||||
|
lukechampine.com/uint128 v1.3.0 h1:cDdUVfRwDUDovz610ABgFD17nXD4/uDgVHl2sC3+sbo=
|
||||||
|
lukechampine.com/uint128 v1.3.0/go.mod h1:c4eWIwlEGaxC/+H1VguhU4PHXNWDCDMUlWdIWl2j1gk=
|
||||||
|
modernc.org/cc/v3 v3.41.0 h1:QoR1Sn3YWlmA1T4vLaKZfawdVtSiGx8H+cEojbC7v1Q=
|
||||||
|
modernc.org/cc/v3 v3.41.0/go.mod h1:Ni4zjJYJ04CDOhG7dn640WGfwBzfE0ecX8TyMB0Fv0Y=
|
||||||
|
modernc.org/ccgo/v3 v3.16.15 h1:KbDR3ZAVU+wiLyMESPtbtE/Add4elztFyfsWoNTgxS0=
|
||||||
|
modernc.org/ccgo/v3 v3.16.15/go.mod h1:yT7B+/E2m43tmMOT51GMoM98/MtHIcQQSleGnddkUNI=
|
||||||
|
modernc.org/ccorpus v1.11.6 h1:J16RXiiqiCgua6+ZvQot4yUuUy8zxgqbqEEUuGPlISk=
|
||||||
|
modernc.org/ccorpus v1.11.6/go.mod h1:2gEUTrWqdpH2pXsmTM1ZkjeSrUWDpjMu2T6m29L/ErQ=
|
||||||
|
modernc.org/httpfs v1.0.6 h1:AAgIpFZRXuYnkjftxTAZwMIiwEqAfk8aVB2/oA6nAeM=
|
||||||
|
modernc.org/httpfs v1.0.6/go.mod h1:7dosgurJGp0sPaRanU53W4xZYKh14wfzX420oZADeHM=
|
||||||
|
modernc.org/libc v1.38.0 h1:o4Lpk0zNDSdsjfEXnF1FGXWQ9PDi1NOdWcLP5n13FGo=
|
||||||
|
modernc.org/libc v1.38.0/go.mod h1:YAXkAZ8ktnkCKaN9sw/UDeUVkGYJ/YquGO4FTi5nmHE=
|
||||||
|
modernc.org/mathutil v1.6.0 h1:fRe9+AmYlaej+64JsEEhoWuAYBkOtQiMEU7n/XgfYi4=
|
||||||
|
modernc.org/mathutil v1.6.0/go.mod h1:Ui5Q9q1TR2gFm0AQRqQUaBWFLAhQpCwNcuhBOSedWPo=
|
||||||
|
modernc.org/memory v1.7.2 h1:Klh90S215mmH8c9gO98QxQFsY+W451E8AnzjoE2ee1E=
|
||||||
|
modernc.org/memory v1.7.2/go.mod h1:NO4NVCQy0N7ln+T9ngWqOQfi7ley4vpwvARR+Hjw95E=
|
||||||
|
modernc.org/opt v0.1.3 h1:3XOZf2yznlhC+ibLltsDGzABUGVx8J6pnFMS3E4dcq4=
|
||||||
|
modernc.org/opt v0.1.3/go.mod h1:WdSiB5evDcignE70guQKxYUl14mgWtbClRi5wmkkTX0=
|
||||||
|
modernc.org/sqlite v1.28.0 h1:Zx+LyDDmXczNnEQdvPuEfcFVA2ZPyaD7UCZDjef3BHQ=
|
||||||
|
modernc.org/sqlite v1.28.0/go.mod h1:Qxpazz0zH8Z1xCFyi5GSL3FzbtZ3fvbjmywNogldEW0=
|
||||||
|
modernc.org/strutil v1.2.0 h1:agBi9dp1I+eOnxXeiZawM8F4LawKv4NzGWSaLfyeNZA=
|
||||||
|
modernc.org/strutil v1.2.0/go.mod h1:/mdcBmfOibveCTBxUl5B5l6W+TTH1FXPLHZE6bTosX0=
|
||||||
|
modernc.org/tcl v1.15.2 h1:C4ybAYCGJw968e+Me18oW55kD/FexcHbqH2xak1ROSY=
|
||||||
|
modernc.org/tcl v1.15.2/go.mod h1:3+k/ZaEbKrC8ePv8zJWPtBSW0V7Gg9g8rkmhI1Kfs3c=
|
||||||
|
modernc.org/token v1.1.0 h1:Xl7Ap9dKaEs5kLoOQeQmPWevfnk/DM5qcLcYlA8ys6Y=
|
||||||
|
modernc.org/token v1.1.0/go.mod h1:UGzOrNV1mAFSEB63lOFHIpNRUVMvYTc6yu1SMY/XTDM=
|
||||||
|
modernc.org/z v1.7.3 h1:zDJf6iHjrnB+WRD88stbXokugjyc0/pB91ri1gO6LZY=
|
||||||
|
modernc.org/z v1.7.3/go.mod h1:Ipv4tsdxZRbQyLq9Q1M6gdbkxYzdlrciF2Hi/lS7nWE=
|
||||||
|
|
29
inline/nenefoot/nenefoot.go
Normal file
29
inline/nenefoot/nenefoot.go
Normal 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
47
inline/nenefoot/sql.go
Normal 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")
|
||||||
|
}
|
9
main.go
9
main.go
|
@ -5,10 +5,11 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"time"
|
"time"
|
||||||
"watn3y/bloaterbot/commands/gaypoints"
|
|
||||||
"watn3y/bloaterbot/commands/notify"
|
"watn3y.de/bloaterbot/commands/gaypoints"
|
||||||
"watn3y/bloaterbot/config"
|
"watn3y.de/bloaterbot/commands/notify"
|
||||||
"watn3y/bloaterbot/webserver"
|
"watn3y.de/bloaterbot/config"
|
||||||
|
"watn3y.de/bloaterbot/webserver"
|
||||||
|
|
||||||
"github.com/rs/zerolog"
|
"github.com/rs/zerolog"
|
||||||
"github.com/rs/zerolog/log"
|
"github.com/rs/zerolog/log"
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
package balonlyl
|
package balonlyl
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"watn3y/bloaterbot/botIO"
|
"watn3y.de/bloaterbot/botIO"
|
||||||
"watn3y/bloaterbot/config"
|
"watn3y.de/bloaterbot/config"
|
||||||
|
|
||||||
tgbotapi "github.com/go-telegram-bot-api/telegram-bot-api/v5"
|
tgbotapi "github.com/go-telegram-bot-api/telegram-bot-api/v5"
|
||||||
)
|
)
|
||||||
|
|
||||||
//TODO logging
|
//TODO logging
|
||||||
|
|
||||||
func Balonlyl(update tgbotapi.Update, bot *tgbotapi.BotAPI) {
|
func Balonlyl(update tgbotapi.Update, bot *tgbotapi.BotAPI) {
|
||||||
|
|
|
@ -3,14 +3,16 @@ package text
|
||||||
import (
|
import (
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
"watn3y/bloaterbot/commonlogic"
|
|
||||||
"watn3y/bloaterbot/config"
|
"watn3y.de/bloaterbot/commonlogic"
|
||||||
"watn3y/bloaterbot/text/balonlyl"
|
"watn3y.de/bloaterbot/config"
|
||||||
|
"watn3y.de/bloaterbot/text/balonlyl"
|
||||||
|
|
||||||
tgbotapi "github.com/go-telegram-bot-api/telegram-bot-api/v5"
|
tgbotapi "github.com/go-telegram-bot-api/telegram-bot-api/v5"
|
||||||
"github.com/rs/zerolog/log"
|
"github.com/rs/zerolog/log"
|
||||||
)
|
)
|
||||||
//TODO logging
|
|
||||||
|
// TODO logging
|
||||||
func Matcher(update tgbotapi.Update, bot *tgbotapi.BotAPI) {
|
func Matcher(update tgbotapi.Update, bot *tgbotapi.BotAPI) {
|
||||||
|
|
||||||
log.Debug().Str("text", update.Message.Text).Int64("chat", update.Message.Chat.ID).Msg("Starting text matcher")
|
log.Debug().Str("text", update.Message.Text).Int64("chat", update.Message.Chat.ID).Msg("Starting text matcher")
|
||||||
|
|
|
@ -1,13 +0,0 @@
|
||||||
<!DOCTYPE html>
|
|
||||||
<html lang="en">
|
|
||||||
<head>
|
|
||||||
<title>bloaterbot</title>
|
|
||||||
<meta http-equiv="Refresh" content="1; url='https://watn3y.de'" />
|
|
||||||
<style>
|
|
||||||
h1 {text-align: center;}
|
|
||||||
</style>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<h1>NO.</h1>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
|
@ -2,16 +2,21 @@ package webserver
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
||||||
"watn3y/bloaterbot/config"
|
"watn3y.de/bloaterbot/config"
|
||||||
|
|
||||||
"github.com/rs/zerolog/log"
|
"github.com/rs/zerolog/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
func RunServer() {
|
func RunServer() {
|
||||||
fs := http.FileServer(http.Dir("./videos"))
|
//http.HandleFunc("/", handle204)
|
||||||
http.Handle("/", fs)
|
|
||||||
|
|
||||||
log.Info().Str("port", config.BotConfig.Webserver.Port).Str("path", "./videos").Msg("Starting webserver")
|
videos := http.FileServer(http.Dir("data/videos"))
|
||||||
|
nenefoot := http.FileServer(http.Dir("data/nenefoot"))
|
||||||
|
|
||||||
|
http.Handle("/", videos)
|
||||||
|
http.Handle("/nenefoot/", nenefoot)
|
||||||
|
|
||||||
|
log.Info().Str("port", config.BotConfig.Webserver.Port).Msg("Starting webserver")
|
||||||
|
|
||||||
err := http.ListenAndServe(":"+config.BotConfig.Webserver.Port, nil)
|
err := http.ListenAndServe(":"+config.BotConfig.Webserver.Port, nil)
|
||||||
|
|
||||||
|
@ -20,3 +25,16 @@ func RunServer() {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*func handle204(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
||||||
|
buf, err := os.ReadFile("data/204.jpg")
|
||||||
|
if err != nil {
|
||||||
|
log.Err(err).Msg("failed to open data/204.jpg")
|
||||||
|
}
|
||||||
|
w.Header().Set("Content-Type", "image/jpeg")
|
||||||
|
w.Write(buf)
|
||||||
|
return
|
||||||
|
|
||||||
|
}
|
||||||
|
*/
|
Loading…
Reference in a new issue