mirror of
https://github.com/idanoo/go-mastodon-matrix-webhooks.git
synced 2024-11-23 08:55:21 +00:00
Move mastodon URL to a .env var
This commit is contained in:
parent
ae803d1127
commit
b17f929948
13
.env.example
13
.env.example
@ -1,6 +1,7 @@
|
||||
MATRIX_WEBHOOK_URL=
|
||||
MATRIX_WEBHOOK_API_KEY=
|
||||
MATRIX_ACCOUNT_CHANNEL=
|
||||
MATRIX_REPORT_CHANNEL=
|
||||
PORT=
|
||||
IP2LOCATION_FILE=
|
||||
MATRIX_WEBHOOK_URL="http://127.0.0.1:4785"
|
||||
MATRIX_WEBHOOK_API_KEY=keySetupInMatrixWebhooks
|
||||
MATRIX_ACCOUNT_CHANNEL="!channelID:matrix.org"
|
||||
MATRIX_REPORT_CHANNEL="!channelID:matrix.org"
|
||||
PORT=8081
|
||||
IP2LOCATION_FILE="full path to .BIN file"
|
||||
MASTODON_INSTANCE="mastodon.test"
|
11
README.md
11
README.md
@ -7,3 +7,14 @@ Allows you to post signup/report info into a Matrix channel.
|
||||
Install golang. Install [matrix-webhook](https://github.com/nim65s/matrix-webhook).
|
||||
|
||||
Copy .env.example to .env and fill in the blanks
|
||||
|
||||
|
||||
```
|
||||
MATRIX_WEBHOOK_URL="http://127.0.0.1:4785"
|
||||
MATRIX_WEBHOOK_API_KEY=keySetupInMatrixWebhooks
|
||||
MATRIX_ACCOUNT_CHANNEL="!channelID:matrix.org"
|
||||
MATRIX_REPORT_CHANNEL="!channelID:matrix.org"
|
||||
PORT=8081
|
||||
IP2LOCATION_FILE="full path to .BIN file"
|
||||
MASTODON_INSTANCE="mastodon.test"
|
||||
```
|
15
main.go
15
main.go
@ -18,6 +18,7 @@ var MATRIX_ACCOUNT_CHANNEL string
|
||||
var MATRIX_REPORT_CHANNEL string
|
||||
var PORT string
|
||||
var IP2LOCATION_FILE string
|
||||
var MASTODON_INSTANCE string
|
||||
|
||||
func init() {
|
||||
err := godotenv.Load()
|
||||
@ -45,6 +46,11 @@ func init() {
|
||||
log.Fatal("MATRIX_REPORT_CHANNEL empty or invalid")
|
||||
}
|
||||
|
||||
MASTODON_INSTANCE = os.Getenv("MASTODON_INSTANCE")
|
||||
if MASTODON_INSTANCE == "" {
|
||||
log.Fatal("MASTODON_INSTANCE is empty or invalid")
|
||||
}
|
||||
|
||||
PORT = os.Getenv("PORT")
|
||||
if PORT == "" {
|
||||
log.Fatal("PORT empty or invalid")
|
||||
@ -75,7 +81,8 @@ func handler(w http.ResponseWriter, r *http.Request) {
|
||||
msg := fmt.Sprintf(
|
||||
"[New Report](%s): **%s** has reported **%s**: %s",
|
||||
fmt.Sprintf(
|
||||
"https://mastodon.nz/admin/reports/%s",
|
||||
"https://%s/admin/reports/%s",
|
||||
MASTODON_INSTANCE,
|
||||
i.Object.ID,
|
||||
),
|
||||
i.Object.Account.Username,
|
||||
@ -101,7 +108,8 @@ func handler(w http.ResponseWriter, r *http.Request) {
|
||||
msg := fmt.Sprintf(
|
||||
"[New Signup](%s) %s: **%s** (%s). %s",
|
||||
fmt.Sprintf(
|
||||
"https://mastodon.nz/admin/accounts/%s",
|
||||
"https://%s/admin/accounts/%s",
|
||||
MASTODON_INSTANCE,
|
||||
i.Object.ID,
|
||||
),
|
||||
country,
|
||||
@ -129,7 +137,8 @@ func handler(w http.ResponseWriter, r *http.Request) {
|
||||
msg := fmt.Sprintf(
|
||||
"[Signup Approved](%s): %s",
|
||||
fmt.Sprintf(
|
||||
"https://mastodon.nz/admin/accounts/%s",
|
||||
"https://%s/admin/accounts/%s",
|
||||
MASTODON_INSTANCE,
|
||||
i.Object.ID,
|
||||
),
|
||||
i.Object.Username,
|
||||
|
Loading…
Reference in New Issue
Block a user