Skip to content

Instantly share code, notes, and snippets.

@roskoff
Created October 4, 2008 13:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save roskoff/14751 to your computer and use it in GitHub Desktop.
Save roskoff/14751 to your computer and use it in GitHub Desktop.
// ---------------------------
// SMS-TIGO (English Version)
// ---------------------------
var imageId = "";
CmdUtils.CreateCommand({
name: "sms-tigo",
icon: "http://www.tigo.com.py/favicon.ico",
author: { name: "Eliseo Ocampos", email: "roskoff@gmail.com"},
license: "MPL",
description: "Sends a SMS to a cell phone registered in Tigo (cell phone and telecomunications company: www.tigo.com.py)",
help: "Write the message (mensaje) to send, then fill the cell phone number destinatary (para 098xnnnnnn), " +
" <br/> then the captcha code (codigo xxxx) and then an optional sender (firma your-name)." +
" <br/> You have to wait until the captcha image is loaded.",
takes: {mensaje: noun_arb_text},
modifiers: {para: noun_arb_text, codigo: noun_arb_text, firma: noun_arb_text},
preview: function( pblock ){
var mens = "";
var imageIdUrl = "http://www.tigo.com.py/cgi/get_id_sms.php?1222714899111.38";
var getImageUrl = "http://idt.telecel.com.py/brian/sms/sms_img.php?rid=";
pblock.innerHTML = "Sends a SMS to Tigo, requesting captcha image...";
if( imageId=="") {
displayMessage("Requesting captcha image..."); // debug message
jQuery.get(imageIdUrl, function(data){
imageId = data.substr(3);
});
}
mens = "The captcha image will appear in a moment.Codigo de seguridad invalido.. <br/>";
mens += "[ <img src='%s' />".replace( /%s/, getImageUrl + imageId) + " ]";
//+ " (" + imageId + ") </div>"; // debug
pblock.innerHTML = mens;
},
execute: function(mensaje, mods){
var urlEnvio = "http://www.tigo.com.py/cgi/envio_portal.php?";
var params = {hcaracteristica:mods.para.text.substr(0,4),
htexto: mensaje.text,
hpara: mods.para.text.substr(4),
hfirma: mods.firma.text,
hpin:'',
strRID: mods.codigo.text,
intID: imageId.substr(0,8)};
imageId = "";
jQuery.get(urlEnvio,
params,
function(data){
// The response will have the form: <id0>=<value0>&<id1>=<value1>, i.e.:
// blnkOk=false&errorMsg="Codigo de seguridad invalido"
var results = data.split("&");
var okStatus = results[0].split("=");
var errorMessage = results[1].split("=");
if (okStatus[1] == "true") {
displayMessage("[sms-tigo] Message sent");
} else {
displayMessage("[sms-tigo] Error sending SMS: " + errorMessage[1]);
}
}
);
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment