mirror of
https://github.com/MedzikUser/go-screenshot
synced 2024-08-15 03:15:46 +00:00
53 lines
816 B
Go
53 lines
816 B
Go
package main
|
|
|
|
import (
|
|
"flag"
|
|
"fmt"
|
|
"log"
|
|
"os"
|
|
|
|
"github.com/gtuk/discordwebhook"
|
|
"gitlab.com/gaming0skar123/go/screenshot/imgur"
|
|
)
|
|
|
|
var color = "1127128"
|
|
|
|
func main() {
|
|
var file string
|
|
flag.StringVar(&file, "f", "", "File location")
|
|
|
|
flag.Parse()
|
|
|
|
if file == "" {
|
|
log.Fatal("Empty file arg")
|
|
}
|
|
|
|
i := imgur.Upload(file)
|
|
|
|
fmt.Println("Uploaded!")
|
|
|
|
webhook := os.Getenv("DISCORD_WEBHOOK_URL")
|
|
|
|
domain := os.Getenv("PROXY_DOMAIN")
|
|
if domain == "" {
|
|
domain = "https://i.imgur.com"
|
|
}
|
|
|
|
url := domain + "/" + i.Data.IDExt
|
|
|
|
err := discordwebhook.SendMessage(webhook, discordwebhook.Message{
|
|
Embeds: &[]discordwebhook.Embed{
|
|
{
|
|
Title: &url,
|
|
Color: &color,
|
|
Image: &discordwebhook.Image{
|
|
Url: &url,
|
|
},
|
|
},
|
|
},
|
|
})
|
|
|
|
if err != nil || err.Error() != "" {
|
|
fmt.Println(err)
|
|
}
|
|
}
|