Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- print("\x0314"+scriptName()+" script by binary has been loaded successfully");
- String.prototype.includes = function() {'use strict'; return String.prototype.indexOf.apply(this, arguments) !== -1; };
- var rec = false;//api 0f9d0e934eb38b7bbc3356c1e5714350
- function rnd_color()
- {
- var letras = "0123456789ABCDEF".split('');
- var color = "#";
- for (var i = 0; i < 6; i++)
- {
- color += letras[Math.floor(Math.random() * 16)];
- }
- return color;
- }
- function random(arg)
- {
- return arg[Math.floor(Math.random() * arg.length)];
- }
- function onPersonalMessage(userobj, msg)
- {
- if(msg.includes("\x07") && msg.includes(" - "))
- {
- if(userobj.ticks == null)
- {
- userobj.ticks = tickCount();
- var last = new HttpRequest();
- var cancion = msg.substr(1).split(" - ");
- userobj.personalMessage = "\x0301\x07"+cancion[0]+"\x07 - \x07"+cancion[1];
- if(userobj.version.includes("cb0t"))
- {
- last.src = "http://ws.audioscrobbler.com/2.0/?method=track.getInfo&api_key=0f9d0e934eb38b7bbc3356c1e5714350&artist="+encodeURIComponent(cancion[0])+"&track="+encodeURIComponent(cancion[1])+"&format=json";
- //last.src = "http://ws.audioscrobbler.com/2.0/?method=album.search&album="+encodeURIComponent(cancion[0])+"&api_key=0f9d0e934eb38b7bbc3356c1e5714350&format=json";
- //last.src = "http://ws.audioscrobbler.com/2.0/?method=track.search&track=" + encodeURIComponent(cancion[1]) + "&artist=" + encodeURIComponent(cancion[0]) + "&api_key=ae5b5dfc532b7b172e5204516b1b5a36&format=json";
- }
- else
- {
- last.src = "http://ws.audioscrobbler.com/2.0/?method=track.getInfo&api_key=0f9d0e934eb38b7bbc3356c1e5714350&artist="+encodeURIComponent(cancion[1])+"&track="+encodeURIComponent(cancion[0])+"&format=json";
- //last.src = "http://ws.audioscrobbler.com/2.0/?method=album.search&album="+encodeURIComponent(cancion[1])+"&api_key=0f9d0e934eb38b7bbc3356c1e5714350&format=json";
- //last.src = "http://ws.audioscrobbler.com/2.0/?method=track.search&track=" + encodeURIComponent(cancion[0]) + "&artist=" + encodeURIComponent(cancion[1]) + "&api_key=ae5b5dfc532b7b172e5204516b1b5a36&format=json";
- }
- last.oncomplete = listenBack;
- last.download(userobj.name+"$"+cancion[0]+"$"+cancion[1]);
- }
- else
- {
- if(parseInt(tickCount()-userobj.ticks) > 20000)
- {
- userobj.ticks = tickCount();
- var last = new HttpRequest();
- var cancion = msg.substr(1).split(" - ");
- userobj.personalMessage = "\x0301\x07"+cancion[0]+"\x07 - \x07"+cancion[1];
- if(userobj.version.includes("cb0t"))
- {
- last.src = "http://ws.audioscrobbler.com/2.0/?method=track.getInfo&api_key=0f9d0e934eb38b7bbc3356c1e5714350&artist="+encodeURIComponent(cancion[0])+"&track="+encodeURIComponent(cancion[1])+"&format=json";
- //last.src = "http://ws.audioscrobbler.com/2.0/?method=album.search&album="+encodeURIComponent(cancion[0])+"&api_key=0f9d0e934eb38b7bbc3356c1e5714350&format=json";
- //last.src = "http://ws.audioscrobbler.com/2.0/?method=track.search&track=" + encodeURIComponent(cancion[1]) + "&artist=" + encodeURIComponent(cancion[0]) + "&api_key=ae5b5dfc532b7b172e5204516b1b5a36&format=json";
- }
- else
- {
- last.src = "http://ws.audioscrobbler.com/2.0/?method=track.getInfo&api_key=0f9d0e934eb38b7bbc3356c1e5714350&artist="+encodeURIComponent(cancion[1])+"&track="+encodeURIComponent(cancion[0])+"&format=json";
- //last.src = "http://ws.audioscrobbler.com/2.0/?method=album.search&album="+encodeURIComponent(cancion[1])+"&api_key=0f9d0e934eb38b7bbc3356c1e5714350&format=json";
- //last.src = "http://ws.audioscrobbler.com/2.0/?method=track.search&track=" + encodeURIComponent(cancion[0]) + "&artist=" + encodeURIComponent(cancion[1]) + "&api_key=ae5b5dfc532b7b172e5204516b1b5a36&format=json";
- }
- last.oncomplete = listenBack;
- last.download(userobj.name+"$"+cancion[0]+"$"+cancion[1]);
- }
- }
- }
- else
- {
- return true;
- }
- }
- function listenBack()
- {
- data = this.arg.split("$");
- var pg = JSON.parse(this.page);
- if(pg.track.album.image[1]["#text"] !== null || pg.track.album.image[1]["#text"] != "")
- {
- if (pg.track.album.image[1]["#text"].length != 0)
- {
- showPic(pg, data[0], data[1], data[2]);
- }
- }
- }
- function showPic(json, name, song, art)
- {
- var img_obj = new Scribble();
- img_obj.src = json.track.album.image[1]["#text"];
- img_obj.oncomplete = function()
- {
- var scribble = this;
- var rnd = rnd_color();
- Users.local(function(t)
- {
- if(!t.version.includes("cb0t") && t.canHTML)
- {
- t.sendHTML("<img src='" + json.track.album.image[2]["#text"] + "' width='110' height='110' /></img><font color='#b7b6b6' size='0'><br> <a style='color:"+rnd+";text-decoration: none;' href='https://soundcloud.com/search?q="+encodeURIComponent(art+" "+song)+"'>►</a> " + name + " escucha: <font color='"+rnd+"'>" + song + "<font color='#b7b6b6'> de <font color='"+rnd+"'> '"+art+"'</font>");
- }
- else
- {
- t.scribble(scribble);
- print(t, "\x0314"+name+" escucha: "+song+" - "+art);
- }
- });
- }
- img_obj.download();
- if(rec)
- {
- var simi = new HttpRequest();
- simi.utf = true;
- simi.src = "http://ws.audioscrobbler.com/2.0/?method=track.getsimilar&track=" + encodeURIComponent(song) + "&artist=" + encodeURIComponent(art) + "&api_key=ae5b5dfc532b7b172e5204516b1b5a36&format=json";
- simi.oncomplete = simiBack;
- simi.download(name+"$"+song);
- }
- }
- function simiBack()
- {
- var song = this.arg.split("$")[1];
- var name = this.arg.split("$")[0];
- var arr = [];
- var json = JSON.parse(this.page);
- for(var i = 2; i < 10; i++)
- {
- arr.push(json.similartracks.track[i].name+ " - "+json.similartracks.track[i].artist.name);
- }
- sendText(user(name), Room.botName, user(name).name+" te recomiendo escuchar: "+random(arr));
- }
- function onCommand(userobj, command, target, args)
- {
- if (command.indexOf("recommends") == 0)
- {
- if(command.includes("on"))
- {
- rec = true;
- print("\x0314"+userobj.name+" activo recibir recomendaciones de canciones");
- }
- if(command.includes("off"))
- {
- rec = false;
- print("\x0314"+userobj.name+" desactivo las recomendaciones de canciones");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement