diff --git a/README.md b/README.md index 4a719684..547a1d9e 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,7 @@ PBot is a versatile IRC Bot written in Perl * [Substitution](#substitution) * [Chaining](#chaining) * [Variables](#variables) + * [Selectors](#selectors) * [Inline invocation](#inline-invocation) * [Background processing](#background-processing) * [Extensible](#extensible) @@ -145,6 +146,12 @@ combine their effects. !echo $greeting:uc HELLO, WORLD +#### Selectors +You can select a random item from a selection list and interpolate the value within commands. + + !echo This is a %(neat|cool|awesome) bot. + This is a cool bot. + #### Inline invocation You can invoke up to three commands inlined within a message. If the message is addressed to a nick, the output will also be addressed to them. diff --git a/doc/Commands.md b/doc/Commands.md index b007e0db..c92d5f61 100644 --- a/doc/Commands.md +++ b/doc/Commands.md @@ -10,6 +10,7 @@ * [Piping](#piping) * [Substitution](#substitution) * [Variables](#variables) + * [Selectors](#selectors) * [Background processing](#background-processing) * [Types of commands](#types-of-commands) * [Built-in commands](#built-in-commands) @@ -295,6 +296,25 @@ combine their effects. !echo $greeting:uc HELLO, WORLD +### Selectors +You can select a random item from a selection list and interpolate the value within commands. + +The syntax for selectors is: + + %()[:modifiers] + +`` is a list of items separated by a vertical bar. + +`[:modifiers]` is an optional list of modifiers, each prefixed with a colon. See [expansion-modifiers](Factoids.md#expansion-modifiers). + +Examples: + + !echo This is a %(neat|cool|awesome) bot. + This is a cool bot. + + !echo IRC is %(fun|weird|confusing|amazing):pick_unique(2):enumerate + IRC is weird and fun + ### Background processing Any command can be flagged to be executed as a background process. For example, suppose you make a Plugin that has a command that may potentially take a long time to complete, which could diff --git a/doc/README.md b/doc/README.md index 539875c9..98c24024 100644 --- a/doc/README.md +++ b/doc/README.md @@ -42,6 +42,7 @@ * [Piping](Commands.md#piping) * [Substitution](Commands.md#substitution) * [Variables](Commands.md#variables) + * [Selectors](Commands.md#selectors) * [Background processing](Commands.md#background-processing) * [Types of commands](Commands.md#types-of-commands) * [Built-in commands](Commands.md#built-in-commands)