Compare commits
7 Commits
b680af776e
...
main
Author | SHA1 | Date | |
---|---|---|---|
115051d463 | |||
9a03f3d4c6 | |||
bd1b8da2f7 | |||
a394767832 | |||
f424633083 | |||
a39dadce1a | |||
2d392d8033 |
Binary file not shown.
@ -17,6 +17,10 @@ type Config struct {
|
||||
Host string `yaml:"host"`
|
||||
Call string `yaml:"call"`
|
||||
} `yaml:"cluster"`
|
||||
|
||||
Log struct {
|
||||
SQLitePath string `yaml:"sqlitePath"`
|
||||
} `yaml:"log"`
|
||||
}
|
||||
|
||||
func NewConfig(configPath string) (*Config, error) {
|
||||
|
@ -3,7 +3,8 @@ gotify:
|
||||
token: ALaGS4MVMWTEMcP
|
||||
|
||||
cluster:
|
||||
host: ve7cc.net:23
|
||||
call: XV9Q
|
||||
host: dxc.k0xm.net:7300
|
||||
call: F4BPO
|
||||
|
||||
#arc.jg1vgx.net:7000
|
||||
log:
|
||||
sqlitePath: "C:\\Perso\\Seafile\\Radio\\Logs\\Log4OM\\Vietnam.SQLite"
|
2
dx.txt
2
dx.txt
@ -1 +1 @@
|
||||
8P9CB ZC4GW TM5FI VP2V/W5GI VP9/AB2E 8Q7KR 8Q7KB TF2MSN FW1JG CO8BLY OD5KU 5U5K S21ZI K8K 8Q7EC OX3LX FP/KV1J TO7PX S79/HA8PX JW/WE9G ZC4MK K8R 7E4K E51KEE E51CZZ DT0IP YN2RP VK2/W7BRS K8K 3W9A S21AF
|
||||
TF2MSN T32AZ DT0IP YN2RP KH8T 9J2AO XT2AW 6O3T 5H1WX 5H3MB CR3W A25AO 5W1SA
|
24
main.go
24
main.go
@ -112,7 +112,7 @@ func sendToGotify(title string, sMess ClusterMessage, priority int, cfg Config)
|
||||
}
|
||||
|
||||
func SanitizeClusterMessage(message string) ClusterMessage {
|
||||
r := regexp.MustCompile(`DX\sde\s([A-Z0-9]+)[-#:]+[\s]+([0-9]+.[0-9])[\s]+([^\s]+)[\s]+([A-Z]+[0-9])\s+(.*dB).*(.{4})Z$`)
|
||||
r := regexp.MustCompile(`DX\sde\s([A-Z0-9]+)[-#:]+[\s]+([0-9]+.[0-9])[\s]+([^\s]+)[\s]+(\bFT8\b|\bFT4\b|\bCW\b)+\s+(.*dB).*(.{4})Z$`)
|
||||
matches := r.FindStringSubmatch(message)
|
||||
|
||||
mes := ClusterMessage{}
|
||||
@ -138,7 +138,7 @@ func SanitizeClusterMessage(message string) ClusterMessage {
|
||||
}
|
||||
|
||||
func sendTelnetMessage(conn net.Conn, message string) {
|
||||
if message != "XV9Q-1" {
|
||||
if !strings.HasPrefix(message, "F4BPO") {
|
||||
time.Sleep(2 * time.Second)
|
||||
}
|
||||
_, err := conn.Write([]byte(message + "\n"))
|
||||
@ -151,8 +151,8 @@ func sendTelnetMessage(conn net.Conn, message string) {
|
||||
func sendFilters(conn net.Conn) {
|
||||
go sendTelnetMessage(conn, "set/ft8")
|
||||
time.Sleep(1 * time.Second)
|
||||
//go sendTelnetMessage(conn, "SET/FILTER DOC/PASS 3W")
|
||||
//time.Sleep(1 * time.Second)
|
||||
go sendTelnetMessage(conn, "SET/FILTER DOC/PASS F")
|
||||
time.Sleep(1 * time.Second)
|
||||
go sendTelnetMessage(conn, "set/skimmer")
|
||||
time.Sleep(1 * time.Second)
|
||||
go sendTelnetMessage(conn, "set/ft4")
|
||||
@ -177,7 +177,8 @@ func main() {
|
||||
fmt.Println("PushDXCluster v0.1")
|
||||
for {
|
||||
// Connect to the Telnet server
|
||||
conn, err := net.Dial("tcp", cfg.Cluster.Host)
|
||||
addr, err := net.ResolveTCPAddr("tcp", cfg.Cluster.Host)
|
||||
conn, err := net.DialTCP("tcp", nil, addr)
|
||||
if err != nil {
|
||||
log.Printf("Failed to connect to Telnet server: %v", err)
|
||||
time.Sleep(5 * time.Second) // Wait before retrying
|
||||
@ -192,6 +193,8 @@ func main() {
|
||||
// Loop to read from the Telnet server
|
||||
for {
|
||||
message, err := reader.ReadString('\n')
|
||||
message, _ = strings.CutSuffix(message, "\n")
|
||||
message, _ = strings.CutSuffix(message, "\r")
|
||||
if err != nil {
|
||||
log.Printf("Error reading from Telnet server: %v", err)
|
||||
conn.Close()
|
||||
@ -203,14 +206,19 @@ func main() {
|
||||
sMess := SanitizeClusterMessage(message)
|
||||
|
||||
if sMess.DX != "" {
|
||||
log.Printf("Sanitized message: Reporter: %s, DX: %s, Freq: %s, Report: %s, Time: %s", sMess.From, sMess.DX, sMess.Freq, sMess.Report, sMess.Time)
|
||||
log.Printf("Sanitized message: Reporter: %s, DX: %s, Freq: %s, Mode: %s, Report: %s, Time: %s", sMess.From, sMess.DX, sMess.Freq, sMess.Mode, sMess.Report, sMess.Time)
|
||||
} else {
|
||||
log.Printf("Received message: %s", message)
|
||||
}
|
||||
|
||||
// Send Call to ID to the Server
|
||||
if message != "" && strings.Contains("Please enter your call:", message) {
|
||||
go sendTelnetMessage(conn, "XV9Q-1")
|
||||
go sendTelnetMessage(conn, "F4BPO-2")
|
||||
login = true
|
||||
}
|
||||
|
||||
if message != "" && strings.Contains("login:", message) {
|
||||
go sendTelnetMessage(conn, "F4BPO-2")
|
||||
login = true
|
||||
}
|
||||
|
||||
@ -221,7 +229,7 @@ func main() {
|
||||
}
|
||||
|
||||
// If calls is in the DX List then send a Gotify notification
|
||||
if sMess.DX != "" && sMess.From == "XV9Q" && strings.Contains(DX, sMess.DX) {
|
||||
if sMess.DX != "" && sMess.From == "F4BPO" && strings.Contains(DX, sMess.DX) {
|
||||
sendToGotify("Spot", sMess, 5, *cfg)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user