Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- exports.commands = {
- mb: 'musicbox',
- musicbox: function (target, room, user) {
- if (!this.canBroadcast()) return;
- var parts = target.split(',');
- if (!target) return this.sendReply("/musicbox link, link, link - parses it to be in a music box");
- var parsedParts = parts.map(parse);
- Promise.all(parsedParts).then(function(parts) {
- var str = parts.join('');
- this.sendReply('str is ' + str);
- }.bind(this))
- }
- };
- function parse (link) {
- return new Promise(function(resolve, reject) {
- request(link, function(err, res, body) {
- if (!err && res.statusCode == 200) {
- var $ = cheerio.load(body);
- var title = $("title").text();
- var str = '<a href="' + link + '"><button title="' + title + '">' + title + '</a></button><br />'; //parse it now
- resolve(str);
- } else {
- reject(str);
- }
- });
- });
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement