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_URL="http://127.0.0.1:4785"
|
||||||
MATRIX_WEBHOOK_API_KEY=
|
MATRIX_WEBHOOK_API_KEY=keySetupInMatrixWebhooks
|
||||||
MATRIX_ACCOUNT_CHANNEL=
|
MATRIX_ACCOUNT_CHANNEL="!channelID:matrix.org"
|
||||||
MATRIX_REPORT_CHANNEL=
|
MATRIX_REPORT_CHANNEL="!channelID:matrix.org"
|
||||||
PORT=
|
PORT=8081
|
||||||
IP2LOCATION_FILE=
|
IP2LOCATION_FILE="full path to .BIN file"
|
||||||
|
MASTODON_INSTANCE="mastodon.test"
|
13
README.md
13
README.md
@ -6,4 +6,15 @@ Allows you to post signup/report info into a Matrix channel.
|
|||||||
# Install
|
# Install
|
||||||
Install golang. Install [matrix-webhook](https://github.com/nim65s/matrix-webhook).
|
Install golang. Install [matrix-webhook](https://github.com/nim65s/matrix-webhook).
|
||||||
|
|
||||||
Copy .env.example to .env and fill in the blanks
|
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 MATRIX_REPORT_CHANNEL string
|
||||||
var PORT string
|
var PORT string
|
||||||
var IP2LOCATION_FILE string
|
var IP2LOCATION_FILE string
|
||||||
|
var MASTODON_INSTANCE string
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
err := godotenv.Load()
|
err := godotenv.Load()
|
||||||
@ -45,6 +46,11 @@ func init() {
|
|||||||
log.Fatal("MATRIX_REPORT_CHANNEL empty or invalid")
|
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")
|
PORT = os.Getenv("PORT")
|
||||||
if PORT == "" {
|
if PORT == "" {
|
||||||
log.Fatal("PORT empty or invalid")
|
log.Fatal("PORT empty or invalid")
|
||||||
@ -75,7 +81,8 @@ func handler(w http.ResponseWriter, r *http.Request) {
|
|||||||
msg := fmt.Sprintf(
|
msg := fmt.Sprintf(
|
||||||
"[New Report](%s): **%s** has reported **%s**: %s",
|
"[New Report](%s): **%s** has reported **%s**: %s",
|
||||||
fmt.Sprintf(
|
fmt.Sprintf(
|
||||||
"https://mastodon.nz/admin/reports/%s",
|
"https://%s/admin/reports/%s",
|
||||||
|
MASTODON_INSTANCE,
|
||||||
i.Object.ID,
|
i.Object.ID,
|
||||||
),
|
),
|
||||||
i.Object.Account.Username,
|
i.Object.Account.Username,
|
||||||
@ -101,7 +108,8 @@ func handler(w http.ResponseWriter, r *http.Request) {
|
|||||||
msg := fmt.Sprintf(
|
msg := fmt.Sprintf(
|
||||||
"[New Signup](%s) %s: **%s** (%s). %s",
|
"[New Signup](%s) %s: **%s** (%s). %s",
|
||||||
fmt.Sprintf(
|
fmt.Sprintf(
|
||||||
"https://mastodon.nz/admin/accounts/%s",
|
"https://%s/admin/accounts/%s",
|
||||||
|
MASTODON_INSTANCE,
|
||||||
i.Object.ID,
|
i.Object.ID,
|
||||||
),
|
),
|
||||||
country,
|
country,
|
||||||
@ -129,7 +137,8 @@ func handler(w http.ResponseWriter, r *http.Request) {
|
|||||||
msg := fmt.Sprintf(
|
msg := fmt.Sprintf(
|
||||||
"[Signup Approved](%s): %s",
|
"[Signup Approved](%s): %s",
|
||||||
fmt.Sprintf(
|
fmt.Sprintf(
|
||||||
"https://mastodon.nz/admin/accounts/%s",
|
"https://%s/admin/accounts/%s",
|
||||||
|
MASTODON_INSTANCE,
|
||||||
i.Object.ID,
|
i.Object.ID,
|
||||||
),
|
),
|
||||||
i.Object.Username,
|
i.Object.Username,
|
||||||
|
Loading…
Reference in New Issue
Block a user