Renamed RecvOnly to Monitor

This commit is contained in:
blackbeard420 2025-03-03 20:24:18 -05:00
parent 1e10152db4
commit 0fc25eb941
2 changed files with 34 additions and 13 deletions

View File

@ -4,9 +4,11 @@ ouchnets official relay client
## usage
ouch-relay simply opens config.json in the current directory currently. a CLI has not been added yet
`./ouch-relay` will load config.json from current directory
`./ouch-relay`
To specify config path use `./ouch-relay -cfg path/to/config`
`./ouch-relay -h` to print the usage message
## config
@ -15,15 +17,24 @@ ouch-relay simply opens config.json in the current directory currently. a CLI ha
"networks": [
{
"url": "irc.ouch.chat:6667",
"nick": "relay1",
"nick": "Alpha",
"channel": "#testing",
"name": "ouchNET",
"name": "TestNet",
"monitor": true
},
{
"url": "irc.whatever.chat:6667",
"nick": "relay2",
"url": "irc.ouch.chat:6667",
"nick": "Beta",
"channel": "#test",
"name": "whateverNET",
"name": "OuchNet",
"monitor": false
},
{
"url": "irc.ouch.chat:6667",
"nick": "Charlie",
"channel": "#taliban",
"name": "TalibanNet",
"monitor": false
}
]
}
@ -33,6 +44,6 @@ ouch-relay simply opens config.json in the current directory currently. a CLI ha
- `nick` is the nickname you want the relay to use
- `channel` is the channel you want the relay to occupy
- `name` is the network Identifier for the relay
- `recvonly` set to `true` to make connection only recieve relays, not send
- `monitor` set to `true` to make connection only recieve messages from relay chain, not send
you may specify as many networks as you want under the json `"netoworks"` array. All networks will then have specified channels relayed across all networks
you may specify as many networks as you want under the json `"networks"` array. All networks will then have specified channels relayed across all networks

View File

@ -2,6 +2,7 @@ package main
import (
"encoding/json"
"flag"
"fmt"
"log"
"os"
@ -17,7 +18,7 @@ type Network struct {
Nick string `json:"nick"`
Channel string `json:"channel"`
Name string `json:"name"`
RecvOnly bool `json:"recvonly"`
Monitor bool `json:"monitor"`
Connection irc.Connection
}
@ -29,7 +30,16 @@ var netmap map[string]*Network
var netmutex sync.Mutex
func main() {
buf, _ := os.ReadFile("config.json")
cfgpath := flag.String("cfg", "config.json", "path to config file")
flag.Parse()
log.Printf("Loading config: %s", *cfgpath)
buf, err := os.ReadFile(*cfgpath)
if err != nil {
log.Fatalf("FATAL: %s", err.Error())
}
conf := Config{}
@ -55,7 +65,7 @@ func initRelay(n *Network) {
netmap[n.Name] = n
n.Connection = *irc.NewConnection(n.Url, n.Nick, n.Nick, nil, []string{n.Channel})
if !n.RecvOnly {
if !n.Monitor {
n.Connection.PrivmsgCallbackEx = handleMessage
n.Connection.JoinCallbackEx = handleJoin
n.Connection.PartCallbackEx = handlePart
@ -73,7 +83,7 @@ func deleteRelay(n string) {
func runRelay(n *Network) {
n.Connection.Run()
relay(&n.Connection, "Network connection lost, retrying in 15 seconds")
log.Printf("Network connection lost [%s]", n.Name)
time.Sleep(time.Second * 15)
initRelay(n)
}