insobot » Forums » User Guide: Aliases and PSAs
insofaras
Alex Baines
22 posts
1 project
#12079 User Guide: Aliases and PSAs
3 months, 2 weeks ago Edited by Alex Baines on Aug. 12, 2017, 5:03 p.m. Reason: mod_psa now supports regex + aliases

Aliases and PSAs allow you to make the bot say things so you don't have to.

In the case of aliases, you can create simple commands that make the bot give a canned response whenever a !command is said. PSAs are similar, but either respond automatically on a timer, or whenever a message contains a specific word/phrase.

If you're in your own twitch channel, or are whitelisted then you have permission to create/modify aliases & PSAs, as detailed here.

Aliases

To create or update an alias, use \alias <key> <text>.
<key> is the word that will follow the exclamation mark for the new alias.
<text> is what the bot will respond with, don't add quotes unless you want them in the response.

1
2
3
4
<me>      | \alias hello Hello there, %t
<insobot> | me: Alias hello set.
<me>      | !hello
<insobot> | Hello, me

This alias uses %t, which is one of the printf-style format sequences available.

This is a full list:
1
2
3
4
%t - Replaced by the name of whoever invoked the !command.
%a - Replaced by any arguments to the !command (text after it).
%n - Equivalent to %a if %a isn't an empty string, %t otherwise.
%u - URL-Encoded version of %a


To remove an alias, use \unalias <key>
1
2
<me>      | \unalias hello
<insobot> | me: Removed alias hello.


To view available aliases in a channel, use \lsa
1
2
<me>      | \lsa
<insobot> | me: Aliases in #here: !hello !test !something !keyboard


To change the required permissions to use an alias, use \chamod <key> <permission>
<permission> is either NORMAL, WLIST, or ADMIN.

Note that ADMIN is not particularly secure, since it only requires WLIST permission to use this permission changing command...
1
2
<me>      | \chamod hello WLIST
<insobot> | me: Set permissions on hello to WLIST

Local vs Global Aliases

All the commands mentioned previously are local to the channel that they are used from. So if you create an alias called hello in #place_a, it won't be available
in #place_b.

However there are an equivalent set of commands to create "global" aliases, that will be available in all channels on the same server. These are the same, but with an added 'g' character.

Here's a table:
1
2
3
4
5
6
Command |   Local  | Global
--------+----------+--------
Create  | \alias   | \galias
Update  | \alias   | \galias
Remove  | \unalias | \gunalias (cue firearm jokes)
List    | \lsa     | \lsga

Use them wisely.

Multiple keys for local aliases

Sometimes you might want an alias to be available via multiple keys. Copy pasting is an option, but if you want to update the text, you'd have to redo them all.

Fortunately there is a special syntax added by ChronalDragon to simplify this case.
When any one of the linked keys is updated, all the keys will recall the new text.
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
<me>      | \alias test This is a test
<insobot> | me: Alias test set.
<me>      | \alias boop -> test
<insobot> | me: Alias boop set.
<me>      | !boop
<insobot> | This is a test
<me>      | \alias boop Something else entirely
<insobot> | me: Alias boop set.
<me>      | !test
<insobot> | Something else entirely

PSAs

To create/update a PSA, use \psa+ <key> [options] <time>m <text>
<key> is a name you make up to identify the PSA, much like aliases
<time> is the cooldown in minutes, note the m that follows this is currently needed, i'm not exactly sure why though, so maybe I'll remove it soon...
[options] can one or more of the following:
  • +live
  • causes the PSA to only fire when the channel is live (on twitch)
  • +trigger '<regex>'
  • makes the PSA fire when the given regex matches a message,
    in this case <time> will be the minimum wait before it can fire again.
I hope you got all that, it'll be on the test. Here are some examples:

Send the message every 20 minutes, if the stream is live
1
2
<me>      | \psa+ safety +live 20m Don't run with scissors.
<insobot> | PSA [safety] Added.

Send the message when someone says "keyboard" or "kbd" with a 5min cooldown
1
2
<me>      | \psa+ kbd +trigger 'keyboard|kbd' 5m The keyboard currently in use is the Yamaha PSRF51
<insobot> | PSA [kbd] Added.

Recall the alias "!welcome" when someone says anything, with a 15min cooldown
1
2
<me>      | \psa+ greet +trigger '.' 15m !welcome
<insobot> | PSA [greet] Added.

Send the message when "alot" is said, and the stream is live, with a 10m cooldown
1
2
<me>      | \psa+ alot +live +trigger 'alot' 10m https://hyperboleandahalf.blogspot.co.uk/2010/04/alot-is-better-than-you-at-everything.html
<insobot> | PSA [alot] Added.

To remove a PSA, use \psa- <key>
1
2
<me>      | \psa- safety
<insobot> | me: Deleted psa 'safety'

To view a list of PSAs in the channel, use \psa
1
2
<me>      | \psa
<insobot> | Current PSAs: [alot: 10m trigger='alot' (when live)] [kbd: 5m trigger='keyboard']

That should about cover it. If i've missed something, or you have questions, ask away below.