mirror of
https://github.com/MedzikUser/go-screenshot
synced 2024-08-15 03:15:46 +00:00
Update
This commit is contained in:
parent
b6c7a8774c
commit
ba56ea0533
10 changed files with 168 additions and 2 deletions
14
.github/dependabot.yml
vendored
Normal file
14
.github/dependabot.yml
vendored
Normal file
|
@ -0,0 +1,14 @@
|
|||
version: 2
|
||||
|
||||
updates:
|
||||
# Maintain dependencies for Go modules
|
||||
- package-ecosystem: "gomod"
|
||||
directory: "/"
|
||||
schedule:
|
||||
interval: "daily"
|
||||
|
||||
# Maintain dependencies for GitHub Actions
|
||||
- package-ecosystem: "github-actions"
|
||||
directory: "/"
|
||||
schedule:
|
||||
interval: "daily"
|
20
.github/workflows/lint.yml
vendored
Normal file
20
.github/workflows/lint.yml
vendored
Normal file
|
@ -0,0 +1,20 @@
|
|||
name: lint
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
push:
|
||||
|
||||
jobs:
|
||||
golangci:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v2
|
||||
with:
|
||||
go-version: 1.16
|
||||
- name: GolangCi Lint
|
||||
uses: golangci/golangci-lint-action@v2
|
||||
with:
|
||||
version: latest
|
27
.github/workflows/release.yml
vendored
Normal file
27
.github/workflows/release.yml
vendored
Normal file
|
@ -0,0 +1,27 @@
|
|||
name: goreleaser
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
push:
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
jobs:
|
||||
goreleaser:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v2
|
||||
with:
|
||||
go-version: 1.16
|
||||
- name: Run GoReleaser
|
||||
uses: goreleaser/goreleaser-action@v2
|
||||
with:
|
||||
distribution: goreleaser
|
||||
version: latest
|
||||
args: release --rm-dist
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
@ -1,8 +1,8 @@
|
|||
ports:
|
||||
- port: 8080
|
||||
|
||||
checkoutLocation: "go/src/cdn"
|
||||
workspaceLocation: "go/src/cdn"
|
||||
checkoutLocation: "go/src/screenshot"
|
||||
workspaceLocation: "go/src/screenshot"
|
||||
|
||||
vscode:
|
||||
extensions:
|
||||
|
|
22
.goreleaser.yml
Normal file
22
.goreleaser.yml
Normal file
|
@ -0,0 +1,22 @@
|
|||
project_name: screenshot
|
||||
|
||||
before:
|
||||
hooks:
|
||||
- go mod tidy
|
||||
|
||||
builds:
|
||||
- goos:
|
||||
- linux
|
||||
goarch:
|
||||
- amd64
|
||||
|
||||
binary: '{{ .ProjectName }}.out'
|
||||
|
||||
archives:
|
||||
- format: tar.gz
|
||||
|
||||
files:
|
||||
- none*
|
||||
|
||||
checksum:
|
||||
name_template: 'checksums.txt'
|
5
go.mod
5
go.mod
|
@ -1,3 +1,8 @@
|
|||
module gitlab.com/gaming0skar123/go/screenshot
|
||||
|
||||
go 1.16
|
||||
|
||||
require (
|
||||
github.com/gtuk/discordwebhook v1.0.0
|
||||
gitlab.com/gaming0skar123/go/modules/imgur v0.0.1-alpha.3
|
||||
)
|
||||
|
|
4
go.sum
Normal file
4
go.sum
Normal file
|
@ -0,0 +1,4 @@
|
|||
github.com/gtuk/discordwebhook v1.0.0 h1:xY21mwzScQQZeVkAPMQTB/XHIBx1lkjLeg7aALzTfOk=
|
||||
github.com/gtuk/discordwebhook v1.0.0/go.mod h1:U3LdXNJ1e0bx3MMe2a4mB1VBantPHOPly2jNd8ZWXec=
|
||||
gitlab.com/gaming0skar123/go/modules/imgur v0.0.1-alpha.3 h1:UKH8ZURQNfyav+cMpyjrf/WPkb7sLJiPUnezKlmQrX4=
|
||||
gitlab.com/gaming0skar123/go/modules/imgur v0.0.1-alpha.3/go.mod h1:Y8l7x4FzTVYVgQXCZJOMs8H7eDzlEyxhTBhW6FEr5Bo=
|
16
imgur/client.go
Normal file
16
imgur/client.go
Normal file
|
@ -0,0 +1,16 @@
|
|||
package imgur
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"os"
|
||||
|
||||
"gitlab.com/gaming0skar123/go/modules/imgur"
|
||||
)
|
||||
|
||||
var client *imgur.Client
|
||||
|
||||
func init() {
|
||||
client = new(imgur.Client)
|
||||
client.HTTPClient = new(http.Client)
|
||||
client.ImgurClientID = os.Getenv("IMGUR_CLIENT_ID")
|
||||
}
|
16
imgur/upload.go
Normal file
16
imgur/upload.go
Normal file
|
@ -0,0 +1,16 @@
|
|||
package imgur
|
||||
|
||||
import (
|
||||
"log"
|
||||
|
||||
"gitlab.com/gaming0skar123/go/modules/imgur"
|
||||
)
|
||||
|
||||
func Upload(path string) *imgur.ImageInfoData {
|
||||
i, _, err := client.UploadImageFromFile(path, "")
|
||||
if err != nil {
|
||||
log.Fatal("Error uploading image: " + err.Error())
|
||||
}
|
||||
|
||||
return i
|
||||
}
|
42
main.go
Normal file
42
main.go
Normal file
|
@ -0,0 +1,42 @@
|
|||
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")
|
||||
|
||||
discordwebhook.SendMessage(webhook, discordwebhook.Message{
|
||||
Embeds: &[]discordwebhook.Embed{
|
||||
{
|
||||
Title: &i.Data.Link,
|
||||
Color: &color,
|
||||
Image: &discordwebhook.Image{
|
||||
Url: &i.Data.Link,
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
Loading…
Reference in a new issue