Skip to content

Commit b3838e7

Browse files
committed
Refactor code and improve changes detection
Add github actions for lint, publish, and release Update README Add documentation
1 parent c990dfd commit b3838e7

File tree

213 files changed

+1028
-262168
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

213 files changed

+1028
-262168
lines changed

Diff for: .dockerignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ README.md
66
LICENSE
77
web-watcher
88
db.sqlite
9-
vendor
9+
dist/

Diff for: .github/images/gopher.png

191 KB
Loading

Diff for: .github/workflows/lint.yml

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: lint
2+
3+
on:
4+
push:
5+
pull_request:
6+
7+
jobs:
8+
build:
9+
name: Build
10+
runs-on: ubuntu-latest
11+
steps:
12+
13+
- name: Set up Go 1.14
14+
uses: actions/setup-go@v1
15+
with:
16+
go-version: 1.14
17+
id: go
18+
19+
- name: Check out code into the Go module directory
20+
uses: actions/checkout@v2
21+
22+
- name: Build
23+
run: go build -v .
24+
25+
- name: golangci-lint
26+
uses: actions-contrib/golangci-lint@v1
27+
env:
28+
GOROOT: ""

Diff for: .github/workflows/publish.yml

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: github pages
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
8+
defaults:
9+
run:
10+
shell: bash
11+
working-directory: www
12+
13+
jobs:
14+
deploy:
15+
runs-on: ubuntu-18.04
16+
steps:
17+
- uses: actions/checkout@v2
18+
with:
19+
submodules: true
20+
fetch-depth: 0
21+
22+
- name: Setup Hugo
23+
uses: peaceiris/actions-hugo@v2
24+
with:
25+
hugo-version: 'latest'
26+
27+
- name: Build
28+
run: hugo --minify
29+
30+
- name: Deploy
31+
uses: peaceiris/actions-gh-pages@v3
32+
with:
33+
github_token: ${{ secrets.GITHUB_TOKEN }}
34+
publish_dir: ./www/public

Diff for: .github/workflows/release.yml

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: release
2+
3+
on:
4+
push:
5+
tags:
6+
- '*'
7+
8+
jobs:
9+
goreleaser:
10+
runs-on: ubuntu-latest
11+
steps:
12+
-
13+
name: Checkout
14+
uses: actions/checkout@v2
15+
-
16+
name: Unshallow
17+
run: git fetch --prune --unshallow
18+
-
19+
name: Set up Go
20+
uses: actions/setup-go@v1
21+
with:
22+
go-version: 1.14.x
23+
-
24+
name: Docker login
25+
uses: azure/docker-login@v1
26+
with:
27+
login-server: docker.pkg.github.com
28+
username: ${{ secrets.DOCKER_USERNAME }}
29+
password: ${{ secrets.DOCKER_PASSWORD }}
30+
-
31+
name: Run GoReleaser
32+
uses: goreleaser/goreleaser-action@v1
33+
with:
34+
version: latest
35+
args: release --rm-dist
36+
env:
37+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Diff for: .gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@
1111
# Output of the go coverage tool, specifically when used with LiteIDE
1212
*.out
1313

14+
.DS_Store
15+
1416
db.sqlite
1517
web-watcher
1618
.idea/*
19+
vendor/
20+
dist/

Diff for: .gitmodules

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "www/themes/hugo-apex-theme"]
2+
path = www/themes/hugo-apex-theme
3+
url = https://github.com/caarlos0/hugo-apex-theme.git

Diff for: .goreleaser.yml

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
before:
2+
hooks:
3+
- go mod download
4+
archives:
5+
- replacements:
6+
darwin: Darwin
7+
linux: Linux
8+
windows: Windows
9+
386: i386
10+
amd64: x86_64
11+
checksum:
12+
name_template: 'checksums.txt'
13+
snapshot:
14+
name_template: "{{ .Tag }}-next"
15+
changelog:
16+
sort: asc
17+
filters:
18+
exclude:
19+
- '^docs:'
20+
- '^test:'
21+
22+
release:
23+
github:
24+
owner: shellbear
25+
name: web-watcher
26+
27+
dockers:
28+
-
29+
binaries:
30+
- web-watcher
31+
dockerfile: Dockerfile.cgo
32+
image_templates:
33+
- "docker.pkg.github.com/shellbear/web-watcher/web-watcher:{{ .Tag }}"
34+
- "docker.pkg.github.com/shellbear/web-watcher/web-watcher:latest"
35+
build_flag_templates:
36+
- "--pull"
37+
- "--label=org.opencontainers.image.created={{.Date}}"
38+
- "--label=org.opencontainers.image.name={{.ProjectName}}"
39+
- "--label=org.opencontainers.image.revision={{.FullCommit}}"
40+
- "--label=org.opencontainers.image.version={{.Version}}"
41+

Diff for: Dockerfile

+2-4
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,10 @@ FROM golang:latest
33
WORKDIR /app
44

55
COPY go.mod go.sum ./
6-
76
RUN go mod download
87

98
COPY . .
9+
RUN go build -o web-watcher .
1010

11-
RUN go build -o main .
12-
13-
CMD ["./main"]
11+
ENTRYPOINT ["/app/web-watcher"]
1412

Diff for: Dockerfile.cgo

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
FROM golang:latest
2+
3+
COPY web-watcher /
4+
5+
ENTRYPOINT ["/web-watcher"]

Diff for: README.md

+41-42
Original file line numberDiff line numberDiff line change
@@ -1,78 +1,77 @@
1-
# Web-watcher
2-
3-
A small discord bot which aims to monitor and send notifications on website changes.
4-
5-
## Installation
6-
7-
If you want to self host this bot, you have to first create a new Discord application and bot from the [developer portal](https://discordapp.com/developers/applications/).
8-
You can follow this [tutorial](https://github.com/reactiflux/discord-irc/wiki/Creating-a-discord-bot-&-getting-a-token) to achieve this step.
9-
10-
With go CLI:
11-
```bash
12-
go get github.com/ShellBear/web-watcher
13-
```
1+
<p align="center">
2+
<img alt="Gopher" src=".github/images/gopher.png" height="140" />
3+
<h3 align="center">web-watcher</h3>
4+
<p align="center">A small Discord bot which aims to alert you on website changes.</p>
5+
</p>
6+
7+
<p align="center">
8+
<a href="https://goreportcard.com/report/github.com/shellbear/web-watcher" alt="Go Report Card">
9+
<img src="https://goreportcard.com/badge/github.com/shellbear/web-watcher" />
10+
</a>
11+
<a href="https://github.com/shellbear/web-watcher/actions?query=workflow%3Alint" alt="Pipeline status">
12+
<img src="https://github.com/shellbear/web-watcher/workflows/lint/badge.svg" />
13+
</a>
14+
<a href="https://github.com/shellbear/web-watcher/actions?query=workflow%3A%22github+pages%22" alt="Pipeline status">
15+
<img src="https://github.com/shellbear/web-watcher/workflows/github%20pages/badge.svg" />
16+
</a>
17+
<img src="https://img.shields.io/github/go-mod/go-version/shellbear/web-watcher" alt="Go version" />
18+
<a href="https://opensource.org/licenses/MIT" alt="Go version">
19+
<img src="https://img.shields.io/badge/license-MIT-brightgreen.svg" />
20+
</a>
21+
</p>
22+
23+
---
24+
25+
## Documentation
26+
27+
A full documentation is available at [https://shellbear.github.io/web-watcher](https://shellbear.github.io/web-watcher).
1428

1529
## Usage
1630

1731
```bash
18-
export DISCORD_TOKEN=YOUR_DISCORD_TOKEN
19-
web-watcher
20-
21-
# or
22-
23-
web-watcher --token YOUR_DISCORD_TOKEN
24-
```
25-
26-
```bash
27-
web-watcher --help
28-
32+
> web-watcher --help
2933
Web-watcher discord Bot.
3034

3135
Options:
3236
-delay int
3337
Watch delay in minutes (default 60)
38+
-prefix string
39+
The discord commands prefix (default "!")
40+
-ratio float
41+
Changes detection ratio (default 1)
3442
-token string
3543
Discord token
3644
```
3745

38-
By default the watch interval for every website is 1 Hour but you can easily change this with the `delay` parameter followed by the time interval in minutes.
46+
By default, the watch interval for every website is 1 hour, but you can easily change this with the `interval` parameter
47+
followed by the interval in minutes.
3948

4049
```bash
4150
# Set watch interval to 10 minutes
42-
web-watcher --token YOUR_DISCORD_TOKEN --delay 10
51+
web-watcher --token YOUR_DISCORD_TOKEN --interval 10
4352
```
4453

45-
## Commands
54+
## Discord commands
4655

4756
#### !watch [URL]
4857

49-
Add an URL to the watchlist.
58+
Add a URL to the watchlist.
5059

5160
#### !unwatch [URL]
5261

53-
Remove an URL from the watchlist.
62+
Remove a URL from the watchlist.
5463

5564
#### !watchlist
5665

5766
Get the complete watchlist.
5867

59-
## Deploy
60-
61-
With docker:
62-
```bash
63-
docker build -t web-watcher .
64-
```
65-
66-
And test:
67-
```bash
68-
docker run -e DISCORD_TOKEN=YOUR_DISCORD_TOKEN web-watcher
69-
```
70-
7168
## Built With
7269

70+
- [go-difflib](https://github.com/pmezard/go-difflib) - Partial port of Python difflib package to Go
71+
- [xxhash](https://github.com/cespare/xxhash) - Go implementation of the 64-bit xxHash algorithm (XXH64)
7372
- [Gorm](https://github.com/jinzhu/gorm) - The fantastic ORM library for Golang
7473
- [DiscordGo](https://github.com/bwmarrin/discordgo) - Go bindings for Discord
7574

7675
## License
7776

78-
This project is licensed under the MIT License - see the [LICENSE](LICENSE.md) file for details
77+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details

0 commit comments

Comments
 (0)