add regex support and clipboard support to notification center
This commit is contained in:
@@ -16,6 +16,7 @@ func HandleHelloAck(_ context.Context, env *runtime.Env, envelope map[string]int
|
||||
|
||||
var keywords []string
|
||||
minInterval := 0
|
||||
clipboardEnabled := false
|
||||
|
||||
if raw, ok := envelope["notification"].(map[string]interface{}); ok {
|
||||
if rawKeywords, ok := raw["keywords"].([]interface{}); ok {
|
||||
@@ -34,11 +35,14 @@ func HandleHelloAck(_ context.Context, env *runtime.Env, envelope map[string]int
|
||||
if v, ok := raw["minIntervalMs"].(int); ok {
|
||||
minInterval = v
|
||||
}
|
||||
if v, ok := raw["clipboardEnabled"].(bool); ok {
|
||||
clipboardEnabled = v
|
||||
}
|
||||
}
|
||||
|
||||
if len(keywords) > 0 || minInterval > 0 {
|
||||
env.SetNotificationConfig(keywords, minInterval)
|
||||
log.Printf("hello ack: loaded %d notification keywords", len(keywords))
|
||||
env.SetNotificationConfig(keywords, minInterval, clipboardEnabled)
|
||||
log.Printf("hello ack: loaded %d notification keywords clipboard=%v", len(keywords), clipboardEnabled)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ func HandleNotificationConfig(_ context.Context, env *runtime.Env, envelope map[
|
||||
|
||||
var keywords []string
|
||||
minInterval := 0
|
||||
clipboardEnabled := false
|
||||
|
||||
if raw, ok := envelope["keywords"].([]interface{}); ok {
|
||||
for _, v := range raw {
|
||||
@@ -32,8 +33,11 @@ func HandleNotificationConfig(_ context.Context, env *runtime.Env, envelope map[
|
||||
if v, ok := envelope["minIntervalMs"].(int); ok {
|
||||
minInterval = v
|
||||
}
|
||||
if v, ok := envelope["clipboardEnabled"].(bool); ok {
|
||||
clipboardEnabled = v
|
||||
}
|
||||
|
||||
env.SetNotificationConfig(keywords, minInterval)
|
||||
log.Printf("notification_config: loaded %d keywords", len(keywords))
|
||||
env.SetNotificationConfig(keywords, minInterval, clipboardEnabled)
|
||||
log.Printf("notification_config: loaded %d keywords clipboard=%v", len(keywords), clipboardEnabled)
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user