mirror of
https://github.com/idanoo/go-pager-discord
synced 2025-07-01 05:42:19 +00:00
Progress
This commit is contained in:
parent
1697ecaea9
commit
64c5003fad
4 changed files with 98 additions and 4 deletions
|
@ -1,4 +1,4 @@
|
||||||
DISCORD_WEBHOOK=
|
DISCORD_WEBHOOK=""
|
||||||
RTL_FREQ=157.950
|
RTL_FREQ="157.50"
|
||||||
RTL_DEVICE_ID=
|
RTL_DEVICE_ID=""
|
||||||
RTL_GAIN=40.2
|
RTL_GAIN="40.2"
|
||||||
|
|
5
go.mod
Normal file
5
go.mod
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
module go-pager-discord
|
||||||
|
|
||||||
|
go 1.20
|
||||||
|
|
||||||
|
require github.com/joho/godotenv v1.5.1
|
2
go.sum
Normal file
2
go.sum
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0=
|
||||||
|
github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4=
|
87
main.go
Normal file
87
main.go
Normal file
|
@ -0,0 +1,87 @@
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"log"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"github.com/joho/godotenv"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
DISCORD_WEBHOOK string
|
||||||
|
RTL_FREQ string
|
||||||
|
RTL_DEVICE_ID string
|
||||||
|
RTL_GAIN string
|
||||||
|
|
||||||
|
// Emojies to replace
|
||||||
|
emojis = map[string][]string{
|
||||||
|
":house:": []string{"house", "roof"},
|
||||||
|
":blue_car:": []string{"mva", "mvc", "car "},
|
||||||
|
":fire:": []string{"fire", "smoke", "smoking", "chimney"},
|
||||||
|
":ocean:": []string{"flood"},
|
||||||
|
":evergreen_tree:": []string{"tree"},
|
||||||
|
":wind_blowing_face:": []string{"wind", "blow"},
|
||||||
|
":zap:": []string{"power", "electric", "spark"},
|
||||||
|
":ambulance: :purple_circle:": []string{"purple"},
|
||||||
|
":ambulance:": []string{"chest pain", "not alert", "seizure", "breath", "pain", "fall ", "orange", "sweats", "acute", "red 1", "red 2", "respitory", "bleeding", "purple"},
|
||||||
|
":biohazard": []string{"hazchem"},
|
||||||
|
":helmet_with_cross:": []string{"resc "},
|
||||||
|
}
|
||||||
|
|
||||||
|
// Phrases to skip
|
||||||
|
skip = []string{
|
||||||
|
"this is a test",
|
||||||
|
"enabled demodulators",
|
||||||
|
"test page",
|
||||||
|
"assigned to station",
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
// Load .env file
|
||||||
|
func init() {
|
||||||
|
err := godotenv.Load()
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal("Error loading .env file")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Webhook to post to
|
||||||
|
DISCORD_WEBHOOK = os.Getenv("DISCORD_WEBHOOK")
|
||||||
|
if DISCORD_WEBHOOK == "" {
|
||||||
|
log.Fatal("DISCORD_WEBHOOK empty or invalid")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Frequency to listen to
|
||||||
|
RTL_FREQ = os.Getenv("RTL_FREQ")
|
||||||
|
if RTL_FREQ == "" {
|
||||||
|
log.Fatal("RTL_FREQ empty or invalid")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Not required - if not set, skip setting
|
||||||
|
RTL_DEVICE_ID = os.Getenv("RTL_DEVICE_ID")
|
||||||
|
|
||||||
|
// Receiver gain
|
||||||
|
RTL_GAIN = os.Getenv("RTL_GAIN")
|
||||||
|
if RTL_FREQ == "" {
|
||||||
|
log.Fatal("RTL_GAIN empty or invalid")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Start func
|
||||||
|
func main() {
|
||||||
|
log.Println("Booting go-pager-discord")
|
||||||
|
|
||||||
|
// Start running rtl_fm + multimon
|
||||||
|
deviceID := ""
|
||||||
|
if RTL_DEVICE_ID != "" {
|
||||||
|
deviceID = fmt.Sprintf("-d %s", RTL_DEVICE_ID)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Build command
|
||||||
|
_ = fmt.Sprintf(
|
||||||
|
"rtl_fm -M fm -d %s -f %sM -g %s -s 22050 -- | multimon-ng -t raw -a POCSAG512 -a POCSAG1200 -a FLEX -a POCSAG2400 /dev/stdin",
|
||||||
|
deviceID,
|
||||||
|
RTL_FREQ,
|
||||||
|
RTL_GAIN,
|
||||||
|
)
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue