|
@@ -22,8 +22,6 @@ import (
|
|
|
"sour.is/x/toolbox/log"
|
|
|
)
|
|
|
|
|
|
-var defaultEnv []string
|
|
|
-
|
|
|
func main() {
|
|
|
ctx, cancel := context.WithCancel(context.Background())
|
|
|
|
|
@@ -57,11 +55,10 @@ func run(ctx context.Context) {
|
|
|
PASS := viper.GetString("irc.pass")
|
|
|
OPER := viper.GetString("irc.oper")
|
|
|
TLS := viper.GetBool("irc.tls")
|
|
|
- CMD := viper.GetString("irc.cmd")
|
|
|
+
|
|
|
+ CMD := viper.GetString("irc.cmd.run")
|
|
|
+ OPTS := viper.GetStringMapString("irc.opts")
|
|
|
CMDTIMEOUT := time.Duration(viper.GetInt64("irc.cmd.timeout")) * time.Second
|
|
|
- if CMDTIMEOUT == 0 {
|
|
|
- CMDTIMEOUT = 30 * time.Second
|
|
|
- }
|
|
|
|
|
|
cfg := irc.NewConfig(NICK)
|
|
|
|
|
@@ -92,6 +89,7 @@ func run(ctx context.Context) {
|
|
|
c.LogPanic(l)
|
|
|
}
|
|
|
|
|
|
+ defaultEnv := make([]string, 0, len(OPTS)+6)
|
|
|
defaultEnv = append(defaultEnv,
|
|
|
fmt.Sprintf("HOME=%v", os.Getenv("HOME")),
|
|
|
fmt.Sprintf("PATH=%v", os.Getenv("PATH")),
|
|
@@ -101,6 +99,12 @@ func run(ctx context.Context) {
|
|
|
fmt.Sprintf("SKILLET_IRC_HOST=%v", HOST),
|
|
|
)
|
|
|
|
|
|
+ for name, value := range OPTS {
|
|
|
+ name = strings.ToUpper(name)
|
|
|
+ name = strings.ReplaceAll(name, ".", "_")
|
|
|
+ defaultEnv = append(defaultEnv, fmt.Sprintf("SKILLET_OPT_%s=%s", name, value))
|
|
|
+ }
|
|
|
+
|
|
|
cl := irc.Client(cfg)
|
|
|
cl.EnableStateTracking()
|
|
|
|