Crea comandos personalizados con código simple.
⚠️ Importante: El código se ejecuta en el servidor con un máximo de ejecución de 125 segundos
📝 Funciones Esenciales
SendMessage("¡Hola!")
If IsCommand("/start") Then
SendMessage("¡Bienvenido!")
Stop
EndIfStop es CRUCIAL después de SendMessage() para evitar respuestas duplicadas
If IsCommand("/buscar", True) Then
EndIf
SetLLMContext("Responde como experto en cocina")
SetLLMInstructions("Traduce todo lo que {user} te dice al inglés")
SaveSettings("puntos", "100")
puntos = LoadSettings("puntos")
SaveSettings("puntos")
userId = GetUserID()
chatId = GetChatID()
CreateButton("texto", "callback_data")
CreateOption("texto")
OneTimeKeyboard(keyboard)
keyboard = CreateKeyboard(boton1, boton2, …)
keyboard = OneTimeKeyboard(keyboard)
fila1 = CreateKeyboard(boton1, boton2)
fila2 = CreateKeyboard(boton3, boton4)
keyboard = CreateKeyboard(fila1, fila2)
keyboard = CreateOptions(opcion1, opcion2, …)
fila1 = CreateOptions(opcion1, opcion2)
fila2 = CreateOptions(opcion3, opcion4)
keyboard = CreateOptions(fila1, fila2)
keyboard = RemoveKeyboard()
CopyMessage(id_numerico_del_mensaje_a_copiar, "id_del_chat_del_mensaje_a_copiar")
🚀 Ejemplos Prácticos
If IsCommand("/traducir", True) Then
SetLLMContext("Traduce al inglés")
EndIf
If IsCommand("/modo_serio") Then
SendMessage("Modo serio activado.")
SetLLMContext("Responde de forma seria y profesional.")
EndIf
If IsCommand("/modo_divertido") Then
SendMessage("¡Modo divertido! 🎉")
SetLLMContext("Responde de forma alegre con emojis.")
SaveSettings("fun_" & GetChatID(), True)
EndIf
If IsCommand("/puntos") Then
puntos = LoadSettings("puntos_" & GetUserID())
If puntos = "" Then puntos = 0
SendMessage("Tienes " & puntos & " puntos")
Stop
EndIf
If IsCommand("/añadirpunto") Then
clave = "puntos_" & GetUserID()
puntos = LoadSettings(clave)
If puntos = "" Then puntos = 0
puntos = puntos + 1
SaveSettings(clave, puntos)
SendMessage("¡+1 punto! Total: " & puntos)
Stop
EndIf
If IsCommand("/encuesta") Then
keyboard = "[{~qtext~q:~q😊 Sí~q,~qcallback_data~q:~qsi~q},{~qtext~q:~q😐 No~q,~qcallback_data~q:~qno~q}]"
SendMessage("¿Te gusta TeleChars AI?", 0, keyboard)
Stop
EndIf
callbackData = GetCallbackText()
If callbackData <> "" Then
If callbackData = "si" Then
SendMessage("¡Gracias! 😊")
Else
SendMessage("¿Cómo podemos mejorar?")
EndIf
Stop
EndIfEn strings, los ~q son una forma rápida de poner comillas dobles, al igual que los ~n son saltos de línea, y los ~t son tabulaciones.
If IsCommand("/encuesta") Then
boton1 = CreateButton("😊 Sí", "si")
boton2 = CreateButton("😐 No", "no")
keyboard = CreateKeyboard(boton1, boton2)
SendMessage("¿Te gusta TeleChars AI?", 0, keyboard)
Stop
EndIf
callbackData = GetCallbackText()
If callbackData <> "" Then
If callbackData = "si" Then
SendMessage("¡Gracias! 😊")
Else
SendMessage("¿Cómo podemos mejorar?")
EndIf
Stop
EndIfEste ejemplo simplifica la creación de teclados sin necesidad de escribir JSON manualmente.
If IsCommand("/menu") Then
fila1 = CreateKeyboard(CreateButton("Opción 1", "opt1"), CreateButton("Opción 2", "opt2"))
fila2 = CreateKeyboard(CreateButton("Opción 3", "opt3"), CreateButton("Opción 4", "opt4"))
keyboard = CreateKeyboard(fila1, fila2)
SendMessage("Selecciona una opción:", 0, keyboard)
Stop
EndIf
callbackData = GetCallbackText()
If callbackData <> "" Then
SendMessage("Elegiste: " & callbackData)
Stop
EndIfPara crear múltiples filas, primero crea cada fila con CreateKeyboard y luego pásalas a otro CreateKeyboard
If IsCommand("/opciones") Then
fila1 = CreateOptions(CreateOption("Opción 1"), CreateOption("Opción 2"))
fila2 = CreateOptions(CreateOption("Opción 3"), CreateOption("Opción 4"))
keyboard = CreateOptions(fila1, fila2)
SendMessage("Selecciona una opción", 0, keyboard)
Stop
EndIf
userText = GetValue("user_text")
If Instr(userText, "Opción ") = 1 Then
SendMessage("Elegiste: " & userText, 0, RemoveKeyboard())
Stop
EndIf
If IsCommand("/sticker") Then
CopyMessage(123, 1234567890)
Stop
ElseIf IsCommand("/sticker2") Then
CopyMessage(123, "@AbCdEFgh")
Stop
EndIf
🚫 Error común: Olvidar Stop después de SendMessage() genera respuestas duplicadas.
💡 Ideas de comandos:/traducir [texto]/modo_serio/modo_divertido/puntos/encuesta/quiz/recordar [texto]