|
| 1 | +--- |
| 2 | +title: Quotes Commands for v1.0.0+ |
| 3 | +description: An example how to get and add quotes using commands in Streamer.bot v1.0.0+ |
| 4 | +author: pwnyy |
| 5 | +icon: i-mdi-format-quote-close |
| 6 | +navigation: false |
| 7 | +difficulty: 1 |
| 8 | +--- |
| 9 | + |
| 10 | +::warning |
| 11 | +This is only for Streamer.bot v1.0.0 and above! |
| 12 | +:: |
| 13 | + |
| 14 | +In Streamer.bot v1.0.0+, the built-in quote command "!quote" has been removed. This allows for more customization and flexibility in how quotes are retrieved and displayed. With that the "Show Quote" trigger will also not work anymore. |
| 15 | +The following example shows how to create your own "!quote" command to either retrieve a random quote or a specific quote by its index. |
| 16 | + |
| 17 | +An import is provided at the end of the instructions, which includes a "!quote" and "!quoteadd" command. |
| 18 | + |
| 19 | +The instructions below will guide you through the process of creating a quote command that can retrieve quotes, and add new quotes. |
| 20 | +Keep in mind this is just an example, and you can customize the sub-actions to your liking. The following sub-actions will be used to retrieve a random quote or a specific quote by its index. It will also be checked whether or not a command input is a number or not via inline math. |
| 21 | + |
| 22 | +## Instructions (Get Quote) |
| 23 | + |
| 24 | +1. Creating an action |
| 25 | + |
| 26 | + To create a new action head to the **Actions** tab and right-click in the actions section. Select **Add Action** and name it something like "Get Quote". This action will be used to retrieve a random quote or a specific quote by its index. |
| 27 | + |
| 28 | +2. Adding the "!quote" command trigger |
| 29 | + |
| 30 | + Next step would be adding our trigger for the command. Right-click in the **Triggers** section and select `Core -> Commands -> Command Triggered`. |
| 31 | + If you already have a command like "!quote" and want to use that, you can select it from the dropdown menu. If not, you can create a new command by clicking on the `Create Command` button below the dropdown. |
| 32 | + |
| 33 | + Give the command a name like "Get Quote" and set the command itself to `!quote`, or anything you like. |
| 34 | + Leave the location to `Start`, this will allow the command to also check an input. |
| 35 | + |
| 36 | + The other settings can be left as is, unless you want to change them. For example, you can set the `Cooldown` to prevent spamming the command. |
| 37 | + |
| 38 | +  |
| 39 | + |
| 40 | +3. Check whether input is empty or not |
| 41 | + First we want to check whether the input, in our case the argument `input0` is empty or not. If it is empty, we will retrieve a random quote, otherwise we will try to retrieve a specific quote by the input. |
| 42 | + To do this, we will use an the sub-action `Core -> Logic > If/Else`. |
| 43 | + |
| 44 | + - In the Input field you would write `%input0%` to get the value of the input0 argument. |
| 45 | + - The Operation would be `Is Null or Empty`. |
| 46 | + |
| 47 | + After clicking `OK`, you will see a new If/Else block in your action. In the `True` group, we will retrieve a random quote, and in the `False` group we will try to retrieve a specific quote by its index. |
| 48 | +  |
| 49 | +4. Get a random quote and send the message |
| 50 | + |
| 51 | + In the `True` group of the If/Else block, we will retrieve a random quote. |
| 52 | + To do this, right-click on the `True Result` group and add the sub-action `Core -> Quotes -> Get Quote`. |
| 53 | + Or you can also click on the `True Result` group and search for the `Get Quote` sub-action in the search bar. |
| 54 | + |
| 55 | + In the sub-action itself make sure you select `Random` as the `Type` and click `OK`. This will retrieve a random quote from the quotes. |
| 56 | + |
| 57 | + Next, we want to send the quote as a message. Add the sub-action `Twitch -> Chat -> Send Message to Channel` to the `True Result` group, and make sure it's under the `Get Random Quote` sub-action. |
| 58 | + In the `Message` field you can write something like `%quoteId% %quote% - %quoteUser%` to send the quote ID, the quote itself and the user who added the quote. |
| 59 | + |
| 60 | +5. Check whether input is a number or not |
| 61 | + |
| 62 | + In the `False` group of the If/Else block, we will continue down the path to retrieve a specific quote by its index. |
| 63 | + |
| 64 | + However first we want to check whether the input is a number or not, this would still be in the `False` group. |
| 65 | + |
| 66 | + This can be done the following way: |
| 67 | + 1. Add a sub-action Core -> Arguments -> Set Argument. |
| 68 | + - Variable Name: `quoteNum` |
| 69 | + - Value: `$math( floor( %input0% ) )$` |
| 70 | + |
| 71 | + The math function will round down the input to the nearest whole number. If the value of `input0` is not a number, the value of `quoteNum` will be `NaN` which we can check with another `if/else`. |
| 72 | + :read-more{to="/guide/variables#math"} |
| 73 | + |
| 74 | + 2. Add another `If/Else` sub-action to check whether the `quoteNum` value is a number or not. |
| 75 | + - Input: `%quoteNum%` |
| 76 | + - Operation: `Equals` |
| 77 | + - Value: `NaN` |
| 78 | + |
| 79 | + In the `True` group, you can now add another sub-action to send a message to the channel that the input is not a number, or you simply leave it empty. |
| 80 | + |
| 81 | + In the `False` group, we will continue and try to retrieve the specific quote by its index. |
| 82 | + |
| 83 | +  |
| 84 | + |
| 85 | +6. Get a specific quote and send the message |
| 86 | + |
| 87 | + Since we have already checked that the input is a number, we can now retrieve the specific quote by its index. |
| 88 | + To do this we want to add the sub-action `Core -> Quotes -> Get Quote`, and as the `Type` we will select `Specific`. The `Quote ID` field will be set to `%quoteNum%`, which will retrieve the value of the `quoteNum` variable we set earlier. |
| 89 | + |
| 90 | + :read-more{to="/sub-actions/core/quotes/get-quote"} |
| 91 | + |
| 92 | + The last thing we want to do is check whether or not a quote was able to be retrieved. This can be done by adding yet another `If/Else` sub-action under the `Get Quote` sub-action. |
| 93 | + |
| 94 | + We want to check whether the argument `quote`, or other quote related arguments were even created by the `Get Quote` sub-action. |
| 95 | + - Input: `quote` |
| 96 | + - Operation: `Does Not Exist` |
| 97 | + |
| 98 | + Why do we not add % around `quote`? Because we don't want the value of the `quote` argument, but rather check if the literal name `quote` exists as an argument. |
| 99 | + |
| 100 | + - In the `True` group, we can add a sub-action to send a message to the channel that the quote was not found, or you can leave it empty. |
| 101 | + - In the `False` group, we can add the sub-action `Twitch -> Chat -> Send Message to Channel` to send the quote as a message. |
| 102 | + - For example: `#%quoteId%: %quote% - %quoteUser%` |
| 103 | + |
| 104 | +  |
| 105 | + |
| 106 | +## Instructions (Add Quote) |
| 107 | + Adding a quote is fairly straightforward, we will create a new action that will be used to add a simple command input as the quote. This will it that the quote is referenced to the streamer, and not the the user who added it via the command. |
| 108 | + |
| 109 | +1. Creating an action |
| 110 | + |
| 111 | + To create a new action head to the **Actions** tab and right-click in the actions section. Select **Add Action** and name it something like "Add Quote". |
| 112 | + |
| 113 | +2. Adding the "!quoteadd" command trigger |
| 114 | + |
| 115 | + This step is pretty much the same as the previous one for just adding a !quote command. Just in this case we give it a different name and a different command itself. |
| 116 | + |
| 117 | + - Right-click in the **Triggers** section and select `Core -> Commands -> Command Triggered`. |
| 118 | + If you already have a command like "!quoteadd" and want to use that, you can select it from the dropdown menu. If not, you can create a new command by clicking on the `Create Command` button below the dropdown. |
| 119 | + |
| 120 | + Give the command a name like "Add Quote" and set the command itself to `!quoteadd`, or anything you like. |
| 121 | + Leave the location to `Start`, this will allow the command to also check an input. |
| 122 | + |
| 123 | + The other settings can be left as is, unless you want to change them. For example, you can set the `Cooldown` to prevent spamming the command. |
| 124 | + |
| 125 | +3. Adding the quote itself |
| 126 | + |
| 127 | + Next, we want to add the quote itself. To do this, we will use the sub-action `Core -> Quotes -> Add Quote`. |
| 128 | + |
| 129 | + In the `Variable` field, we will write `%rawInput%`, this will get the whole input of the command, so the value of `rawInput`. |
| 130 | + |
| 131 | +  |
| 132 | + |
| 133 | +4. Check if the quote was added successfully |
| 134 | + |
| 135 | + After adding the quote, we want to check whether or not the quote was added successfully. This can be done by adding another `If/Else` sub-action. |
| 136 | + - Input: `%success%` |
| 137 | + - Operation: `Equals` |
| 138 | + - Value: `True` |
| 139 | + |
| 140 | + In the `False` group, we can then add a `Break` sub-action to stop the action from continuing, since the quote was not added successfully. |
| 141 | + |
| 142 | + Below the whole `If/Else` block, you can also put this in the `True` group`, we can then add a sub-action to send a message to the channel that the quote was added successfully. |
| 143 | + |
| 144 | + So create a sub-action `Twitch -> Chat -> Send Message to Channel` and write something like `Quote added successfully! ID: %quoteId% - %quote%` in the `Message` field. |
| 145 | + |
| 146 | +## Import |
| 147 | + |
| 148 | +As mentioned at the start here is the import for Streamer.bot v1.0.0 and above. This includes the `!quote` and `!quoteadd` commands, and the needed actions. |
| 149 | + |
| 150 | +```bash [streamerbot-import] |
| 151 | +U0JBRR+LCAAAAAAABADtW0mP20YWvgfIf2A6MZBgXE7ti2+OZ+Lpi5EZe3IxfKi1TUQSFZLqthH4v09xldQkJard3W4bqYMgsl5tb/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