mirror of
https://github.com/kha7iq/pingme.git
synced 2025-05-15 22:30:11 -07:00
Compare commits
46 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
2d36d68023 | ||
|
6c02fbd8d4 | ||
|
f24407ea7e | ||
|
b9f2293cee | ||
|
4374f0864b | ||
|
fe6ac6a8d0 | ||
|
c663b2da6e | ||
|
8989698d25 | ||
|
daae65b4ba | ||
|
138ff38891 | ||
|
a2a91ace45 | ||
|
9dca2a1b74 | ||
|
7277d3386f | ||
|
5220398da3 | ||
|
98891789cf | ||
|
6629fac687 | ||
|
db4a0fe266 | ||
|
600ce268ac | ||
|
a233a22c70 | ||
|
888b989e67 | ||
|
3ec42b8a4b | ||
|
6786a1d80b | ||
|
5ed11059e0 | ||
|
8b190506ff | ||
|
1fed68e69c | ||
|
ba9185e93a | ||
|
3e3bd04861 | ||
|
c23aa335fc | ||
|
111c27d9cd | ||
|
2e450056eb | ||
|
aea178cb18 | ||
|
300293b85b | ||
|
cb0531d66f | ||
|
4338ba4056 | ||
|
ab93bcc203 | ||
|
ab46bee38b | ||
|
e69a3b2191 | ||
|
dd970e43e2 | ||
|
a6485a2702 | ||
|
f9d0d5a93d | ||
|
4c363e1192 | ||
|
fa26243b53 | ||
|
b6ee47a24e | ||
|
ba7070ecc9 | ||
|
b841854e09 | ||
|
93ecd78272 |
6
.github/aur/pingme-bin/.SRCINFO.template
vendored
6
.github/aur/pingme-bin/.SRCINFO.template
vendored
@ -11,13 +11,13 @@ pkgbase = pingme-bin
|
|||||||
provides = ${_PKGNAME}
|
provides = ${_PKGNAME}
|
||||||
conflicts = ${_PKGNAME}
|
conflicts = ${_PKGNAME}
|
||||||
|
|
||||||
source_x86_64 = ${_PKGNAME}_${PKGVER}_linux_x86_64.tar.gz::https://github.com/kha7iq/${_PKGNAME}/releases/download/v${PKGVER}/${_PKGNAME}_linux_x86_64.tar.gz")
|
source_x86_64 = ${_PKGNAME}_${pkgver}_linux_x86_64.tar.gz::https://github.com/kha7iq/${_PKGNAME}/releases/download/v${pkgver}/${_PKGNAME}_linux_x86_64.tar.gz")
|
||||||
sha256sums_x86_64 = (${SHA256SUM_X86})
|
sha256sums_x86_64 = (${SHA256SUM_X86})
|
||||||
|
|
||||||
source_i686 = ${_PKGNAME}_${PKGVER}_linux_i386.tar.gz::https://github.com/kha7iq/${_PKGNAME}/releases/download/v${PKGVER}/${_PKGNAME}_linux_i386.tar.gz")
|
source_i686 = ${_PKGNAME}_${pkgver}_linux_i386.tar.gz::https://github.com/kha7iq/${_PKGNAME}/releases/download/v${pkgver}/${_PKGNAME}_linux_i386.tar.gz")
|
||||||
sha256sums_i686 = (${SHA256SUM_i686})
|
sha256sums_i686 = (${SHA256SUM_i686})
|
||||||
|
|
||||||
source_aarch64 = ${_PKGNAME}_${PKGVER}_linux_arm64.tar.gz::https://github.com/kha7iq/${_PKGNAME}/releases/download/v${PKGVER}/${_PKGNAME}_linux_arm64.tar.gz")
|
source_aarch64 = ${_PKGNAME}_${pkgver}_linux_arm64.tar.gz::https://github.com/kha7iq/${_PKGNAME}/releases/download/v${pkgver}/${_PKGNAME}_linux_arm64.tar.gz")
|
||||||
sha256sums_aarch64 = (${SHA256SUM_AARCH64})
|
sha256sums_aarch64 = (${SHA256SUM_AARCH64})
|
||||||
|
|
||||||
pkgname = pingme-bin
|
pkgname = pingme-bin
|
||||||
|
11
.github/aur/pingme-bin/publish.sh
vendored
11
.github/aur/pingme-bin/publish.sh
vendored
@ -5,7 +5,7 @@ set -e
|
|||||||
|
|
||||||
WD=$(cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd)
|
WD=$(cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd)
|
||||||
PKGNAME=$(basename $WD)
|
PKGNAME=$(basename $WD)
|
||||||
|
repo="kha7iq/pingme"
|
||||||
export _PKGNAME="${PKGNAME%-bin}"
|
export _PKGNAME="${PKGNAME%-bin}"
|
||||||
ROOT=${WD%/.github/aur/$PKGNAME}
|
ROOT=${WD%/.github/aur/$PKGNAME}
|
||||||
|
|
||||||
@ -14,8 +14,9 @@ exec 100>$LOCKFILE || exit 0
|
|||||||
flock -n 100 || exit 0
|
flock -n 100 || exit 0
|
||||||
trap "rm -f $LOCKFILE" EXIT
|
trap "rm -f $LOCKFILE" EXIT
|
||||||
|
|
||||||
export VERSION=$1
|
export PKGVER=$(curl -s https://api.github.com/repos/$repo/releases/latest | grep -o '"tag_name": "v[^"]*' | cut -d'"' -f4 | sed 's/^v//')
|
||||||
echo "Publishing to AUR as version ${VERSION}"
|
|
||||||
|
echo "Publishing to AUR as version ${PKGVER}"
|
||||||
|
|
||||||
cd $WD
|
cd $WD
|
||||||
|
|
||||||
@ -36,8 +37,6 @@ git clone aur@aur.archlinux.org:$PKGNAME $GITDIR 2>&1
|
|||||||
CURRENT_PKGVER=$(cat $GITDIR/.SRCINFO | grep pkgver | awk '{ print $3 }')
|
CURRENT_PKGVER=$(cat $GITDIR/.SRCINFO | grep pkgver | awk '{ print $3 }')
|
||||||
CURRENT_PKGREL=$(cat $GITDIR/.SRCINFO | grep pkgrel | awk '{ print $3 }')
|
CURRENT_PKGREL=$(cat $GITDIR/.SRCINFO | grep pkgrel | awk '{ print $3 }')
|
||||||
|
|
||||||
export PKGVER=${VERSION/-/}
|
|
||||||
|
|
||||||
if [[ "${CURRENT_PKGVER}" == "${PKGVER}" ]]; then
|
if [[ "${CURRENT_PKGVER}" == "${PKGVER}" ]]; then
|
||||||
export PKGREL=$((CURRENT_PKGREL+1))
|
export PKGREL=$((CURRENT_PKGREL+1))
|
||||||
else
|
else
|
||||||
@ -54,7 +53,7 @@ envsubst '$PKGVER $PKGREL $_PKGNAME $SHA256SUM_X86 $SHA256SUM_i686 $SHA256SUM_AA
|
|||||||
envsubst '$PKGVER $PKGREL $SHA256SUM_X86 $SHA256SUM_i686 $SHA256SUM_AARCH64' < PKGBUILD.template > $GITDIR/PKGBUILD
|
envsubst '$PKGVER $PKGREL $SHA256SUM_X86 $SHA256SUM_i686 $SHA256SUM_AARCH64' < PKGBUILD.template > $GITDIR/PKGBUILD
|
||||||
|
|
||||||
cd $GITDIR
|
cd $GITDIR
|
||||||
git config user.name "GoReleaser"
|
git config user.name "kha7iq"
|
||||||
git config user.email "a.khaliq@outlook.my"
|
git config user.email "a.khaliq@outlook.my"
|
||||||
git add -A
|
git add -A
|
||||||
if [ -z "$(git status --porcelain)" ]; then
|
if [ -z "$(git status --porcelain)" ]; then
|
||||||
|
2
.github/aur/pingme/.SRCINFO.template
vendored
2
.github/aur/pingme/.SRCINFO.template
vendored
@ -8,6 +8,6 @@ pkgbase = pingme
|
|||||||
arch = aarch64
|
arch = aarch64
|
||||||
license = MIT
|
license = MIT
|
||||||
makedepends = go
|
makedepends = go
|
||||||
source = pingme-${PKGVER}.tar.gz::https://github.com/kha7iq/pingme/archive/v{PKGVER}.tar.gz
|
source = pingme-${pkgver}.tar.gz::https://github.com/kha7iq/${pkgname}/archive/v${pkgver}.tar.gz
|
||||||
|
|
||||||
pkgname = pingme
|
pkgname = pingme
|
||||||
|
2
.github/aur/pingme/PKGBUILD.template
vendored
2
.github/aur/pingme/PKGBUILD.template
vendored
@ -18,7 +18,7 @@ sha256sums=(
|
|||||||
build() {
|
build() {
|
||||||
cd "${pkgname}-${pkgver}"
|
cd "${pkgname}-${pkgver}"
|
||||||
export CGO_LDFLAGS="$LDFLAGS"
|
export CGO_LDFLAGS="$LDFLAGS"
|
||||||
go build -ldflags "-linkmode=external -s -w -X main.version=${pkgver}" -o ${pkgname} .
|
go build -ldflags "-linkmode=external -s -w -X main.Version=${pkgver}" -o ${pkgname} .
|
||||||
}
|
}
|
||||||
|
|
||||||
package() {
|
package() {
|
||||||
|
11
.github/aur/pingme/publish.sh
vendored
11
.github/aur/pingme/publish.sh
vendored
@ -5,14 +5,17 @@ set -e
|
|||||||
WD=$(cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd)
|
WD=$(cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd)
|
||||||
PKGNAME=$(basename $WD)
|
PKGNAME=$(basename $WD)
|
||||||
ROOT=${WD%/.github/aur/$PKGNAME}
|
ROOT=${WD%/.github/aur/$PKGNAME}
|
||||||
|
repo="kha7iq/pingme"
|
||||||
|
|
||||||
LOCKFILE=/tmp/aur-$PKGNAME.lock
|
LOCKFILE=/tmp/aur-$PKGNAME.lock
|
||||||
exec 100>$LOCKFILE || exit 0
|
exec 100>$LOCKFILE || exit 0
|
||||||
flock -n 100 || exit 0
|
flock -n 100 || exit 0
|
||||||
trap "rm -f $LOCKFILE" EXIT
|
trap "rm -f $LOCKFILE" EXIT
|
||||||
|
|
||||||
export VERSION=$1
|
|
||||||
echo "Publishing to AUR as version ${VERSION}"
|
export PKGVER=$(curl -s https://api.github.com/repos/$repo/releases/latest | grep -o '"tag_name": "v[^"]*' | cut -d'"' -f4 | sed 's/^v//')
|
||||||
|
|
||||||
|
echo "Publishing to AUR as version ${PKGVER}"
|
||||||
|
|
||||||
cd $WD
|
cd $WD
|
||||||
|
|
||||||
@ -33,7 +36,6 @@ git clone aur@aur.archlinux.org:$PKGNAME $GITDIR 2>&1
|
|||||||
CURRENT_PKGVER=$(cat $GITDIR/.SRCINFO | grep pkgver | awk '{ print $3 }')
|
CURRENT_PKGVER=$(cat $GITDIR/.SRCINFO | grep pkgver | awk '{ print $3 }')
|
||||||
CURRENT_PKGREL=$(cat $GITDIR/.SRCINFO | grep pkgrel | awk '{ print $3 }')
|
CURRENT_PKGREL=$(cat $GITDIR/.SRCINFO | grep pkgrel | awk '{ print $3 }')
|
||||||
|
|
||||||
export PKGVER=${VERSION/-/}
|
|
||||||
|
|
||||||
if [[ "${CURRENT_PKGVER}" == "${PKGVER}" ]]; then
|
if [[ "${CURRENT_PKGVER}" == "${PKGVER}" ]]; then
|
||||||
export PKGREL=$((CURRENT_PKGREL+1))
|
export PKGREL=$((CURRENT_PKGREL+1))
|
||||||
@ -47,7 +49,8 @@ envsubst '$PKGVER $PKGREL $SHA256SUM' < .SRCINFO.template > $GITDIR/.SRCINFO
|
|||||||
envsubst '$PKGVER $PKGREL $SHA256SUM' < PKGBUILD.template > $GITDIR/PKGBUILD
|
envsubst '$PKGVER $PKGREL $SHA256SUM' < PKGBUILD.template > $GITDIR/PKGBUILD
|
||||||
|
|
||||||
cd $GITDIR
|
cd $GITDIR
|
||||||
git config user.name "GoReleaser"
|
|
||||||
|
git config user.name "kha7iq"
|
||||||
git config user.email "a.khaliq@outlook.my"
|
git config user.email "a.khaliq@outlook.my"
|
||||||
git add -A
|
git add -A
|
||||||
if [ -z "$(git status --porcelain)" ]; then
|
if [ -z "$(git status --porcelain)" ]; then
|
||||||
|
49
.github/workflows/build.yml
vendored
49
.github/workflows/build.yml
vendored
@ -2,10 +2,6 @@ name: build
|
|||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
# branches:
|
|
||||||
# - 'master'
|
|
||||||
# paths-ignore:
|
|
||||||
# - '**.md'
|
|
||||||
tags:
|
tags:
|
||||||
- 'v0.[0-9]+.[0-9]'
|
- 'v0.[0-9]+.[0-9]'
|
||||||
|
|
||||||
@ -15,55 +11,39 @@ jobs:
|
|||||||
env:
|
env:
|
||||||
DOCKER_CLI_EXPERIMENTAL: "enabled"
|
DOCKER_CLI_EXPERIMENTAL: "enabled"
|
||||||
steps:
|
steps:
|
||||||
-
|
- name: Checkout
|
||||||
name: Checkout
|
uses: actions/checkout@v4
|
||||||
uses: actions/checkout@v2.3.4
|
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
-
|
|
||||||
name: Set up Go
|
- name: Set up Go
|
||||||
uses: actions/setup-go@v2
|
uses: actions/setup-go@v4
|
||||||
with:
|
with:
|
||||||
go-version: '1.16'
|
go-version: '>=1.20.0'
|
||||||
-
|
|
||||||
name: Cache Go modules
|
- name: Docker login GHCR
|
||||||
uses: actions/cache@v2.1.5
|
|
||||||
with:
|
|
||||||
path: ~/go/pkg/mod
|
|
||||||
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
|
|
||||||
restore-keys: |
|
|
||||||
${{ runner.os }}-go-
|
|
||||||
-
|
|
||||||
name: Diff
|
|
||||||
run: git diff
|
|
||||||
|
|
||||||
-
|
|
||||||
name: Docker login GHCR
|
|
||||||
uses: docker/login-action@v1
|
uses: docker/login-action@v1
|
||||||
with:
|
with:
|
||||||
registry: ghcr.io
|
registry: ghcr.io
|
||||||
username: ${{ github.repository_owner }}
|
username: ${{ github.repository_owner }}
|
||||||
password: ${{ secrets.GITHUB_TOKEN }}
|
password: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
-
|
- name: Docker Login DockerHub
|
||||||
name: Docker Login DockerHub
|
|
||||||
uses: docker/login-action@v1
|
uses: docker/login-action@v1
|
||||||
with:
|
with:
|
||||||
username: ${{ secrets.DOCKER_USERNAME }}
|
username: ${{ secrets.DOCKER_USERNAME }}
|
||||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||||
|
|
||||||
-
|
- name: Release PingMe
|
||||||
name: Release PingMe
|
uses: goreleaser/goreleaser-action@v3
|
||||||
uses: goreleaser/goreleaser-action@v2
|
|
||||||
with:
|
with:
|
||||||
version: latest
|
version: latest
|
||||||
args: release --rm-dist
|
args: release --clean
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }}
|
||||||
AUR_SSH_PRIVATE_KEY: ${{ secrets.AUR_SSH_PRIVATE_KEY }}
|
AUR_SSH_PRIVATE_KEY: ${{ secrets.AUR_SSH_PRIVATE_KEY }}
|
||||||
|
|
||||||
-
|
- name: Notify on failure
|
||||||
name: Notify on failure
|
|
||||||
uses: kha7iq/pingme-action@v1
|
uses: kha7iq/pingme-action@v1
|
||||||
if: failure()
|
if: failure()
|
||||||
env:
|
env:
|
||||||
@ -74,8 +54,7 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
service: telegram
|
service: telegram
|
||||||
|
|
||||||
-
|
- name: Notify on success
|
||||||
name: Notify on success
|
|
||||||
uses: kha7iq/pingme-action@v1
|
uses: kha7iq/pingme-action@v1
|
||||||
if: success()
|
if: success()
|
||||||
env:
|
env:
|
||||||
|
14
.github/workflows/pull_request.yml
vendored
14
.github/workflows/pull_request.yml
vendored
@ -1,14 +0,0 @@
|
|||||||
on: pull_request
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
lint-code:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
name: Perform Checks
|
|
||||||
steps:
|
|
||||||
- name: Checkout
|
|
||||||
uses: actions/checkout@v2
|
|
||||||
|
|
||||||
- name: golangci-lint
|
|
||||||
uses: golangci/golangci-lint-action@v2
|
|
||||||
with:
|
|
||||||
version: v1.29
|
|
@ -12,10 +12,15 @@ builds:
|
|||||||
- darwin
|
- darwin
|
||||||
- windows
|
- windows
|
||||||
goarch:
|
goarch:
|
||||||
- 386
|
- "386"
|
||||||
- amd64
|
- amd64
|
||||||
- arm
|
- arm
|
||||||
- arm64
|
- arm64
|
||||||
|
goarm:
|
||||||
|
- "7"
|
||||||
|
ignore:
|
||||||
|
- goos: windows
|
||||||
|
goarch: arm64
|
||||||
mod_timestamp: '{{ .CommitTimestamp }}'
|
mod_timestamp: '{{ .CommitTimestamp }}'
|
||||||
flags:
|
flags:
|
||||||
- -trimpath
|
- -trimpath
|
||||||
@ -30,19 +35,21 @@ changelog:
|
|||||||
exclude: ['^docs:', '^test:', 'Merge pull request', 'Merge branch', 'go mod tidy']
|
exclude: ['^docs:', '^test:', 'Merge pull request', 'Merge branch', 'go mod tidy']
|
||||||
|
|
||||||
archives:
|
archives:
|
||||||
- name_template: '{{ .ProjectName }}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}'
|
- name_template: >-
|
||||||
replacements:
|
{{ .ProjectName }}_
|
||||||
darwin: Darwin
|
{{- title .Os }}_
|
||||||
linux: Linux
|
{{- if eq .Arch "amd64" }}x86_64
|
||||||
windows: Windows
|
{{- else if eq .Arch "386" }}i386
|
||||||
386: i386
|
{{- else }}{{ .Arch }}{{ end }}
|
||||||
amd64: x86_64
|
|
||||||
format_overrides:
|
format_overrides:
|
||||||
- goos: windows
|
- goos: windows
|
||||||
format: zip
|
format: zip
|
||||||
|
files:
|
||||||
|
- README.md
|
||||||
|
- LICENSE.md
|
||||||
|
|
||||||
brews:
|
brews:
|
||||||
- tap:
|
- repository:
|
||||||
owner: kha7iq
|
owner: kha7iq
|
||||||
name: homebrew-tap
|
name: homebrew-tap
|
||||||
folder: Formula
|
folder: Formula
|
||||||
@ -56,6 +63,7 @@ brews:
|
|||||||
|
|
||||||
nfpms:
|
nfpms:
|
||||||
- file_name_template: '{{ .ProjectName }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}'
|
- file_name_template: '{{ .ProjectName }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}'
|
||||||
|
maintainer: 'Abdul Khaliq <a.khaliq@outlook.my>'
|
||||||
homepage: pingme.lmno.pk
|
homepage: pingme.lmno.pk
|
||||||
description: PingMe is a CLI tool which provides the ability to send messages or alerts to multiple messaging platforms.
|
description: PingMe is a CLI tool which provides the ability to send messages or alerts to multiple messaging platforms.
|
||||||
license: MIT
|
license: MIT
|
||||||
@ -65,21 +73,11 @@ nfpms:
|
|||||||
dependencies:
|
dependencies:
|
||||||
- git
|
- git
|
||||||
|
|
||||||
# snapcrafts:
|
scoops:
|
||||||
# - name_template: '{{ .ProjectName }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}'
|
- repository:
|
||||||
# summary: PingMe is a CLI tool which provides the ability to send messages
|
|
||||||
# description: |
|
|
||||||
# PingMe is a CLI tool which provides the ability to send messages
|
|
||||||
# or alerts to multiple messaging platforms.
|
|
||||||
# grade: stable
|
|
||||||
# confinement: strict
|
|
||||||
# publish: false
|
|
||||||
|
|
||||||
scoop:
|
|
||||||
url_template: "https://github.com/kha7iq/pingme/releases/download/{{ .Tag }}/{{ .ArtifactName }}"
|
|
||||||
bucket:
|
|
||||||
owner: kha7iq
|
owner: kha7iq
|
||||||
name: scoop-bucket
|
name: scoop-bucket
|
||||||
|
url_template: "https://github.com/kha7iq/pingme/releases/download/{{ .Tag }}/{{ .ArtifactName }}"
|
||||||
homepage: https://pingme.lmno.pk
|
homepage: https://pingme.lmno.pk
|
||||||
description: PingMe is a CLI tool which provides the ability to send messages or alerts to multiple messaging platforms.
|
description: PingMe is a CLI tool which provides the ability to send messages or alerts to multiple messaging platforms.
|
||||||
license: MIT
|
license: MIT
|
||||||
@ -100,16 +98,3 @@ dockers:
|
|||||||
- "--label=org.opencontainers.image.version={{.Version}}"
|
- "--label=org.opencontainers.image.version={{.Version}}"
|
||||||
- "--label=org.opencontainers.image.source={{.GitURL}}"
|
- "--label=org.opencontainers.image.source={{.GitURL}}"
|
||||||
- "--platform=linux/amd64"
|
- "--platform=linux/amd64"
|
||||||
|
|
||||||
publishers:
|
|
||||||
- name: aur pingme binary
|
|
||||||
env:
|
|
||||||
- AUR_SSH_PRIVATE_KEY={{ .Env.AUR_SSH_PRIVATE_KEY }}
|
|
||||||
cmd: |
|
|
||||||
.github/aur/pingme-bin/publish.sh {{ .Version }}
|
|
||||||
|
|
||||||
- name: aur pingme sources
|
|
||||||
env:
|
|
||||||
- AUR_SSH_PRIVATE_KEY={{ .Env.AUR_SSH_PRIVATE_KEY }}
|
|
||||||
cmd: |
|
|
||||||
.github/aur/pingme/publish.sh {{ .Version }}
|
|
||||||
|
35
README.md
35
README.md
@ -12,8 +12,6 @@
|
|||||||
<img alt="Release" src="https://img.shields.io/github/v/release/kha7iq/pingme">
|
<img alt="Release" src="https://img.shields.io/github/v/release/kha7iq/pingme">
|
||||||
<a href="https://goreportcard.com/report/github.com/kha7iq/pingme">
|
<a href="https://goreportcard.com/report/github.com/kha7iq/pingme">
|
||||||
<img alt="Go Report Card" src="https://goreportcard.com/badge/github.com/kha7iq/pingme">
|
<img alt="Go Report Card" src="https://goreportcard.com/badge/github.com/kha7iq/pingme">
|
||||||
<a href="#">
|
|
||||||
<img alt="Build" src="https://img.shields.io/github/workflow/status/kha7iq/pingme/goreleaser">
|
|
||||||
<a href="https://github.com/kha7iq/pingme/issues">
|
<a href="https://github.com/kha7iq/pingme/issues">
|
||||||
<img alt="GitHub issues" src="https://img.shields.io/github/issues/kha7iq/pingme?style=flat-square&logo=github&logoColor=white">
|
<img alt="GitHub issues" src="https://img.shields.io/github/issues/kha7iq/pingme?style=flat-square&logo=github&logoColor=white">
|
||||||
<a href="https://github.com/kha7iq/pingme/blob/master/LICENSE.md">
|
<a href="https://github.com/kha7iq/pingme/blob/master/LICENSE.md">
|
||||||
@ -31,7 +29,6 @@
|
|||||||
<a href="#github-action">Github Action</a> •
|
<a href="#github-action">Github Action</a> •
|
||||||
<a href="#configuration">Configuration</a> •
|
<a href="#configuration">Configuration</a> •
|
||||||
<a href="#contributing">Contributing</a> •
|
<a href="#contributing">Contributing</a> •
|
||||||
<a href="#show-your-support">Show Your Support</a>
|
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
---
|
---
|
||||||
@ -77,6 +74,19 @@ platforms.
|
|||||||
brew install kha7iq/tap/pingme
|
brew install kha7iq/tap/pingme
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
## Shell Script
|
||||||
|
By default pingme is going to be installed at `/usr/bin/` sudo is requried for this operation.
|
||||||
|
|
||||||
|
If you would like to provide a custom install path you can do so as input to script. i.e `./install.sh $HOME/bin`
|
||||||
|
```bash
|
||||||
|
curl -s https://raw.githubusercontent.com/kha7iq/pingme/master/install.sh | sudo sh
|
||||||
|
```
|
||||||
|
or
|
||||||
|
```bash
|
||||||
|
curl -sL https://bit.ly/installpm | sudo sh
|
||||||
|
```
|
||||||
|
|
||||||
## Linux
|
## Linux
|
||||||
|
|
||||||
* AUR
|
* AUR
|
||||||
@ -89,15 +99,20 @@ yay -S pingme-bin
|
|||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
* Binary
|
## Manual
|
||||||
```bash
|
```bash
|
||||||
export PINGME_VERSION="0.2.3"
|
# Chose desired version, architecture & target os
|
||||||
wget -q https://github.com/kha7iq/pingme/releases/download/v${PINGME_VERSION}/pingme_Linux_x86_64.tar.gz && \
|
export PINGME_VERSION="0.2.6"
|
||||||
tar -xf pingme_Linux_x86_64.tar.gz && \
|
export ARCH="x86_64"
|
||||||
|
export OS="Linux"
|
||||||
|
wget -q https://github.com/kha7iq/pingme/releases/download/v${PINGME_VERSION}/pingme_${OS}_${ARCH}.tar.gz && \
|
||||||
|
tar -xf pingme_${OS}_${ARCH}.tar.gz && \
|
||||||
chmod +x pingme && \
|
chmod +x pingme && \
|
||||||
sudo mv pingme /usr/local/bin/pingme
|
sudo mv pingme /usr/local/bin/pingme
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### Windows
|
### Windows
|
||||||
|
|
||||||
```powershell
|
```powershell
|
||||||
@ -200,10 +215,6 @@ Contributions, issues and feature requests are welcome!<br/>Feel free to check
|
|||||||
[issues page](https://github.com/kha7iq/pingme/issues). You can also take a look
|
[issues page](https://github.com/kha7iq/pingme/issues). You can also take a look
|
||||||
at the [contributing guide](https://github.com/kha7iq/pingme/blob/master/CONTRIBUTING.md).
|
at the [contributing guide](https://github.com/kha7iq/pingme/blob/master/CONTRIBUTING.md).
|
||||||
|
|
||||||
## Show your support
|
|
||||||
|
|
||||||
Give a ⭐️ if you like this project!
|
|
||||||
|
|
||||||
## Acknowledgments
|
## Acknowledgments
|
||||||
|
|
||||||
This project is based on amazing library [Notify](https://github.com/nikoksr/notify)
|
This project is based on amazing library [Notify](https://github.com/nikoksr/notify)
|
||||||
|
@ -54,6 +54,7 @@ platforms.
|
|||||||
- *Line*
|
- *Line*
|
||||||
- *Mastodon*
|
- *Mastodon*
|
||||||
- *Mattermost*
|
- *Mattermost*
|
||||||
|
- *Matrix*
|
||||||
- *Microsoft Teams*
|
- *Microsoft Teams*
|
||||||
- *Pushbullet*
|
- *Pushbullet*
|
||||||
- *Pushover*
|
- *Pushover*
|
||||||
|
@ -6,7 +6,6 @@
|
|||||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
|
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
|
||||||
<meta name="description" content="Description">
|
<meta name="description" content="Description">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0">
|
||||||
<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/docsify@4/lib/themes/vue.css">
|
|
||||||
<link
|
<link
|
||||||
rel="stylesheet"
|
rel="stylesheet"
|
||||||
href="//cdn.jsdelivr.net/npm/docsify-darklight-theme@latest/dist/style.min.css"
|
href="//cdn.jsdelivr.net/npm/docsify-darklight-theme@latest/dist/style.min.css"
|
||||||
@ -19,11 +18,31 @@
|
|||||||
<script>
|
<script>
|
||||||
window.$docsify = {
|
window.$docsify = {
|
||||||
homepage: 'home.md',
|
homepage: 'home.md',
|
||||||
|
siteFont : 'Source Sans Pro',
|
||||||
|
defaultTheme : 'light | dark',
|
||||||
|
codeFontFamily : 'monospace',
|
||||||
logo: '/_media/logo.png',
|
logo: '/_media/logo.png',
|
||||||
loadSidebar: true,
|
loadSidebar: true,
|
||||||
subMaxLevel: 2,
|
subMaxLevel: 2,
|
||||||
name: 'PingMe',
|
name: 'PingMe',
|
||||||
repo: 'https://github.com/kha7iq/pingme'
|
repo: 'https://github.com/kha7iq/pingme',
|
||||||
|
darklightTheme: {
|
||||||
|
siteFont : 'PT Sans',
|
||||||
|
defaultTheme : 'dark | light',
|
||||||
|
codeFontFamily : 'Roboto Mono, Monaco, courier, monospace',
|
||||||
|
bodyFontSize : '16px',
|
||||||
|
dark: {
|
||||||
|
accent: '#ffa500',
|
||||||
|
background: '#282C34',
|
||||||
|
codeTextColor : '#b4b4b4',
|
||||||
|
codeBackgroundColor : '#353A44',
|
||||||
|
coverBackground : '#161B22'
|
||||||
|
},
|
||||||
|
light: {
|
||||||
|
accent: '#008080',
|
||||||
|
coverBackground : '#f0f0f0'
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
<!-- Docsify v4 -->
|
<!-- Docsify v4 -->
|
||||||
@ -32,5 +51,7 @@
|
|||||||
src="//cdn.jsdelivr.net/npm/docsify-darklight-theme@latest/dist/index.min.js"
|
src="//cdn.jsdelivr.net/npm/docsify-darklight-theme@latest/dist/index.min.js"
|
||||||
type="text/javascript">
|
type="text/javascript">
|
||||||
</script>
|
</script>
|
||||||
|
<script src="//unpkg.com/prismjs/components/prism-bash.min.js"></script>
|
||||||
|
<script src="//unpkg.com/prismjs/components/prism-yaml.min.js "></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
@ -6,6 +6,18 @@
|
|||||||
brew install kha7iq/tap/pingme
|
brew install kha7iq/tap/pingme
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Shell Script
|
||||||
|
By default pingme is going to be installed at `/usr/bin/` sudo is requried for this operation.
|
||||||
|
|
||||||
|
If you would like to provide a custom install path you can do so as input to script. i.e `./install.sh $HOME/bin`
|
||||||
|
```bash
|
||||||
|
curl -s https://raw.githubusercontent.com/kha7iq/pingme/master/install.sh | sudo sh
|
||||||
|
```
|
||||||
|
or
|
||||||
|
```bash
|
||||||
|
curl -sL https://bit.ly/installpm | sudo sh
|
||||||
|
```
|
||||||
|
|
||||||
## Linux
|
## Linux
|
||||||
|
|
||||||
* AUR
|
* AUR
|
||||||
@ -13,20 +25,18 @@ brew install kha7iq/tap/pingme
|
|||||||
yay -S pingme-bin
|
yay -S pingme-bin
|
||||||
```
|
```
|
||||||
|
|
||||||
* Binary
|
## Manual
|
||||||
```bash
|
```bash
|
||||||
wget -q https://github.com/kha7iq/pingme/releases/download/v0.2.3/pingme_Linux_x86_64.tar.gz
|
# Chose desired version, architecture & target os
|
||||||
tar -xf pingme_Linux_x86_64.tar.gz
|
export PINGME_VERSION="0.2.4"
|
||||||
chmod +x pingme
|
export ARCH="x86_64"
|
||||||
|
export OS="Linux"
|
||||||
|
wget -q https://github.com/kha7iq/pingme/releases/download/v${PINGME_VERSION}/pingme_${OS}_${ARCH}.tar.gz && \
|
||||||
|
tar -xf pingme_${OS}_${ARCH}.tar.gz && \
|
||||||
|
chmod +x pingme && \
|
||||||
sudo mv pingme /usr/local/bin/pingme
|
sudo mv pingme /usr/local/bin/pingme
|
||||||
```
|
```
|
||||||
|
|
||||||
## Go Get
|
|
||||||
|
|
||||||
```bash
|
|
||||||
go get -u github.com/kha7iq/pingme
|
|
||||||
```
|
|
||||||
|
|
||||||
## Windows
|
## Windows
|
||||||
|
|
||||||
```powershell
|
```powershell
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
# Configuration
|
# Configuration
|
||||||
|
|
||||||
All the flags have corresponding environment variables assosiated with it. You
|
All the flags have corresponding environment variables associated with them. You
|
||||||
can either provide the value with flags or export to a variable. You can view
|
can either provide the value with flags or export to a variable. You can view
|
||||||
the corresponding variable to each with --help flag.
|
the corresponding variable with `--help` flag.
|
||||||
|
|
||||||
*Flags* take precedence over *variables*
|
*Flags* take precedence over *variables*
|
||||||
|
|
||||||
@ -85,7 +85,8 @@ jobs:
|
|||||||
- name: Ping me On
|
- name: Ping me On
|
||||||
uses: kha7iq/pingme-action@v1
|
uses: kha7iq/pingme-action@v1
|
||||||
env:
|
env:
|
||||||
GOTIFY_TOKEN: ${{ secrets.TELEGRAM_TOKEN }}
|
GOTIFY_TOKEN: ${{ secrets.GOTIFY_TOKEN }}
|
||||||
|
GOTIFY_URL: "example.com"
|
||||||
GOTIFY_TITLE: 'Reference: ${{ github.ref }}'
|
GOTIFY_TITLE: 'Reference: ${{ github.ref }}'
|
||||||
GOTIFY_MESSAGE: 'Event is triggered by ${{ github.event_name }}'
|
GOTIFY_MESSAGE: 'Event is triggered by ${{ github.event_name }}'
|
||||||
|
|
||||||
@ -247,7 +248,6 @@ jobs:
|
|||||||
MATTERMOST_TOKEN: ${{ secrets.MATTERMOST_TOKEN }}
|
MATTERMOST_TOKEN: ${{ secrets.MATTERMOST_TOKEN }}
|
||||||
MATTERMOST_SERVER_URL: ${{ secrets.MATTERMOST_SERVER_URL }}
|
MATTERMOST_SERVER_URL: ${{ secrets.MATTERMOST_SERVER_URL }}
|
||||||
MATTERMOST_CHANNELS: ${{ secrets.MATTERMOST_CHANNELS }}
|
MATTERMOST_CHANNELS: ${{ secrets.MATTERMOST_CHANNELS }}
|
||||||
MATTERMOST_CHANNELS: ${{ secrets.MATTERMOST_CHANNELS }}
|
|
||||||
MATTERMOST_TITLE: 'Reference: ${{ github.ref }}'
|
MATTERMOST_TITLE: 'Reference: ${{ github.ref }}'
|
||||||
MATTERMOST_MESSAGE: 'Event is triggered by ${{ github.event_name }}'
|
MATTERMOST_MESSAGE: 'Event is triggered by ${{ github.event_name }}'
|
||||||
with:
|
with:
|
||||||
@ -420,7 +420,7 @@ jobs:
|
|||||||
pingme pushbullet \
|
pingme pushbullet \
|
||||||
--sms true \
|
--sms true \
|
||||||
--token "abcdefg" \
|
--token "abcdefg" \
|
||||||
-d "adnroid" \
|
-d "android" \
|
||||||
--msg "some message" \
|
--msg "some message" \
|
||||||
--number "00123456789"
|
--number "00123456789"
|
||||||
```
|
```
|
||||||
@ -428,7 +428,7 @@ pingme pushbullet \
|
|||||||
- Push notification
|
- Push notification
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
pingme pushbullet --token "abcdefg" -d "adnroid" --msg "some message"
|
pingme pushbullet --token "abcdefg" -d "android" --msg "some message"
|
||||||
```
|
```
|
||||||
|
|
||||||
- GitHub Action
|
- GitHub Action
|
||||||
@ -806,3 +806,72 @@ jobs:
|
|||||||
| TEXTMAGIC_TITLE | "" |
|
| TEXTMAGIC_TITLE | "" |
|
||||||
| TEXTMAGIC_MESSAGE | "" |
|
| TEXTMAGIC_MESSAGE | "" |
|
||||||
| TEXTMAGIC_RECEIVER | "" |
|
| TEXTMAGIC_RECEIVER | "" |
|
||||||
|
|
||||||
|
## Matrix
|
||||||
|
|
||||||
|
Matrix uses either username and password, or an access token for authentication. Tokens will be used first, if not
|
||||||
|
present, username and password will be used. Similarly for --room, if not present, room will be determined using roomId
|
||||||
|
and domain.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
pingme matrix \
|
||||||
|
--username 'matrix username' \
|
||||||
|
--password 'password' \
|
||||||
|
--token 'access token' \
|
||||||
|
--url 'https://matrix-client.matrix.org' \
|
||||||
|
--serverName 'server1.matrix.org' \
|
||||||
|
--room 'LRovrjPJaRChcTKgoK:matrix.org' \
|
||||||
|
--roomId 'LRovrjPJaRChcTKgoK' \
|
||||||
|
--domain 'matrix.org' \
|
||||||
|
--msg 'some message' \
|
||||||
|
--autoJoin
|
||||||
|
```
|
||||||
|
|
||||||
|
- GitHub Action
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
on: [push]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
pingme-job:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
name: PingMe
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Ping me On
|
||||||
|
uses: kha7iq/pingme-action@v1
|
||||||
|
env:
|
||||||
|
MATRIX_USERNAME: ${{ secrets.MATRIX_USERNAME }}
|
||||||
|
MATRIX_PASSWORD: ${{ secrets.MATRIX_PASSWORD }}
|
||||||
|
MATRIX_ACCESS_TOKEN: ${{ secrets.MATRIX_ACCESS_TOKEN }}
|
||||||
|
MATRIX_SERVER_URL: ${{ secrets.MATRIX_SERVER_URL }}
|
||||||
|
MATRIX_SERVER_NAME: ${{ secrets.MATRIX_SERVER_NAME }}
|
||||||
|
MATRIX_ROOM: ${{ secrets.MATRIX_ROOM }}
|
||||||
|
MATRIX_ROOM_ID: ${{ secrets.MATRIX_ROOM_ID }}
|
||||||
|
MATRIX_DOMAIN: ${{ secrets.MATRIX_DOMAIN }}
|
||||||
|
MATRIX_MESSAGE: 'Event is triggered by ${{ github.event_name }}'
|
||||||
|
MATRIX_AUTO_JOIN: ${{ secrets.MATRIX_AUTO_JOIN }}
|
||||||
|
|
||||||
|
with:
|
||||||
|
# Chose the messaging platform.
|
||||||
|
# slack / telegram / rocketchat / teams /
|
||||||
|
# pushover / discord / email / mattermost / textmagic / matrix
|
||||||
|
service: matrix
|
||||||
|
```
|
||||||
|
|
||||||
|
- **Variables**
|
||||||
|
|
||||||
|
| Variables | Default Value |
|
||||||
|
|--------------------| :----------------: |
|
||||||
|
| MATRIX_USERNAME | "" |
|
||||||
|
| MATRIX_PASSWORD | "" |
|
||||||
|
| MATRIX_ACCESS_TOKEN | "" |
|
||||||
|
| MATRIX_SERVER_URL | "" |
|
||||||
|
| MATRIX_SERVER_NAME | "" |
|
||||||
|
| MATRIX_ROOM | "" |
|
||||||
|
| MATRIX_ROOM_ID | "" |
|
||||||
|
| MATRIX_DOMAIN | "" |
|
||||||
|
| MATRIX_MESSAGE | "" |
|
||||||
|
| MATRIX_AUTO_JOIN | "" |
|
||||||
|
29
go.mod
29
go.mod
@ -3,13 +3,26 @@ module github.com/kha7iq/pingme
|
|||||||
go 1.16
|
go 1.16
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/cpuguy83/go-md2man/v2 v2.0.0 // indirect
|
github.com/RocketChat/Rocket.Chat.Go.SDK v0.0.0-20220708192748-b73dcb041214 // indirect
|
||||||
|
github.com/go-openapi/analysis v0.21.3 // indirect
|
||||||
|
github.com/go-openapi/runtime v0.24.1 // indirect
|
||||||
|
github.com/go-openapi/spec v0.20.6 // indirect
|
||||||
|
github.com/go-openapi/strfmt v0.21.3 // indirect
|
||||||
|
github.com/go-openapi/validate v0.22.0 // indirect
|
||||||
|
github.com/gorilla/schema v1.4.1 // indirect
|
||||||
|
github.com/gorilla/websocket v1.5.0 // indirect
|
||||||
github.com/gotify/go-api-client/v2 v2.0.4
|
github.com/gotify/go-api-client/v2 v2.0.4
|
||||||
github.com/gregdel/pushover v0.0.0-20210216095829-2131362cb888
|
github.com/gregdel/pushover v1.1.0
|
||||||
github.com/nikoksr/notify v0.17.2
|
github.com/matrix-org/gomatrix v0.0.0-20210324163249-be2af5ef2e16
|
||||||
github.com/russross/blackfriday/v2 v2.1.0 // indirect
|
github.com/mitchellh/mapstructure v1.5.0 // indirect
|
||||||
github.com/sfreiberg/gotwilio v0.0.0-20201211181435-c426a3710ab5
|
github.com/nikoksr/notify v0.27.0
|
||||||
github.com/silenceper/wechat/v2 v2.0.6
|
github.com/sfreiberg/gotwilio v1.0.0
|
||||||
github.com/stretchr/testify v1.7.0
|
github.com/silenceper/wechat/v2 v2.1.3
|
||||||
github.com/urfave/cli/v2 v2.3.0
|
github.com/slack-go/slack v0.11.0 // indirect
|
||||||
|
github.com/spf13/cast v1.5.0 // indirect
|
||||||
|
github.com/stretchr/testify v1.8.0
|
||||||
|
github.com/textmagic/textmagic-rest-go-v2/v2 v2.0.3361 // indirect
|
||||||
|
github.com/urfave/cli/v2 v2.11.0
|
||||||
|
golang.org/x/net v0.38.0 // indirect
|
||||||
|
golang.org/x/oauth2 v0.0.0-20220630143837-2104d58473e0 // indirect
|
||||||
)
|
)
|
||||||
|
81
install.sh
Executable file
81
install.sh
Executable file
@ -0,0 +1,81 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
# Usage: [sudo] [BINDIR=/usr/local/bin] ./install.sh [<BINDIR>]
|
||||||
|
#
|
||||||
|
# Example:
|
||||||
|
# 1. sudo ./install.sh /usr/local/bin
|
||||||
|
# 2. sudo ./install.sh /usr/bin
|
||||||
|
# 3. ./install.sh $HOME/usr/bin
|
||||||
|
# 4. BINDIR=$HOME/usr/bin ./install.sh
|
||||||
|
#
|
||||||
|
# Default BINDIR=/usr/bin
|
||||||
|
|
||||||
|
set -euf
|
||||||
|
|
||||||
|
if [ -n "${DEBUG-}" ]; then
|
||||||
|
set -x
|
||||||
|
fi
|
||||||
|
|
||||||
|
: ${BINDIR:="/usr/bin"}
|
||||||
|
|
||||||
|
if [ $# -gt 0 ]; then
|
||||||
|
BINDIR=$1
|
||||||
|
fi
|
||||||
|
|
||||||
|
_can_install() {
|
||||||
|
if [ ! -d "${BINDIR}" ]; then
|
||||||
|
mkdir -p "${BINDIR}" 2> /dev/null
|
||||||
|
fi
|
||||||
|
[ -d "${BINDIR}" ] && [ -w "${BINDIR}" ]
|
||||||
|
}
|
||||||
|
|
||||||
|
if ! _can_install && [ "$(id -u)" != 0 ]; then
|
||||||
|
printf "Run script as sudo\n"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ! _can_install; then
|
||||||
|
printf -- "Can't install to %s\n" "${BINDIR}"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
machine=$(uname -m)
|
||||||
|
case $machine in
|
||||||
|
armv7*)
|
||||||
|
machine="arm"
|
||||||
|
;;
|
||||||
|
aarch64)
|
||||||
|
machine="arm64"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
case $(uname -s) in
|
||||||
|
Linux)
|
||||||
|
os="Linux"
|
||||||
|
;;
|
||||||
|
Darwin)
|
||||||
|
os="macOS"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
printf "OS not supported\n"
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
printf "Fetching latest version\n"
|
||||||
|
latest="$(curl -sL 'https://api.github.com/repos/kha7iq/pingme/releases/latest' | grep 'tag_name' | grep --only 'v[0-9\.]\+' | cut -c 2-)"
|
||||||
|
tempFolder="/tmp/pingme_v${latest}"
|
||||||
|
|
||||||
|
printf -- "Found version %s\n" "${latest}"
|
||||||
|
|
||||||
|
mkdir -p "${tempFolder}" 2> /dev/null
|
||||||
|
printf -- "Downloading pingme_%s_%s_%s.tar.gz\n" "${latest}" "${os}" "${machine}"
|
||||||
|
curl -sL -o "${tempFolder}/pingme.tar.gz" "https://github.com/kha7iq/pingme/releases/download/v${latest}/pingme_${os}_${machine}.tar.gz"
|
||||||
|
|
||||||
|
printf -- "Installing...\n"
|
||||||
|
tar -C "${tempFolder}" -xf "${tempFolder}/pingme.tar.gz"
|
||||||
|
install -m755 "${tempFolder}/pingme" "${BINDIR}/pingme"
|
||||||
|
|
||||||
|
printf "Cleaning up temp files\n"
|
||||||
|
rm -rf "${tempFolder}"
|
||||||
|
|
||||||
|
printf -- "Successfully installed pingme into %s/\n" "${BINDIR}"
|
2
main.go
2
main.go
@ -1,6 +1,7 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"github.com/kha7iq/pingme/service/matrix"
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
@ -58,6 +59,7 @@ email address, Line, Gotify and Wechat.`
|
|||||||
wechat.Send(),
|
wechat.Send(),
|
||||||
gotify.Send(),
|
gotify.Send(),
|
||||||
textmagic.Send(),
|
textmagic.Send(),
|
||||||
|
matrix.Send(),
|
||||||
}
|
}
|
||||||
|
|
||||||
err := app.Run(os.Args)
|
err := app.Run(os.Args)
|
||||||
|
221
service/matrix/matrix.go
Normal file
221
service/matrix/matrix.go
Normal file
@ -0,0 +1,221 @@
|
|||||||
|
package matrix
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"github.com/matrix-org/gomatrix"
|
||||||
|
"github.com/urfave/cli/v2"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
type matrixPingMe struct {
|
||||||
|
Username string
|
||||||
|
Password string
|
||||||
|
Token string
|
||||||
|
Url string
|
||||||
|
ServerName string
|
||||||
|
Room string
|
||||||
|
RoomID string
|
||||||
|
Domain string
|
||||||
|
Message string
|
||||||
|
AutoJoin bool
|
||||||
|
}
|
||||||
|
|
||||||
|
func Send() *cli.Command {
|
||||||
|
var matrix matrixPingMe
|
||||||
|
return &cli.Command{
|
||||||
|
Name: "matrix",
|
||||||
|
Usage: "Send message via matrix",
|
||||||
|
UsageText: "pingme matrix --token 'syt_YW...E2qD' --room 'LRovrjPJaRChcTKgoK:matrix.org' " +
|
||||||
|
"--url 'matrix-client.matrix.org' --autoJoin --msg 'Hello, Matrix!'",
|
||||||
|
Flags: []cli.Flag{
|
||||||
|
&cli.StringFlag{
|
||||||
|
Destination: &matrix.Username,
|
||||||
|
Name: "username",
|
||||||
|
Aliases: []string{"u"},
|
||||||
|
Usage: "Matrix username",
|
||||||
|
EnvVars: []string{"MATRIX_USER"},
|
||||||
|
},
|
||||||
|
&cli.StringFlag{
|
||||||
|
Destination: &matrix.Password,
|
||||||
|
Name: "password",
|
||||||
|
Aliases: []string{"p"},
|
||||||
|
Usage: "Matrix password",
|
||||||
|
EnvVars: []string{"MATRIX_PASSWORD"},
|
||||||
|
},
|
||||||
|
&cli.StringFlag{
|
||||||
|
Destination: &matrix.Token,
|
||||||
|
Name: "token",
|
||||||
|
Aliases: []string{"t"},
|
||||||
|
Usage: "Matrix access token. Can be used instead of username+password",
|
||||||
|
EnvVars: []string{"MATRIX_ACCESS_TOKEN"},
|
||||||
|
},
|
||||||
|
&cli.StringFlag{
|
||||||
|
Destination: &matrix.Url,
|
||||||
|
Name: "url",
|
||||||
|
Usage: "Matrix server URL",
|
||||||
|
EnvVars: []string{"MATRIX_SERVER_URL"},
|
||||||
|
},
|
||||||
|
&cli.StringFlag{
|
||||||
|
Destination: &matrix.ServerName,
|
||||||
|
Name: "serverName",
|
||||||
|
Usage: "Can be provided if requests should be routed via a particular server",
|
||||||
|
EnvVars: []string{"MATRIX_SERVER_NAME"},
|
||||||
|
},
|
||||||
|
&cli.StringFlag{
|
||||||
|
Destination: &matrix.Room,
|
||||||
|
Name: "room",
|
||||||
|
Usage: "Matrix room to send the message to, in the format <roomId>:<domain>",
|
||||||
|
EnvVars: []string{"MATRIX_ROOM"},
|
||||||
|
},
|
||||||
|
&cli.StringFlag{
|
||||||
|
Destination: &matrix.RoomID,
|
||||||
|
Name: "roomId",
|
||||||
|
Usage: "Matrix room ID to send the message to. The exclamation mark at the beginning can be excluded.",
|
||||||
|
EnvVars: []string{"MATRIX_ROOM_ID"},
|
||||||
|
},
|
||||||
|
&cli.StringFlag{
|
||||||
|
Destination: &matrix.Domain,
|
||||||
|
Name: "domain",
|
||||||
|
Usage: "Used in conjunction with room ID to get the desired room",
|
||||||
|
EnvVars: []string{"MATRIX_DOMAIN"},
|
||||||
|
},
|
||||||
|
&cli.StringFlag{
|
||||||
|
Destination: &matrix.Message,
|
||||||
|
Name: "msg",
|
||||||
|
Aliases: []string{"m"},
|
||||||
|
Required: true,
|
||||||
|
Usage: "Message to send to matrix",
|
||||||
|
EnvVars: []string{"MATRIX_MESSAGE"},
|
||||||
|
},
|
||||||
|
&cli.BoolFlag{
|
||||||
|
Destination: &matrix.AutoJoin,
|
||||||
|
Name: "autoJoin",
|
||||||
|
Usage: "If enabled, will automatically join the specified room if not already joined",
|
||||||
|
EnvVars: []string{"MATRIX_AUTO_JOIN"},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Action: func(ctx *cli.Context) error {
|
||||||
|
// Login
|
||||||
|
client, err := matrix.login()
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("failed to login to matrix: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Parse and set variables
|
||||||
|
err = matrix.setupVars()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// If necessary, join the given room
|
||||||
|
err = matrix.joinRoomIfNecessary(client)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// Send the message
|
||||||
|
_, err = client.SendText(matrix.Room, matrix.Message)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("failed to send matrix text: %v", err)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
setupVars will ensure the room ID begins with an exclamation mark and set the room string if not
|
||||||
|
already set, using the room ID and domain. If the room string, room id and domain are not set,
|
||||||
|
an error will be thrown.
|
||||||
|
*/
|
||||||
|
func (m *matrixPingMe) setupVars() error {
|
||||||
|
// Format the room ID
|
||||||
|
if !strings.HasPrefix(m.RoomID, "!") {
|
||||||
|
m.RoomID = "!" + m.RoomID
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create the matrix room string if not already provided
|
||||||
|
if m.Room == "" {
|
||||||
|
if m.RoomID == "" || m.Domain == "" {
|
||||||
|
return fmt.Errorf("matrix room, or room ID and domain must be provided")
|
||||||
|
}
|
||||||
|
|
||||||
|
m.Room = fmt.Sprintf("%s:%s", m.RoomID, m.Domain)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
joinRoomIfNecessary gets all the joined rooms and checks if the desired room is in the list.
|
||||||
|
If not, and autoJoin is set to true - will attempt to join the room. If autoJoin is set to
|
||||||
|
false, an error will be thrown
|
||||||
|
*/
|
||||||
|
func (m *matrixPingMe) joinRoomIfNecessary(client *gomatrix.Client) error {
|
||||||
|
// Get already joined rooms
|
||||||
|
joined, err := client.JoinedRooms()
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("failed to get joined rooms: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if we've already joined the desired room
|
||||||
|
foundRoom := false
|
||||||
|
for _, room := range joined.JoinedRooms {
|
||||||
|
if room == m.Room {
|
||||||
|
foundRoom = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// If not, try auto join the room
|
||||||
|
if !foundRoom {
|
||||||
|
if !m.AutoJoin {
|
||||||
|
return fmt.Errorf("not joined room '%s' and --autoJoin is set to false", m.Room)
|
||||||
|
}
|
||||||
|
|
||||||
|
_, err = client.JoinRoom(m.Room, m.ServerName, nil)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("failed to auto join room '%s': %v", m.Room, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
login creates a gomatrix.Client instance, connecting to the given URL, using the provided login details
|
||||||
|
*/
|
||||||
|
func (m *matrixPingMe) login() (*gomatrix.Client, error) {
|
||||||
|
// Create a client instance
|
||||||
|
client, err := gomatrix.NewClient(m.Url, "", "")
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("failed to create matrix client: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Attempt to log in with whatever login details were provided.
|
||||||
|
// Or, throw an error if no login details were given
|
||||||
|
var resp *gomatrix.RespLogin
|
||||||
|
if m.Token != "" {
|
||||||
|
resp, err = client.Login(&gomatrix.ReqLogin{
|
||||||
|
Type: "m.login.token",
|
||||||
|
Token: m.Token,
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
} else if m.Username != "" && m.Password != "" {
|
||||||
|
resp, err = client.Login(&gomatrix.ReqLogin{
|
||||||
|
Type: "m.login.password",
|
||||||
|
User: m.Username,
|
||||||
|
Password: m.Password,
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return nil, fmt.Errorf("no token, or username and password provided")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set the access token for this session
|
||||||
|
client.SetCredentials(resp.UserID, resp.AccessToken)
|
||||||
|
m.Token = resp.AccessToken
|
||||||
|
return client, nil
|
||||||
|
}
|
@ -16,6 +16,7 @@ type pushOver struct {
|
|||||||
Recipient string
|
Recipient string
|
||||||
Message string
|
Message string
|
||||||
Title string
|
Title string
|
||||||
|
Priority int
|
||||||
}
|
}
|
||||||
|
|
||||||
// Send parse values from *cli.context and return *cli.Command.
|
// Send parse values from *cli.context and return *cli.Command.
|
||||||
@ -61,10 +62,27 @@ All configuration options are also available via environment variables.`,
|
|||||||
Usage: "Title of the message.",
|
Usage: "Title of the message.",
|
||||||
EnvVars: []string{"PUSHOVER_TITLE"},
|
EnvVars: []string{"PUSHOVER_TITLE"},
|
||||||
},
|
},
|
||||||
|
&cli.IntFlag{
|
||||||
|
Destination: &pushOverOpts.Priority,
|
||||||
|
Name: "priority",
|
||||||
|
Aliases: []string{"p"},
|
||||||
|
Value: 0,
|
||||||
|
Usage: "Priority of the message.",
|
||||||
|
EnvVars: []string{"PUSHOVER_PRIORITY"},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
Action: func(ctx *cli.Context) error {
|
Action: func(ctx *cli.Context) error {
|
||||||
app := pushover.New(pushOverOpts.Token)
|
app := pushover.New(pushOverOpts.Token)
|
||||||
message := pushover.NewMessageWithTitle(pushOverOpts.Message, pushOverOpts.Title)
|
|
||||||
|
// message := &pushover.Message{Title: pushOverOpts.Title, Message: pushOverOpts.Message, Priority: pushOverOpts.Priority}
|
||||||
|
|
||||||
|
message := &pushover.Message{Title: pushOverOpts.Title,
|
||||||
|
Message: pushOverOpts.Message,
|
||||||
|
Priority: pushOverOpts.Priority,
|
||||||
|
Retry: 60,
|
||||||
|
Expire: 3600,
|
||||||
|
}
|
||||||
|
|
||||||
users := strings.Split(pushOverOpts.Recipient, ",")
|
users := strings.Split(pushOverOpts.Recipient, ",")
|
||||||
|
|
||||||
for _, v := range users {
|
for _, v := range users {
|
||||||
|
@ -26,7 +26,7 @@ func Send() *cli.Command {
|
|||||||
Name: "textmagic",
|
Name: "textmagic",
|
||||||
Usage: "Send message via TextMagic",
|
Usage: "Send message via TextMagic",
|
||||||
UsageText: "pingme textmagic --token 'tokenabc' --user 'sid123' " +
|
UsageText: "pingme textmagic --token 'tokenabc' --user 'sid123' " +
|
||||||
"--subject 'foo' --receiver '+140001442' --msg 'some message'",
|
"--title 'foo' --receiver '+140001442' --msg 'some message'",
|
||||||
Description: `textmagic provides ability to send sms to multiple numbers.
|
Description: `textmagic provides ability to send sms to multiple numbers.
|
||||||
You can specify multiple receivers by separating the value with a comma.`,
|
You can specify multiple receivers by separating the value with a comma.`,
|
||||||
Flags: []cli.Flag{
|
Flags: []cli.Flag{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user