Пример #1
0
bot.addListener('message', function (from, to, message) {
  console.log('%s => %s: %s', from, to, message);

  // Identifica si se trata de un mensaje en el canal o si es uno privado
  if ( to.match(/^[#&]/) ) {
    
    // Ejemplo de Comando
    if ( message.match(/@hello/i) ) {
      bot.say(to, irc.colors.wrap('orange', 'Hola ' + from + irc.colors.wrap('light_gray', ' (respuesta al comando @hello)')));
    }
    
    if ( message.match(/@meeting/i) ) {
//      bot.say(to, irc.colors.wrap('orange', 'La proxima reunion es: Viernes 19/10 a las 19 hs, lugar a definir.' + irc.colors.wrap('light_gray', ' (respuesta al comando @meeting)')));

      meetup.getEvents({'group_urlname' : config.meetup.groupname}, function(error,response) {
        if (!error) {
          var d = new Date(response.results[0].time+3600000);
          bot.say(to, 'La proxima reunion es "\u0002' + response.results[0].name + '\u0002", el dia \u0002' +  d.getDate() + '/' + d.getMonth() + '/' + d.getFullYear() + '\u0002 a las \u0002' + d.toTimeString() + '\u0002');
          bot.say(to, '\u0002Van a ir ' + response.results[0].yes_rsvp_count + ' miembros \u0002 y \u0002quedan ' + (response.results[0].rsvp_limit - response.results[0].yes_rsvp_count) + ' lugares libres\u0002');
          bot.say(to, '\u0002' + response.results[0].event_url + '\u0002');
        }
      });

    }
    
  } else { // Mensajes privados
    bot.say(from, from + ' me escribiste: "' + irc.colors.wrap('orange', message) + '" por el canal privado.');
  }
});
Пример #2
0
const radio = async (station) => {
  const url = `https://polling.bbc.co.uk/modules/onairpanel/include/${station}.json`
  let str
  let data
  try {
    const response = await request.get(url)
    try {
      data = JSON.parse(response)
    } catch (e) {
      if (e instanceof SyntaxError) {
        return response
      }
      throw e
    }
    str = [
      'Now:',
      colors.wrap('white', data.nowTitle),
      colors.wrap('light_gray', data.nowInfo ? '(' + data.nowInfo + ')' : null),
      'followed by',
      data.nextTitle,
      moment(data.nextStart).fromNow(),
      moment(data.nextStart).format('(h:mm a)')
    ]

    if (data.state === 'offair') {
      str = [colors.wrap('gray', 'station is off-air')]
    }
  } catch (e) {
    str = ['err', e]
  }
  return str.join(' ')
}
Пример #3
0
 git.revParse(stackConfig.project_dir, deployment.to_revision, function(err, gitRef) {
   var endMsg = sprintf('<%%s> %s:%s to %s:%s %s', deployment.deployment, deployment.stack, git.trimRevision(gitRef), dreadnot.config.env,
                         deployment.region, success ? irc.colors.wrap('light_green', 'OK') : irc.colors.wrap('dark_red', 'FAIL'));
   if(!success) {
     endMsg = sprintf('%s - %s', endMsg, link);
   }
   notify(endMsg);
 });
Пример #4
0
function processComment(msg) {
    var change = msg["change"]
    var owner = lookupAuthor(change["owner"]["email"], change["owner"]["name"])
    var author = lookupAuthor(msg["author"]["email"], msg["author"]["name"])
    var approvals = msg["approvals"] || []
    var approval_str = ""
    var approval_count = 0
    var has_sanity_plusone = false

    for (var i = 0; i < approvals.length; ++i) {
        var reviewtype = ""
        var color = "reset"
        if (approvals[i]["value"] < 0)
            color = "dark_red"
        else if (approvals[i]["value"] > 0)
            color = "dark_green"

        // sanitize for newer gerrit which passes long form names
        if (approvals[i]["type"] == "Code-Review")
            approvals[i]["type"] = "CRVW"
        else if (approvals[i]["type"] == "Sanity-Review")
            approvals[i]["type"] = "SRVW"

        if (approvals[i]["type"] == "SRVW")
            reviewtype += "S"
        else
            reviewtype += "C" // TODO: check explicitly, otherwise doc bot etc may cause issues in the future

        if (approvals[i]["type"] == "SRVW" && author == "Qt Sanity Bot")
            has_sanity_plusone = true

        temp = reviewtype + ": " + approvals[i]["value"]
        approval_str += irc.colors.wrap(color, temp) + " "
        approval_count += 1
    }

    if (approval_count == 1 && has_sanity_plusone == true)
        return // no need to spam sanity +1s

    message = "[" + change["project"] + "/" + change["branch"] + "] "

    if (author == "Qt CI") {
        comment = msg["comment"]
        // special case to detect CI pass/fail;
        // old style includes the same message on every pass, new style includes more
        // information but the first line shall always end with ": SUCCESS" on pass.
        if (comment == "Successful integration\n\nNo regressions!" || comment.search(/^[^\n]+:\sSUCCESS\n/) >= 0)
            message += change["subject"] + " from " + owner + irc.colors.wrap("dark_green", " _PASSED_") + " CI - " + change["url"]
        else
            message += change["subject"] + " from " + owner + irc.colors.wrap("dark_red", " _FAILED_") + " CI - " + change["url"]
    } else {
        message += change["subject"] + " from " + owner + " reviewed by " + author + ": " + approval_str + " - " + change["url"]
    }
    // log.info("comment: " + message)
    emitter.emit("comment", message);
}
Пример #5
0
            (e,r) => {
                if(r) {
                    let _msg = `${who} was last seen ${r.time} using ${r.command} ${r.message}`;

                    client.say(to, irc.colors.wrap('cyan', _msg));
                }
                else {
                    client.say(to, irc.colors.wrap('cyan', '¯\\_(ツ)_/¯'));
                }
            })
Пример #6
0
            }, function (error, response, body) {
                if (!error && response.statusCode == 200) {

                    try {

                        var image = JSON.parse(body).data[0];

                        client.say(to, irc.colors.wrap('light_green', image.title + ': ') + image.link);

                    }
                    catch (e) {client.say(to, irc.colors.wrap('light_red', e))}
                }
            })
Пример #7
0
	request(url_games,function(err, resp, body) {
			
		    if (err){
			    console.log(err);
			    return;
		    }
		    $ = cheerio.load(body);

		    //Set up 3 lists for different game types
		    var games_list = {live:[],past:[],future:[]};

		    //Find all games
		    $('tr').each(function(i,e){
		    	var id=$(e).attr('id');
		    	if(id && (id.indexOf('match-row-')==0)){

		    		var game_id = $(e).attr('id').replace('match-row-','');
		    		
	    			//Find any live games and display using correct colour (if possible)
		    		if($(e).hasClass('live'))
		    			games_list.live.push(
		    				irc.colors.wrap(games[game_id]?games[game_id].colour:'reset',$(e).find('.team-home').text().trim()+' vs '+$(e).find('.team-away').text().trim())+' : '+irc.colors.wrap('light_blue',$(e).find('.score').text().trim())
		    			);
		    		//Find any finished games
		    		else if($(e).hasClass('report'))
		    			games_list.past.push(
		    				$(e).find('.team-home').text().trim()+' vs '+$(e).find('.team-away').text().trim()+' : '+irc.colors.wrap('light_blue',$(e).find('.score').text().trim())
		    			);
		    		//Find any games yet to start
		    		else if($(e).hasClass('fixture'))
		    			games_list.future.push(
		    				$(e).find('.team-home').text().trim()+' vs '+$(e).find('.team-away').text().trim()+' : '+irc.colors.wrap('light_blue',$(e).find('.elapsed-time').text().trim().replace(/ +|\n/g,' '))
		    			);   			
		    	}
		    });

	    	//Print out each game lists
	    	var hasGames=false;
	    	for (t in games_list)
	    	if(games_list[t].length){
	    		hasGames=true;
	    		ircbot.bot.say(ircbot.config.channels[0],' ');
    			ircbot.bot.say(ircbot.config.channels[0],irc.colors.wrap('dark_green',t+':'));
	    		for(var i=0;g=games_list[t][i++];)
	    			ircbot.bot.say(ircbot.config.channels[0],g);
	    	}
	    	if(!hasGames)
	    		ircbot.bot.say(ircbot.config.channels[0],irc.colors.wrap('dark_green','Nothing happening today :('));	
	    	ircbot.bot.say(ircbot.config.channels[0],' ');
	});
Пример #8
0
        function writePost(post) {

            var subreddit = post.permalink ? "r/" + /\/r\/(.*?)\//g.exec(post.permalink)[1] + ' - ' : '';

            if (post.is_self) {
                var resp = irc.colors.wrap('yellow', subreddit + post.title + "\n") + post.selftext;
            }

            else {
                var resp = irc.colors.wrap('yellow', subreddit + post.title + "; ") + irc.colors.wrap('light_cyan', post.url);
            }

            client.say(to, entities.decode(resp));
        }
Пример #9
0
const tv = async (station) => {
  const url = `https://ibl.api.bbci.co.uk/ibl/v1/channels/${station}/broadcasts?per_page=2`
  let data
  let str
  const response = await request.get(url)
  try {
    data = JSON.parse(response)
  } catch (e) {
    if (e instanceof SyntaxError) {
      return response
    }
    throw e
  }

  const now = data.broadcasts.elements[0]
  const next = data.broadcasts.elements[1]

  str = [
    now.episode.live ? 'Live' : 'Now',
    'on',
    data.broadcasts.channel.title + ':',
    colors.wrap(now.episode.master_brand.id === 'bbc_sport' ? 'yellow' : 'white', now.episode.title),
    now.episode.subtitle ? colors.wrap('light_gray', '(' + now.episode.subtitle + ')') : null,
    colors.wrap('gray', ((ep) => {
      return [
        ep.signed ? 'S' : null,
        ep.guidance ? 'G' : null,
        ep.audio_described ? 'AD' : null,
        now.repeat ? 'R' : null
      ].filter(x => x != null).join(' ')
    })(now.episode)),
    'followed by',
    next.repeat ? 'a repeat of' : null,
    next.episode.title,
    moment(next.scheduled_start).fromNow(),
    moment(next.scheduled_start).format('(h:mm a)')
  ].filter(x => x != null)

  if (now.transmission_start && now.scheduled_start !== now.transmission_start) {
    let paperStart = moment(now.scheduled_start)
    let actualStart = moment(now.transmission_start)
    str.push(colors.wrap('light_red',
      'overrunning by ' + moment.duration(actualStart.diff(paperStart)).humanize()
    ))
  }
  if (!data.broadcasts.channel.on_air) str.push(colors.wrap('light_cyan', 'off-air'))

  return str.join(' ')
}
Пример #10
0
    "eval": function(query, text) {

        try {
            var resp = safeEval(query, context.sandbox);

            if (resp!==hide)
                client.say(to,
                    typeof resp == "string" ? context.sandbox.colour("yellow", resp) :
                    typeof resp == "function" ? irc.colors.wrap('light_magenta', resp) :
                    irc.colors.wrap('light_red', resp)
                );
        }
        catch (e) {client.say(to, irc.colors.wrap('light_red', e))}

    },
Пример #11
0
            weather.find({search: query, degreeType: 'C'}, function(err, result) {
                if(err) return client.say(to, irc.colors.wrap('light_red', err));

                if(result.length) {
                    result = result[0];

                    var response = irc.colors.wrap('light_green', result.location.name + ' ' + result.current.temperature + ' degrees, ' + result.current.skytext + ' wind ' + result.current.winddisplay + '\n');

                    result.forecast.forEach(d => response += irc.colors.wrap('light_green', d.date + ' ' + d.day + ' ') + d.skytextday + irc.colors.wrap('yellow', ' high: ' + d.high + ' low: ' + d.low) + '\n')

                    client.say(to, response);
                }


            });
Пример #12
0
                request("http://tripbot.tripsit.me/api/tripsit/getDrug?name=" + query, function (error, response, body) {
                    if (!error && response.statusCode == 200) {

                        var json = JSON.parse(body);

                        if (json.err == null && json.data) {

                            var data = json.data[0];

                            var resp = irc.colors.wrap('light_magenta', data.pretty_name);

                            data.aliases && " (" + data.aliases.join(", ") + ")";

                            resp += "\n";

                            data.properties.dose && (resp += data.properties.dose + "\n");

                            if (data.properties.onset && data.properties.duration && data.properties["after-effects"]) {
                                resp += "onset: " + data.properties.onset +
                                    " duration: " + data.properties.duration +
                                    " after effects: " + data.properties["after-effects"] + "\n";
                            }

                            data.properties.summary && (resp += data.properties.summary + "\n");

                            data.properties.categories && (resp += "categories: " + data.properties.categories.join(" ") + "\n");

                            data.dose_note && (resp += data.dose_note + "\n");

                            client.say(to, resp)
                        }

                    }
                })
Пример #13
0
    yakc: function (bot, msg) {
      var split = msg.split(' ')

      // white black dark_blue dark_green light_red
      // dark_red magenta orange yellow light_green
      // cyan light_cyan light_blue light_magenta
      // gray light_grey reset
      var actions = {
        'placebo': 'gray',
        'directly': 'white',
        'veto': 'dark_red',
        'decent': 'light_green',
        'bad': 'light_red',
        'shunted': 'dark_blue',
        'unshunted': 'light_blue',
        'demoted': 'magenta',
        'featured': 'orange',
        'held': 'yellow'
      }

      for (var i = split.length; i > 0; i--) { /* backwards */
        if (actions[split[i]]) {
          msg = colors.wrap(actions[split[i]], msg)
          break
        }
      }
      bot.notice(bot.config.get('yakc.channel'), msg)
    }
Пример #14
0
        request(getUrl[0], function (error, response, body) {
            if (!error && response.statusCode == 200) {

                try {

                    var title = /<title>(.*?)<\/title>/ig.exec(body);

                    if(title && title[1]) {

                        var data =
                            irc.colors.wrap('light_blue', '>>') +
                            entities.decode(title[1]);

                        if (data.length < 400) {

                            client.say(to, data);

                        }

                    }


                }
                catch (e) {client.say(to, e)}
            }
        })
Пример #15
0
  sendToIRC(message) {
    const author = message.author;
    // Ignore messages sent by the bot itself:
    if (author.id === this.discord.user.id) return;

    const channelName = `#${message.channel.name}`;
    const ircChannel = this.channelMapping[channelName];

    logger.debug('Channel Mapping', channelName, this.channelMapping[channelName]);
    if (ircChannel) {
      const username = author.username;
      const colorIndex = (username.charCodeAt(0) + username.length) % NICK_COLORS.length;
      const coloredUsername = irc.colors.wrap(NICK_COLORS[colorIndex], username);
      let text = this.parseText(message);

      if (this.isCommandMessage(text)) {
        const prelude = `Command sent from Discord by ${username}:`;
        this.ircClient.say(ircChannel, prelude);
        this.ircClient.say(ircChannel, text);
      } else if (message.attachments && message.attachments.length) {
        message.attachments.forEach(a => {
          const urlMessage =
            `${coloredUsername} posted an attachment to ${channelName} on Discord: ${a.url}`;
          logger.debug('Sending attachment URL to IRC', ircChannel, urlMessage);
          this.ircClient.say(ircChannel, urlMessage);
        });
      } else {
        text = `<${coloredUsername}> ${text}`;
        logger.debug('Sending message to IRC', ircChannel, text);
        this.ircClient.say(ircChannel, text);
      }
    }
  }
function tellIRC(pingType, data) {
    var irc_color = pingType === 'alert' ? 'light_red' : 'light_green';
    var notified = false;
    for (var app_name in irc_channels) {
        if (data.application_name.indexOf(app_name) !== -1 &&
                irc_channels[app_name].types.indexOf(pingType) !== -1) {
            notified = true;
            var message = IRC.colors.wrap(irc_color, 'NR_' + pingType.toUpperCase()) + ': ';
            if (pingType === 'deployment') {
                message += '[' + data.application_name + '] ';
            }
            message += (data.long_description || data.description);
            if (data[pingType + '_url']) {
                message += '. ' + data[pingType + '_url'];
            }
            if (config.dev) {
                irc.say(config.dev_channel, irc_channels[app_name].channels.toString() + ' ' + message);
            }
            else {
                irc_channels[app_name].channels.forEach(function(channel) {
                    irc.say(channel, message);
                });
            }

        }
    }
    if (!notified) {
        var message = 'IGNORED: [' + data.application_name + '] ' + (data.long_description || data.description);
        console.log(message);
        if (config.log_channel) {
            irc.say(config.log_channel, message);
        }
    }
}
Пример #17
0
    "log": function(query, text) {

        var rgxp = /~log\((.*?)\) (.*)/.exec(text);
        var rgxp2 = /~log (.*)/.exec(text);

        if (rgxp && rgxp[1] && rgxp[2]) {
            var lines = rgxp[1];
            var srch = rgxp[2];

            log.all('SELECT time,user,message from LOG WHERE message like ? ORDER BY id DESC LIMIT ?',
                [`%${srch}%`, lines],
                (e,r) => {
                    r && r.forEach(d => {
                        var resp = c.underline(d.time) + ' <'+d.user+'> '+d.message;
                        client.say(to, resp);
                    })
                })
        }
        else if (rgxp2 && rgxp2[1]) {
            log.get('SELECT time,user,message from LOG WHERE message like ? ORDER BY id DESC',
                `%${rgxp2[1]}%`,
                (e,r) => {
                    if(r && r.time) {
                        var resp = c.underline(r.time) + ' <'+r.user+'> '+r.message;
                        client.say(to, resp);
                    }
                })
        }
        else {
            client.say(to, irc.colors.wrap('light_red', 'Syntax: ~log search term OR ~log(qty) search term'));
        }

    },
Пример #18
0
            google(query, function (err, res){
                if(err) return client.say(to, irc.colors.wrap('light_red', err));

                res.links.filter(d => d.link).forEach(d => {
                    client.say(to, irc.colors.wrap('light_blue','▶ ') + irc.colors.wrap('light_cyan', d.link) + ' ' + irc.colors.wrap('yellow', d.title))
                })
            })
Пример #19
0
            r.forEach(d => {

                if(Date.create(d.timestamp).isBefore('now')) {
                    db.run('DELETE FROM events WHERE i = ?', d.i);
                    client.say(config.channel, d.user+ " ➜ " + irc.colors.wrap('light_magenta', d.message));
                }

            })
Пример #20
0
        change: function(changeType,filePath,fileCurrentStat,filePreviousStat){
            if(changeType == "create" && (path.dirname(filePath) == config.misc.watchedDirectory)) {
                bot.say(config.bot.channel, irc.colors.wrap('dark_green', 'Download finished: ') + path.basename(filePath));
            }

            else if (path.dirname(filePath) == config.misc.watchedDirectory + "/music_what") {
                if(changeType == "create") {
                    bot.say(config.bot.channel, irc.colors.wrap('dark_green', '[What] Download finished: ') + path.basename(filePath));
                } else if (changeType == "delete") {
                    bot.say(config.bot.channel, irc.colors.wrap('dark_red', 'Trashed: ') + path.basename(filePath));
                }
            }
            
            else if (path.dirname(filePath) == config.misc.watchedDirectory + "/movie_ptp") {
                if(changeType == "create") {
                    bot.say(config.bot.channel, irc.colors.wrap('dark_green', '[PTP] Download finished: ') + path.basename(filePath));
                } else if (changeType == "delete") {
                    bot.say(config.bot.channel, irc.colors.wrap('dark_red', 'Trashed: ') + path.basename(filePath));
                }
            }

            else if (path.dirname(filePath) == config.misc.watchedDirectory + "/tv_auto") {
                if(changeType == "create") {
                    bot.say(config.bot.channel, irc.colors.wrap('dark_green', '[BTN] Download finished: ') + path.basename(filePath));
                } else if (changeType == "delete") {
                    bot.say(config.bot.channel, irc.colors.wrap('dark_red', 'Trashed: ') + path.basename(filePath));
                }
            }
        }
Пример #21
0
            .then(function (res) {
                if (res.alive) {
                    client.say(to, res.output);
                }
                else {
                    client.say(to, irc.colors.wrap('light_red', query + ' is down :('));
                }

            });
Пример #22
0
            (e,r) => {
                var msg = r.filter(d => d['slots'])
                    .sort((a,b) => +b['slots'] - +a['slots'])
                    .filter(d => d.username.indexOf('$') != 0)
                    .map(d => `${d.username}: ${d['slots']}`)
                    .join(' ');

                client.say(config.channel, irc.colors.wrap('orange', 'slots points: ') + msg);
            })
Пример #23
0
var colorize  = function (channel, text, delta) {
  return 'irc' === channel
    ? irc.colors.wrap(color_diff[delta], text)
    : delta
      ? delta == -1
        ? ">" + text + "<"
        : "<" + text + ">"
      : "|" + text + "|";
};
Пример #24
0
app.post('/', function(req, res) {
	var push = JSON.parse(req.body.payload);
	console.log(push);
	var reponame = irc.colors.wrap('dark_red', '[' + push.repository.name + ']');
	//client.say('#combot', push.pusher.name + " pushed commits");
	var plural = '';
	if (push.commits.length > 1) {
		plural = 's';
	}
	var branch = push.ref.replace(/^refs\/heads\//, '');
	if (branch === '') {
		client.say('#combot', reponame + ' ' + push.pusher.name + ' pushed ' + push.commits.length + ' new commit' + plural);
	}
	else {
		client.say('#combot', reponame + ' ' + push.pusher.name + ' pushed ' + push.commits.length + ' new commit' + plural + ' to ' + branch);
		reponame = irc.colors.wrap('dark_red', '[' + push.repository.name + '\\' + branch + ']');
	}
	for (var i in push.commits) {
		//console.log(push.commits[i]);
		var lines = push.commits[i].message.split('\n');
		if (lines.length > 1) {
			for (var line in lines) {
				if (line == lines.length - 1) {
					client.say('#combot', reponame + '     ' + lines[line] + ' - ' + push.commits[i].committer.name);
				}
				else if (line === 0) {
					client.say('#combot', reponame + ' ' + lines[line]);
				}
				else {
					client.say('#combot', reponame + '     ' + lines[line]);
				}
			}
		}
		else {
			client.say('#combot', reponame + ' ' + lines[0] + ' - ' + push.commits[i].committer.name);
		}

	}
	client.say('#combot', reponame + ' http://combot.vendaria.net/git/index.php?repo=' + push.repository.name + '&from=' + push.commits[0].id + '&to=' + push.after);
	res.send();
});
Пример #25
0
            request("http://www.pornhub.com/webmasters/search?search=" + query, function (error, response, body) {
                if (!error && response.statusCode == 200) {

                    var json = JSON.parse(body);

                    if (json.videos && json.videos.length) {
                        var video = json.videos;

                        video = video[(Math.random()*video.length)|0];

                        var resp = irc.colors.wrap('yellow', video.title) + ' ' + irc.colors.wrap('orange', video.url) + '\n';

                        var tags = video.tags.map(d => d.tag_name).join(" ");

                        resp += irc.colors.wrap('light_magenta', tags)

                        client.say(to, resp)
                    }

                }
            })
Пример #26
0
  bot.respond(/^rps throw (r.*|p.*|s.*)/, "rps - Play with AWESOME-O", function (msg) {
    // user throw / bot throw
    var uthrow, bthrow;
      uthrow = msg.match[1][0];
      bthrow = ["r", "p", "s"];
      bthrow = bthrow[Math.floor(Math.random() * 3)];

    if (uthrow === bthrow) {
      irc.colors.wrap("yellow", bot.client.say(msg.channel, "We both threw "
        + names[uthrow] + ".  Try again."));
    }
    else if (comparator[uthrow][bthrow]) {
      bot.client.say(msg.channel, irc.colors.wrap("light_green", "Your " + names[uthrow]
        + " has defeated my " + names[bthrow]
        + ".  Well done!"));
    }
    else {
      bot.client.say(msg.channel, irc.colors.wrap("light_red", "My " + names[bthrow]
        + " has defeated your " + names[uthrow]
        + ".  You lose."));
    }
  });
Пример #27
0
                db.get('select locked from commands where name = ?', name, (e,r) => {

                    if(r && r.locked == "true") {
                        client.say(to, irc.colors.wrap('light_red', '~' + name + ' is locked'))
                    }
                    else {
                        if (r) { // exists
                            db.run("UPDATE commands SET command = ? WHERE name = ?", [command, name]);
                        }
                        else {
                            db.run("INSERT INTO commands(name,command) VALUES (?,?)", [name, command]);
                        }

                        try {
                            var response = typeof safeEval(command, context.sandbox) + ' ~' + name + ' added';

                            client.say(to, irc.colors.wrap('light_magenta', response));
                        }
                        catch (e) {client.say(to, irc.colors.wrap('light_red', e))}
                    }

                });
Пример #28
0
            db.get('SELECT count(name) from commands', (e,r) => {

                try {

                    var wi = config.webInterface;

                    var response = `There are currently ${r['count(name)'] + Object.keys(commands).length} commands. a full list is available here: http://${wi.domain}:${wi.port}/commands`;

                    client.say(to, response);
                }
                catch (e) {client.say(to, irc.colors.wrap('light_red', e))}

            })
Пример #29
0
		    $('tr').each(function(i,e){
		    	var id=$(e).attr('id');
		    	if(id && (id.indexOf('match-row-')==0)){

		    		var game_id = $(e).attr('id').replace('match-row-','');
		    		
	    			//Find any live games and display using correct colour (if possible)
		    		if($(e).hasClass('live'))
		    			games_list.live.push(
		    				irc.colors.wrap(games[game_id]?games[game_id].colour:'reset',$(e).find('.team-home').text().trim()+' vs '+$(e).find('.team-away').text().trim())+' : '+irc.colors.wrap('light_blue',$(e).find('.score').text().trim())
		    			);
		    		//Find any finished games
		    		else if($(e).hasClass('report'))
		    			games_list.past.push(
		    				$(e).find('.team-home').text().trim()+' vs '+$(e).find('.team-away').text().trim()+' : '+irc.colors.wrap('light_blue',$(e).find('.score').text().trim())
		    			);
		    		//Find any games yet to start
		    		else if($(e).hasClass('fixture'))
		    			games_list.future.push(
		    				$(e).find('.team-home').text().trim()+' vs '+$(e).find('.team-away').text().trim()+' : '+irc.colors.wrap('light_blue',$(e).find('.elapsed-time').text().trim().replace(/ +|\n/g,' '))
		    			);   			
		    	}
		    });
Пример #30
0
        db.get('select command from commands where name = ?', name, (e,r) => {
            if(r) {
                try {

                    var loopNuke = loopProtect(r.command);

                    var response, command = safeEval(loopNuke, context.sandbox)

                    if(typeof command == "function"){
                        response = command.call(context.sandbox, input, params, {from, to, text, message});
                    }
                    else {
                        response = command;
                    }

                    if(response!=hide) client.say(to, response);

                }
                catch (e) {client.say(to, irc.colors.wrap('light_red', e))}
            }
        })