mirror of
https://github.com/lyx0/nourybot.git
synced 2024-11-13 19:49:55 +01:00
remove predb
This commit is contained in:
parent
94eec48e44
commit
d55d0bd73e
2 changed files with 0 additions and 230 deletions
|
@ -184,22 +184,6 @@ func (app *application) handleCommand(message twitch.PrivateMessage) {
|
|||
case "nourybot":
|
||||
reply = "Lidl Twitch bot made by @nouryxd. Prefix: ()"
|
||||
|
||||
case "predb":
|
||||
switch cmdParams[1] {
|
||||
case "latest":
|
||||
if userLevel >= 100 {
|
||||
reply = app.PreDBLatest()
|
||||
}
|
||||
case "search":
|
||||
if userLevel >= 100 && len(message.Message) > 16 {
|
||||
reply = app.PreDBSearch(message.Message[15:len(message.Message)])
|
||||
}
|
||||
case "group":
|
||||
if userLevel >= 100 && len(message.Message) > 15 {
|
||||
reply = app.PreDBGroup(message.Message[14:len(message.Message)])
|
||||
}
|
||||
}
|
||||
|
||||
case "phonetic":
|
||||
if msgLen == 1 {
|
||||
reply = "Not enough arguments provided. Usage: ()phonetic <text to translate>"
|
||||
|
@ -612,20 +596,6 @@ var helpText = map[string]command{
|
|||
Level: "0",
|
||||
Usage: "()ping",
|
||||
},
|
||||
"predb search": {
|
||||
Name: "predb search",
|
||||
Alias: nil,
|
||||
Description: "Returns the last 100 predb.net search results for a given query.",
|
||||
Level: "100",
|
||||
Usage: "()predb search <query>",
|
||||
},
|
||||
"predb group": {
|
||||
Name: "predb group",
|
||||
Alias: nil,
|
||||
Description: "Returns the last 100 predb.net group results for a given release group.",
|
||||
Level: "100",
|
||||
Usage: "()predb group <group>",
|
||||
},
|
||||
"preview": {
|
||||
Name: "preview",
|
||||
Alias: []string{"preview", "thumbnail"},
|
||||
|
|
|
@ -1,200 +0,0 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type latestFullResult struct {
|
||||
Status string `json:"status"`
|
||||
Results int `json:"results"`
|
||||
Data []latestSingleResult `json:"data"`
|
||||
}
|
||||
|
||||
type latestSingleResult struct {
|
||||
ID string `json:"id"`
|
||||
PreTime string `json:"pretime"`
|
||||
Release string `json:"release"`
|
||||
Section string `json:"section"`
|
||||
Files string `json:"files"`
|
||||
Size float64 `json:"size"`
|
||||
Status string `json:"status"`
|
||||
Reason string `json:"reason"`
|
||||
Group string `json:"group"`
|
||||
Genre string `json:"genre"`
|
||||
URL string `json:"url"`
|
||||
NFO string `json:"nfo"`
|
||||
NFOImage string `json:"nfo_image"`
|
||||
}
|
||||
|
||||
func (app *application) PreDBLatest() string {
|
||||
baseUrl := "https://api.predb.net/?limit=100"
|
||||
|
||||
resp, err := http.Get(baseUrl)
|
||||
if err != nil {
|
||||
app.Log.Error(err)
|
||||
return "Something went wrong FeelsBadMan"
|
||||
}
|
||||
|
||||
defer resp.Body.Close()
|
||||
|
||||
body, err := io.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
app.Log.Error(err)
|
||||
return "Something went wrong FeelsBadMan"
|
||||
}
|
||||
|
||||
var release latestFullResult
|
||||
_ = json.Unmarshal([]byte(body), &release)
|
||||
|
||||
var ts []string
|
||||
for i := 0; i < release.Results; i++ {
|
||||
t := fmt.Sprintf("ID: %v\nRelease timestamp: %v\nRelease: %v\nSection: %v\nFiles: %v\nSize: %v\nStatus: %v\nReason: %v\nRelease group: %v\nRelease genre: %v\npredb.net: %v\nNFO URL: %v\nNFO Image URL: %v\n\n",
|
||||
release.Data[i].ID,
|
||||
release.Data[i].PreTime,
|
||||
release.Data[i].Release,
|
||||
release.Data[i].Section,
|
||||
release.Data[i].Files,
|
||||
release.Data[i].Size,
|
||||
release.Data[i].Status,
|
||||
release.Data[i].Reason,
|
||||
release.Data[i].Group,
|
||||
release.Data[i].Genre,
|
||||
fmt.Sprint("https://predb.net"+release.Data[i].URL),
|
||||
release.Data[i].NFO,
|
||||
release.Data[i].NFOImage,
|
||||
)
|
||||
ts = append(ts, t)
|
||||
|
||||
}
|
||||
|
||||
reply := app.YafUploadString(strings.Join(ts, ""))
|
||||
if err != nil {
|
||||
app.Log.Errorw("Error trying to retrieve all timers from database", err)
|
||||
return ""
|
||||
}
|
||||
return reply
|
||||
}
|
||||
|
||||
type searchFullResult struct {
|
||||
Status string `json:"status"`
|
||||
Results int `json:"results"`
|
||||
Data []searchSingleResult `json:"data"`
|
||||
}
|
||||
type searchSingleResult struct {
|
||||
ID int `json:"id"`
|
||||
PreTime int `json:"pretime"`
|
||||
Release string `json:"release"`
|
||||
Section string `json:"section"`
|
||||
Files int `json:"files"`
|
||||
Size float64 `json:"size"`
|
||||
Status int `json:"status"`
|
||||
Reason string `json:"reason"`
|
||||
Group string `json:"group"`
|
||||
Genre string `json:"genre"`
|
||||
URL string `json:"url"`
|
||||
NFO string `json:"nfo"`
|
||||
NFOImage string `json:"nfo_image"`
|
||||
}
|
||||
|
||||
func (app *application) PreDBSearch(title string) string {
|
||||
escaped := fmt.Sprintf("https://api.predb.net/?q=%s&order_by=pretime&sort=desc&limit=100", url.QueryEscape(title))
|
||||
|
||||
resp, err := http.Get(escaped)
|
||||
if err != nil {
|
||||
app.Log.Error(err)
|
||||
return "Something went wrong FeelsBadMan"
|
||||
}
|
||||
|
||||
defer resp.Body.Close()
|
||||
|
||||
body, err := io.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
app.Log.Error(err)
|
||||
return "Something went wrong FeelsBadMan"
|
||||
}
|
||||
|
||||
var release searchFullResult
|
||||
_ = json.Unmarshal([]byte(body), &release)
|
||||
|
||||
var ts []string
|
||||
for i := 0; i < release.Results; i++ {
|
||||
t := fmt.Sprintf("ID: %v\nRelease timestamp: %v\nRelease: %v\nSection: %v\nFiles: %v\nSize: %v\nStatus: %v\nReason: %v\nRelease group: %v\nRelease genre: %v\npredb.net: %v\nNFO URL: %v\nNFO Image URL: %v\n\n",
|
||||
release.Data[i].ID,
|
||||
release.Data[i].PreTime,
|
||||
release.Data[i].Release,
|
||||
release.Data[i].Section,
|
||||
release.Data[i].Files,
|
||||
release.Data[i].Size,
|
||||
release.Data[i].Status,
|
||||
release.Data[i].Reason,
|
||||
release.Data[i].Group,
|
||||
release.Data[i].Genre,
|
||||
fmt.Sprint("https://predb.net"+release.Data[i].URL),
|
||||
release.Data[i].NFO,
|
||||
release.Data[i].NFOImage,
|
||||
)
|
||||
ts = append(ts, t)
|
||||
|
||||
}
|
||||
|
||||
reply := app.YafUploadString(strings.Join(ts, ""))
|
||||
if err != nil {
|
||||
app.Log.Errorw("Error trying to retrieve all timers from database", err)
|
||||
return ""
|
||||
}
|
||||
return reply
|
||||
}
|
||||
|
||||
func (app *application) PreDBGroup(group string) string {
|
||||
escaped := fmt.Sprintf("https://api.predb.net/?group=%s&order_by=pretime&sort=desc&limit=100", url.QueryEscape(group))
|
||||
|
||||
resp, err := http.Get(escaped)
|
||||
if err != nil {
|
||||
app.Log.Error(err)
|
||||
return "Something went wrong FeelsBadMan"
|
||||
}
|
||||
|
||||
defer resp.Body.Close()
|
||||
|
||||
body, err := io.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
app.Log.Error(err)
|
||||
return "Something went wrong FeelsBadMan"
|
||||
}
|
||||
|
||||
var release searchFullResult
|
||||
_ = json.Unmarshal([]byte(body), &release)
|
||||
|
||||
var ts []string
|
||||
for i := 0; i < release.Results; i++ {
|
||||
t := fmt.Sprintf("ID: %v\nRelease timestamp: %v\nRelease: %v\nSection: %v\nFiles: %v\nSize: %v\nStatus: %v\nReason: %v\nRelease group: %v\nRelease genre: %v\npredb.net: %v\nNFO URL: %v\nNFO Image URL: %v\n\n",
|
||||
release.Data[i].ID,
|
||||
release.Data[i].PreTime,
|
||||
release.Data[i].Release,
|
||||
release.Data[i].Section,
|
||||
release.Data[i].Files,
|
||||
release.Data[i].Size,
|
||||
release.Data[i].Status,
|
||||
release.Data[i].Reason,
|
||||
release.Data[i].Group,
|
||||
release.Data[i].Genre,
|
||||
fmt.Sprint("https://predb.net"+release.Data[i].URL),
|
||||
release.Data[i].NFO,
|
||||
release.Data[i].NFOImage,
|
||||
)
|
||||
ts = append(ts, t)
|
||||
|
||||
}
|
||||
|
||||
reply := app.YafUploadString(strings.Join(ts, ""))
|
||||
if err != nil {
|
||||
app.Log.Errorw("Error trying to retrieve all timers from database", err)
|
||||
return "Something went wrong FeelsBadMan"
|
||||
}
|
||||
return reply
|
||||
}
|
Loading…
Reference in a new issue