Skip to content
Snippets Groups Projects
Commit dbf40d5a authored by deuce's avatar deuce
Browse files

Support Canadian call signs as well and include more detail for US signs.

parent 1ca26faf
No related branches found
No related tags found
No related merge requests found
if(!js.global || js.global.HTTPRequest==undefined) if(!js.global || js.global.HTTPRequest==undefined)
load("http.js"); load("http.js");
//Bot_Commands={};
//function Bot_Command(x,y,z){}
Bot_Commands["CALLSIGN"] = new Bot_Command(0,false,false); Bot_Commands["CALLSIGN"] = new Bot_Command(0,false,false);
Bot_Commands["CALLSIGN"].command = function (target,onick,ouh,srv,lvl,cmd) { Bot_Commands["CALLSIGN"].command = function (target,onick,ouh,srv,lvl,cmd) {
var callsign; var callsign;
...@@ -21,7 +24,9 @@ Bot_Commands["CALLSIGN"].command = function (target,onick,ouh,srv,lvl,cmd) { ...@@ -21,7 +24,9 @@ Bot_Commands["CALLSIGN"].command = function (target,onick,ouh,srv,lvl,cmd) {
return true; return true;
} }
var CookieRequest=new HTTPRequest; function USCallsign(callsign, srv, target) {
var i;
var CookieRequest=new HTTPRequest();
var m=CookieRequest.Get('http://wireless2.fcc.gov/UlsApp/UlsSearch/searchLicense.jsp'); var m=CookieRequest.Get('http://wireless2.fcc.gov/UlsApp/UlsSearch/searchLicense.jsp');
var jsess=''; var jsess='';
var cookies=['refineIndex=0']; var cookies=['refineIndex=0'];
...@@ -41,15 +46,79 @@ Bot_Commands["CALLSIGN"].command = function (target,onick,ouh,srv,lvl,cmd) { ...@@ -41,15 +46,79 @@ Bot_Commands["CALLSIGN"].command = function (target,onick,ouh,srv,lvl,cmd) {
req.SendRequest(); req.SendRequest();
req.ReadResponse(); req.ReadResponse();
//m=req.body.match(/<a href=license.jsp\?.*?>\s*([^<]+)<.*?nowrap>\s*(^[<]*?)\s*<.*?nowrap>\s*(^[<]*?)\s*<.*?nowrap>\s*(^[<]*?)\s*<.*?nowrap>\s*(^[<]*?)\s*<.*?nowrap>\s*(^[<]*?)\s*</); m=req.body.match(/(license.jsp\?licKey=[^\s]*)/);
m=req.body.match(/<a href=license.jsp\?.*?>\s*([^<]+)\s*<[\x00-\xff]*?nowrap>\s*([^<]*?)\s*<[\x00-\xff]*?nowrap>\s*([^<]*?)\s*<[\x00-\xff]*?nowrap>\s*([^<]*?)\s*<[\x00-\xff]*?nowrap>\s*([^<]*?)\s*<[\x00-\xff]*?nowrap>\s*([^<]*?)\s*</);
if(m) {
var response=new HTTPRequest().Get('http://wireless2.fcc.gov/UlsApp/UlsSearch/'+m[1]);
m=response.match(/In the case of City, state and zip[^-]*?-->([\x00-\xff]*?)<\/td>/);
if(m) {
var info=callsign+':';
m[1]=m[1].replace(/<[^>]*>/g,'');
m[1]=m[1].replace(/[\r\n]/g,' ');
m[1]=m[1].replace(/\s+/g,' ');
info += m[1];
m=response.match(/>Type<\/td>[\x00-\xff]*?>([^<&]*)[<&]/);
if(m) {
m[1]=m[1].replace(/<[^>]*>/g,'');
m[1]=m[1].replace(/[\r\n]/g,' ');
m[1]=m[1].replace(/\s+/g,' ');
info += ' - Type: '+m[1];
}
m=response.match(/<!--Example: Amateur Extra -->([^&<]*?)[&<]/);
if(m) {
m[1]=m[1].replace(/<[^>]*>/g,'');
m[1]=m[1].replace(/[\r\n]/g,' ');
m[1]=m[1].replace(/\s+/g,' ');
info += ' - Class: '+m[1];
}
m=response.match(/>Status<\/td>[\x00-\xff]*?>([^<&]*)[<&]/);
if(m) { if(m) {
srv.o(target, callsign+" is : "+m[2]+" - "+m[5]+", Expiry: "+m[6]); m[1]=m[1].replace(/<[^>]*>/g,'');
m[1]=m[1].replace(/[\r\n]/g,' ');
m[1]=m[1].replace(/\s+/g,' ');
info += ' ('+m[1]+')';
}
srv.o(target,info);
} }
else { else {
srv.o(target, "Unable to match callsign!"); srv.o(target, "Unable to parse US callsign info!");
}
}
else {
srv.o(target, "Unable to match US callsign!");
}
}
function CanadaCallsign(callsign, srv, target) {
var result=new HTTPRequest().Post('http://www.callsign.ca/ind.php','indicatif='+callsign);
var m=result.match(/<H5>\s*([\x00-\xff]*?)<\/H5/);
if(m!=null) {
m[1]=m[1].replace(/<[^>]*>/g,'');
m[1]=m[1].replace(/[\r\n]/g,' ');
m[1]=m[1].replace(/\s+/g,' ');
srv.o(target, m[1]);
}
else {
srv.o(target, "Unable to match Canadian callsign!");
}
}
if(callsign.search(/(C[F-K]|C[Y-Z]|V[A-GOXY]|X[J-O])/)==0) {
CanadaCallsign(callsign, srv, target);
}
else if(callsign.search(/(A[A-L]|K|N|W)/)==0) {
USCallsign(callsign,srv,target);
}
else {
srv.o(target,"Callsign country not supported.");
} }
return true; return true;
} }
//var dumb={o:function(x,y) {log(y);}};
//Bot_Commands["CALLSIGN"].command(undefined, undefined, undefined,dumb,undefined,['asdf','kj6pxy']);
//Bot_Commands["CALLSIGN"].command(undefined, undefined, undefined,dumb,undefined,['asdf','va6rrx']);
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment