Comandos personalizados: de una etiqueta a una condición
Un comando del bot es el texto que dice en el chat. Ese texto puede llevar sustituciones — el nombre del espectador, el título del stream, un número al azar — y bloques: condiciones, aritmética, una elección al azar. Abajo está todo lo que entiende el bot, con ejemplos.
Dónde se crean los comandos
En el sitio: panel de control → «Comandos del canal» → «Añadir comando». Ahí también se configuran los permisos, el tiempo de espera, los alias y la repetición automática, y el texto se comprueba mientras escribes.
Desde el chat, si eres moderador del canal:
!создать !обнял ${user} обнял ${arg1}
Sustituciones
Una sustitución es ${…} dentro del texto del comando. El bot la reemplaza por un valor en el momento de responder.
| ${notag} | no mention The bot will not address the person who ran the command. |
| ${user} | viewer name Who the command is addressed to: the caller, or the name given after the command. |
| ${randomchatter} | random viewer A random name from chat. Twitch: the bot needs moderator rights. Kick: not supported. |
| ${title} | stream title The current stream title. |
| ${game} | category The current stream category. |
| ${arg1} | 1st word The first word after the command. |
| ${arg2} | 2nd word The second word after the command. |
| ${arg3} | 3rd word The third word after the command. |
| ${args} | everything after Everything written after the command. |
| ${rand 1 100} | random number A random number from the first to the second, both included. |
| ${arg1:кто-нибудь} | word or fallback The first word after the command, or — when there is none — whatever stands after the colon. Also works with ${arg2}, ${arg3}, ${args}, ${user}. |
Bloques
Un bloque es {word …} dentro del texto del comando. Los bloques se resuelven antes de rellenar los valores y hacen lo que una sustitución no puede: elegir, contar y comparar.
| {if} | if A different answer depending on a condition. {elif} and {else} are allowed; {end} closes it. |
| {math} | math Add, subtract, multiply, divide, remainder. No powers. |
| {pick} | pick One of the options listed with a vertical bar. |
| {countdown} | time left How much time is left until a date: DD.MM or DD.MM.YYYY, optionally with a time. |
| {countup} | time since How much time has passed since a date. |
| {upper} | UPPERCASE The text in capital letters. |
| {lower} | lowercase The text in small letters. |
| {len} | length How many characters the text has. |
| {urlencode} | for a link The text made safe to put inside a URL. |
{if} tiene que cerrarse con {end}; entre ellos puede haber cualquier número de {elif} y un solo {else}. Los demás bloques se cierran solos.
Qué puede llevar una condición
Dentro de {if} y {math} puedes usar números, texto entre comillas, sustituciones, paréntesis y estas operaciones:
| == != | igual y distinto; no importa si son mayúsculas o minúsculas |
| < > <= >= | mayor, menor: los números como números, el texto por orden alfabético |
| contains | si el texto de la izquierda contiene el de la derecha |
| starts ends | empieza por … y termina en … |
| and or not | y, o, no |
| + - * / % | sumar, restar, multiplicar, dividir, resto |
Ejemplos listos para usar
Abrazar a alguien y, si no se indica ningún nombre, volver a preguntar:
{if ${arg1} == ""}кого обнимать-то?{else}${user} обнял ${arg1}{end}
Lo mismo, más corto, con un valor por defecto:
${arg1:кого-нибудь} получает пирожок
Cuánto falta para una fecha:
До Нового года {countdown 01.01}
Dos dados:
выпало {math ${rand 1 6} + ${rand 1 6}}
Una elección al azar:
${user}, сегодня ты {pick кот|пёс|бобр}
Varias ramas seguidas:
{if ${args} contains "спасибо"}и тебе!{elif ${args} == ""}чего молчишь?{else}не понял{end}
Cuando el bot responde con llaves
El texto no se pudo analizar; lo más habitual es que falte {end}. El editor del sitio comprueba el texto mientras escribes, señala qué está mal y dónde, y no deja guardar la versión rota, sin borrar lo que escribiste.
Desde el chat tampoco se acepta: !create y !edit responden que el texto tiene un error.