From 13ecfd72045bfd5015c634fe7f0ba17bbe1cbc78 Mon Sep 17 00:00:00 2001 From: Knut Ahlers Date: Wed, 22 Sep 2021 16:10:57 +0200 Subject: [PATCH] [wiki] Move examples to extra page, update to new config format Signed-off-by: Knut Ahlers --- wiki/Examples.md | 132 +++++++++++++++++++++++++++++++++++++++++++++++ wiki/Home.md | 104 ------------------------------------- 2 files changed, 132 insertions(+), 104 deletions(-) create mode 100644 wiki/Examples.md diff --git a/wiki/Examples.md b/wiki/Examples.md new file mode 100644 index 0000000..d07b747 --- /dev/null +++ b/wiki/Examples.md @@ -0,0 +1,132 @@ +# Rule examples + +## Chat-addable generic text-respond-commands + +```yaml + # Respond with variable content if set + - actions: + - type: respond + attributes: + message: '{{ variable (concat ":" "genericcmd" .channel (group 1)) }}' + disable_on_template: '{{ eq (variable (concat ":" "genericcmd" .channel (group 1))) "" }}' + match_channels: ['#mychannel'] + match_message: '^!([^\s]+)(?: |$)' + + # Set variable content to content of chat command + - actions: + - type: setvariable + attributes: + variable: '{{ concat ":" "genericcmd" .channel (group 1) }}' + set: '{{ group 2 }}' + - type: respond + attributes: + message: '[Admin] Set command !{{ group 1 }} to "{{ group 2 }}"' + enable_on: [broadcaster, moderator] + match_channels: ['#mychannel'] + match_message: '^!setcmd ([^\s]+) (.*)' + + # Remove variable and therefore delete command + - actions: + - type: setvariable + attributes: + variable: '{{ concat ":" "genericcmd" .channel (group 1) }}' + clear: true + - type: respond + attributes: + message: '[Admin] Deleted command !{{ group 1 }}' + enable_on: [broadcaster, moderator] + match_channels: ['#mychannel'] + match_message: '^!clearcmd ([^\s]+)' +``` + +## Game death counter with dynamic name + +```yaml + - actions: + - type: counter + attributes: + counter: '{{ channelCounter (recentGame .channel) }}' + - type: respond + attributes: + message: >- + I already died {{ counterValue (channelCounter (recentGame .channel)) }} + times in {{ recentGame .channel }}' + cooldown: 60s + enable_on: [broadcaster, moderator] + match_channels: ['#mychannel'] + match_message: '^!death' +``` + +## Link-protection while allowing Twitch clips + +```yaml + - actions: + - type: timeout + attributes: + duration: 1s + - type: respond + attributes: + message: '@{{ .username }}, please ask for permission before posting links.' + disable_on: [broadcaster, moderator, subscriber, vip] + disable_on_match_messages: + - '^(?:https?://)?clips\.twitch\.tv/[a-zA-Z0-9-]+$' + disable_on_permit: true + match_channels: ['#mychannel'] + match_message: '(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z0-9][a-z0-9-]{0,61}[a-z0-9]' +``` + +## Post follow date for an user + +```yaml + - actions: + - type: respond + attributes: + message: 'You followed on {{ ( followDate .username ( fixUsername .channel ) ).Format "2006-01-02" }}' + match_channels: ['#mychannel'] + match_message: '^!followage' +``` + +## Respond to a message after random delay + +```yaml + - actions: + # Respond after 30-40s + - type: delay + attributes: + delay: 30s + jitter: 10s + - type: respond + attributes: + message: 'Hey {{ .username }}' + match_channels: ['#mychannel'] + match_message: '^Hi' +``` + +## Send a notification on successful permit + +```yaml + - actions: + - type: respond + attributes: + message: >- + @{{ fixUsername (arg 1) }}, you will not get timed out + for the next {{ .permitTimeout }} seconds. + match_channels: ['#mychannel'] + match_event: 'permit' +``` + +## Shoutout command with game query + +```yaml + - actions: + - type: respond + attributes: + message: >- + Check out @{{ fixUsername (group 1) }} and leave a follow, + they were last playing {{ recentGame (fixUsername (group 1)) "something mysterious" }} + at https://twitch.tv/{{ fixUsername (group 1) }} + enable_on: [broadcaster, moderator] + match_channels: ['#mychannel'] + match_message: '^!so ([@\w]+)' +``` + diff --git a/wiki/Home.md b/wiki/Home.md index 853f42c..287273d 100644 --- a/wiki/Home.md +++ b/wiki/Home.md @@ -191,107 +191,3 @@ The example was dumped using this action: match_channels: ['#tezrian'] match_message: '^!test' ``` - -## Rule examples - -### Chat-addable generic text-respond-commands - -```yaml - # Respond with variable content if set - - actions: - - respond: '{{ variable (concat ":" "genericcmd" .channel (group 1)) }}' - disable_on_template: '{{ eq (variable (concat ":" "genericcmd" .channel (group 1))) "" }}' - match_channels: ['#mychannel'] - match_message: '^!([^\s]+)(?: |$)' - - # Set variable content to content of chat command - - actions: - - variable: '{{ concat ":" "genericcmd" .channel (group 1) }}' - set: '{{ group 2 }}' - - respond: '[Admin] Set command !{{ group 1 }} to "{{ group 2 }}"' - enable_on: [broadcaster, moderator] - match_channels: ['#mychannel'] - match_message: '^!setcmd ([^\s]+) (.*)' - - # Remove variable and therefore delete command - - actions: - - variable: '{{ concat ":" "genericcmd" .channel (group 1) }}' - clear: true - - respond: '[Admin] Deleted command !{{ group 1 }}' - enable_on: [broadcaster, moderator] - match_channels: ['#mychannel'] - match_message: '^!clearcmd ([^\s]+)' -``` - -### Game death counter with dynamic name - -```yaml - - actions: - - counter: '{{ channelCounter (recentGame .channel) }}' - - respond: >- - I already died {{ counterValue (channelCounter (recentGame .channel)) }} - times in {{ recentGame .channel }}' - cooldown: 60s - enable_on: [broadcaster, moderator] - match_channels: ['#mychannel'] - match_message: '^!death' -``` - -### Link-protection while allowing Twitch clips - -```yaml - - actions: - - timeout: 1s - - respond: '@{{ .username }}, please ask for permission before posting links.' - disable_on: [broadcaster, moderator, subscriber, vip] - disable_on_match_messages: - - '^(?:https?://)?clips\.twitch\.tv/[a-zA-Z0-9-]+$' - disable_on_permit: true - match_channels: ['#mychannel'] - match_message: '(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z0-9][a-z0-9-]{0,61}[a-z0-9]' -``` - -### Post follow date for an user - -```yaml - - actions: - - respond: 'You followed on {{ ( followDate .username ( fixUsername .channel ) ).Format "2006-01-02" }}' - match_channels: ['#mychannel'] - match_message: '^!followage' -``` - -### Respond to a message after random delay - -```yaml - - actions: - # Respond after 30-40s - - delay: 30s - delay_jitter: 10s - - respond: 'Hey {{ .username }}' - match_channels: ['#mychannel'] - match_message: '^Hi' -``` - -### Send a notification on successful permit - -```yaml - - actions: - - respond: >- - @{{ fixUsername (arg 1) }}, you will not get timed out - for the next {{ .permitTimeout }} seconds. - match_channels: ['#mychannel'] - match_event: 'permit' -``` - -### Shoutout command with game query - -```yaml - - actions: - - respond: >- - Check out @{{ fixUsername (group 1) }} and leave a follow, - they were last playing {{ recentGame (fixUsername (group 1)) "something mysterious" }} - at https://twitch.tv/{{ fixUsername (group 1) }} - enable_on: [broadcaster, moderator] - match_channels: ['#mychannel'] - match_message: '^!so ([@\w]+)' -```