mirror of
https://github.com/Fluffy-Bean/Lynxie.git
synced 2025-05-14 08:02:17 +00:00
Don't require e621 command to be registered
This commit is contained in:
parent
b727751f31
commit
a70ca23e41
1 changed files with 7 additions and 2 deletions
|
@ -4,6 +4,7 @@ import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
|
@ -21,7 +22,11 @@ var username = os.Getenv("E621_USERNAME")
|
||||||
var password = os.Getenv("E621_PASSWORD")
|
var password = os.Getenv("E621_PASSWORD")
|
||||||
|
|
||||||
func RegisterPorbCommands(a *app.App) {
|
func RegisterPorbCommands(a *app.App) {
|
||||||
a.RegisterCommand("e621", registerE621(a))
|
if username != "" && password != "" {
|
||||||
|
a.RegisterCommand("e621", registerE621(a))
|
||||||
|
} else {
|
||||||
|
log.Println("Not registering e621 command...")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func registerE621(a *app.App) app.Callback {
|
func registerE621(a *app.App) app.Callback {
|
||||||
|
@ -59,7 +64,7 @@ func registerE621(a *app.App) app.Callback {
|
||||||
|
|
||||||
req.Header.Add("Accept", "application/json")
|
req.Header.Add("Accept", "application/json")
|
||||||
req.Header.Add("Content-Type", "application/json")
|
req.Header.Add("Content-Type", "application/json")
|
||||||
req.Header.Add("User-Agent", fmt.Sprintf("Lynxie/1.0 (by %s on e621)", username))
|
req.Header.Add("User-Agent", fmt.Sprintf("Lynxie/2.0 (by %s on e621)", username))
|
||||||
req.SetBasicAuth(username, password)
|
req.SetBasicAuth(username, password)
|
||||||
|
|
||||||
res, err := client.Do(req)
|
res, err := client.Do(req)
|
||||||
|
|
Loading…
Add table
Reference in a new issue