This commit is contained in:
Gregory Salaun 2024-07-03 15:44:35 +07:00
parent 45a73d45b9
commit acde3434dd
6 changed files with 36 additions and 70 deletions

Binary file not shown.

2
database.gp Normal file
View File

@ -0,0 +1,2 @@
package main

2
dx.txt
View File

@ -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
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

102
main.go
View File

@ -138,6 +138,27 @@ func SanitizeClusterMessage(message string) ClusterMessage {
return mes
}
func sendTelnetMessage(conn net.Conn, message string) {
if message != "XV9Q-1" {
time.Sleep(2 * time.Second)
}
_, err := conn.Write([]byte(message + "\n"))
if err != nil {
conn.Close()
time.Sleep(5 * time.Second) // Wait before retrying
}
}
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/skimmer")
time.Sleep(1 * time.Second)
go sendTelnetMessage(conn, "set/ft4")
}
func main() {
// Generate our config based on the config supplied
@ -151,6 +172,9 @@ func main() {
log.Fatal(err)
}
login := false
filters_sent := false
fmt.Println("PushDXCluster v0.1")
for {
// Connect to the Telnet server
@ -166,12 +190,6 @@ func main() {
// Create a buffered reader to read from the Telnet server
reader := bufio.NewReader(conn)
ft8 := 0
filter := 0
skimmer := 0
ft4 := 0
login := false
// Loop to read from the Telnet server
for {
message, err := reader.ReadString('\n')
@ -180,6 +198,8 @@ func main() {
conn.Close()
break
}
// Trim and Sanitize spots messages
message = strings.TrimSpace(message)
sMess := SanitizeClusterMessage(message)
@ -189,75 +209,19 @@ func main() {
log.Printf("Received message: %s", message)
}
// Send identification message
// Send Call to ID to the Server
if message != "" && strings.Contains("Please enter your call:", message) {
_, err = conn.Write([]byte(cfg.Cluster.Call + "\n"))
if err != nil {
log.Printf("Failed to send identification message: %v", err)
conn.Close()
time.Sleep(5 * time.Second) // Wait before retrying
continue
}
log.Printf("Identification %s message sent", cfg.Cluster.Call)
go sendTelnetMessage(conn, "XV9Q-1")
login = true
}
if ft8 == 0 && login {
time.Sleep(2 * time.Second)
_, err = conn.Write([]byte("set/ft8" + "\n"))
if err != nil {
log.Printf("Failed to send FT8 message: %v", err)
conn.Close()
time.Sleep(5 * time.Second) // Wait before retrying
continue
}
log.Println("Set FT8 message sent")
ft8++
}
if filter == 0 && login && message != "" && strings.Contains("FT8 spots enabled", message) {
_, err = conn.Write([]byte("SET/FILTER DOC/PASS 3W" + "\n"))
//SET/FILTER DXBM/OFF
//SET/FILTER DOC/PASS 3W
if err != nil {
log.Printf("Failed to send Filter message: %v", err)
conn.Close()
time.Sleep(5 * time.Second) // Wait before retrying
continue
}
log.Println("Set filter Vietnam message sent")
filter++
}
if skimmer == 0 && login && message != "" && strings.Contains("FT8 spots enabled", message) {
time.Sleep(1 * time.Second)
_, err = conn.Write([]byte("set/skimmer" + "\n"))
if err != nil {
log.Printf("Failed to send skimmer message: %v", err)
conn.Close()
time.Sleep(5 * time.Second) // Wait before retrying
continue
}
log.Println("Set CW skimmer message sent")
skimmer++
}
if ft4 == 0 && login && message != "" && strings.Contains("Skimmer spots enabled", message) {
time.Sleep(3 * time.Second)
_, err = conn.Write([]byte("set/skimmer" + "\n"))
if err != nil {
log.Printf("Failed to send FT4 message: %v", err)
conn.Close()
time.Sleep(5 * time.Second) // Wait before retrying
continue
}
log.Println("Set FT4 message sent")
ft4++
// Set the FT8, CW, FT4 and only spots from Vietnam filters only once
if login && !filters_sent {
go sendFilters(conn)
filters_sent = true
}
// If calls is in the DX List then send a Gotify notification
if sMess.DX != "" && sMess.From == "XV9Q" && strings.Contains(DX, sMess.DX) {
sendToGotify("Spot", sMess, 5, *cfg)
}

BIN
rsrc_windows_386.syso Normal file

Binary file not shown.

BIN
rsrc_windows_amd64.syso Normal file

Binary file not shown.