-
Notifications
You must be signed in to change notification settings - Fork 3
Responses
The most basic form of a response is just a plaintext string, like Lorem ipsum.
BotBot also supports randomized responses. When a comma-separated list of responses is enclosed in square brackets, BotBot will randomly select one to be used as the response whenever it is triggered.
For example, [Lorem, ipsum], when triggered, will randomly respond with either "Lorem" or "ipsum".
BotBot supports multiple responses for a single trigger. When a comma-separated list of responses is enclosed in curly brackets, BotBot will send each one as a separate message.
For example, {Lorem, ipsum}, when triggered, will respond with two separate messages: "Lorem" and "ipsum".
When an empty response is provided, no message is displayed. This can be especially useful for the randomized lists. For example, [Lorem ipsum,,,] will display "Lorem ipsum" 25% of the time and no message for the other 75% of the time.
These response methods may be nested or mixed.
When multiple response methods are placed next to each other inline, their resulting values are concatenated.
When multiple response methods are nested, they are evaluated from the outermost brackets inward.
Consider the following response string:
Lorem [ipsum, dolor {sit, amet}]
This has two possible responses:
- There is a 50% chance that the bot will respond with "Lorem ipsum".
This string was obtained from the concatenation of the plaintext string "Lorem " with the randomly selected string "ipsum". - There is a 50% chance that the bot will respond with the messages "Lorem dolor sit" and "Lorem dolor amet". These messages come from the concatenation of "Lorem " with "dolor {sit, amet}", which gets expanded to two messages, "dolor sit" and "dolor amet". "Lorem " is prepended to both "dolor sit" and "dolor amet", resulting in the two messages named above.
Don't worry if this is a little confusing; some experimentation with BotBot in Euphoria will help you learn the syntax.
To escape a character that would normally be treated as a special character by BotBot, precede it with a backslash \ to keep it from being interpreted as a special character.
For example, a response string of [Lorem, ipsum\, dolor] would reply with either "Lorem" or "ipsum, dolor" because the comma was preceded with a backslash to keep it from being treated as a separator.
Special tokens are deprecated in favor of variables. Instead of (sender) etc. use ${sender}; instead of (@sender) use ${atsender}.
If you use the token (sender) in the response, it will be replaced with the username of the person who sent the message to which your bot is currently replying.
For example, if user "my hands are typing words" sends a message that triggers a bot who is coded to respond with (sender), that bot will reply with the message, "my hands are typing words".
Similarly, if you use the token (@sender) in the response, it will be replaced with an @-mention for the username of the person who sent the message to which your bot is currently replying.
For example, if user "my hands are typing words" sends a message that triggers a bot who is coded to respond with (@sender), that bot will reply with the message, "@myhandsaretypingwords", which will ping that user via Euphoria's UI.
Additionally, if you use the token (room) in the response, it will be replaced with the room from which the message to which your bot is currently replying was sent.
For example, if a user sends a message from room &bots that triggers a bot who is coded to respond with (room), that bot will reply with the message, "bots". This can easily be changed to include an "&" simply by using &(room).
Other special tokens include:
-
(uptimeutc): The time when the bot was started, in UTC. -
(uptime): How long the bot has been running. -
(uuid): The bot's UUID, used for identifying the bot on the BotBot server.
Sometimes you might want a bot to reply in the same thread, rather than replying directly (and thereby creating a new thread). You can do this by putting !inline in front of your message.
For example, i hate threads -> !inline yeah, me too! will always reply in the same thread (unless the original message was top-level, in which case it will reply as normal)
Bots can silently communicate with each other, even through different rooms, using inter-bot communication. This is done by having your bot send a message with the syntax, !to @DestinationBotName &destinationroomname Lorem ipsum.
This will send a message to all bots with name @DestinationBotName in room &destinationroomname.
If &destinationroomname is omitted, the message will be sent to all bots with name @DestinationBotName in all rooms.
The receiving bot will see the message as if it was sent by a Euphoria user, and so will not reply if the inter-bot message does not trigger the bot.
Replies appear as top-level threads in Euphoria.
Note that during inter-bot communication, the (sender), (@sender), and (room) fields are preserved, meaning that those fields correspond to the Euphoria user who initiated the inter-bot communication, not the bot.
For now, bots support only the control flow mechanism !break, which stops a bot from sending any more messages for a response after the !break command is issued.
For example, observe the following sample code.
ignore -> !break;
^ -> Lorem ipsum
In this sample code, any sent message (matched by ^, which is a line start anchor) will trigger the bot to reply with "Lorem ipsum" unless the message contains the word "ignore". If a message contains the word "ignore", the bot sends the !break command, thereby suppressing any future output for that command, including the "Lorem ipsum" message that would have otherwise been displayed.
A bot may send the !nick command to attempt to change its nickname.
The syntax is: !nick DesiredNickname
This nickname can contain spaces, as opposed to the nickname used when creating the bot, which cannot contain spaces.
Do not use the @-mention syntax for the !nick command.
To change a bot's name to "TestBot", that bot must send !nick TestBot, not !nick @TestBot.
If the nick is longer than 36 characters, or otherwise rejected by the server, then the nick change will silently fail.
Note that if the nickname of a bot is changed in this way, BotBot system commands will use the nickname set by this command rather than the nickname that the bot initially used.
For example, if a bot is created with the nickname "OldNickname", but it sends the command !nick New Nickname to change its name to "New Nickname", the bot must be killed with the command !kill @NewNickname.