var DbProvider = require('./DbProvider'); var OracleDbProvider = Class(DbProvider, { init: function (config, logger) { this.wait = require('wait.for'); this.oracle = require('oracle'); this._super(config, logger); }, _connect: function (name) { var conf = this.config.get(name); if(!conf) throw new Error('Settings for `'+name+'` is not defined'); try { var connection = this.wait.for(this.oracle.connect, conf); this.logger.info("Connected to OracleDB `%s`.", name); return connection; } catch (err) { this.logger.error("FATAL Failed while connecting to OracleDB: %s.", String(err)); throw err; } } }); module.exports = OracleDbProvider;
var DefineClass = require('define-class'), PluginAbstract = require('cb-framework').pluginAbstract, CleanerPlugin = DefineClass(PluginAbstract, { init: function() { this.commands = { cleanup: { access: ['host', 'mod'], handler: this.cleanup, description: '', params: /(\d+)/ } }; this._super(); }, cleanup: function(fromUser, quantity) { var count, backgroundColor = this.library.colors.blue; if (!quantity || !Number.parseInt(quantity, 10)) { quantity = 30; } for (count = 1; count <= quantity; count++) { this.api.sendNotice("Cleaning up chat...", '', backgroundColor); } this.api.sendNotice("Chat cleaned up.", '', backgroundColor); } }); module.exports = CleanerPlugin;
TimerPlugin = DefineClass(PluginAbstract, { init: function() { this.startTime = 0; this.timeAdded = 0; this.commands = { starttimer: { access: ['host', 'mod'], handler: this.startTimer, description: 'Start a new timer. Expects the first argument to be the number of minutes', params: /(\d+)/ }, stoptimer: { access: ['host', 'mod'], handler: this.stopTimer }, addtime: { access: ['host', 'mod'], handler: this.addTime, params: /(\d+)/ }, timeleft: { access: ['host', 'mod'], handler: this.timeLeft } }; this._super(); }, startTimer: function(fromUser, noOfMinutes) { // There is no timer already running if (startTime == 0 && timeAdded == 0) { // Check if a valid option was sent with /starttimer if (t >= 0 && t.toString().indexOf(".") == -1) { timerDuration = t; // Notice of timer start if (mod != null) { this.api.sendNotice(fromUser.name + ' has set a timer for ' + timerDuration + ' minutes!', '', purple); } // Local variable to convert noticeTime (minutes) to milliseconds var millis = timerDuration * 60000; var fiveMinutes = millis - 300000; var oneMinute = millis - 60000; // Actual timer this.api.setTimeout(this.calculateTime.bind(this), millis); // Five minutes remaining announcement if (fiveMinutes > 0) { cb.setTimeout(fiveMinuteWarning, fiveMinutes); } // One minute remaining announcement this.api.setTimeout(oneMinuteWarning, oneMinute); // Set the start time startTime = new Date(); } else if (t != null) { this.api.sendNotice(t + ' is not a valid option for /starttimer.\nType /ubhelp starttimer to see how to use /starttimer.', mod, "#fee"); } else if (t == null) { this.api.sendNotice('You did not enter a valid option for /starttimer.\nType /ubhelp starttimer to see how to use /starttimer.', mod, "#fee"); } } else if (startTime != 0 && timeAdded != 0 && mod == null) { // There is a timer running and time has been added this.timeAdded = 0; this.timerDuration = t; var millis = timerDuration * 60000; var fiveMinutes = millis - 300000; var oneMinute = millis - 60000; cb.setTimeout(timer, millis); if (fiveMinutes > 0) { this.api.setTimeout(fiveMinuteWarning, fiveMinutes); } this.api.setTimeout(oneMinuteWarning, oneMinute); } else if (startTime != 0 && timeAdded == 0 || startTime != 0 && timeAdded != 0 && mod != null) { // There is a timer running and someone tried to start a new timer this.api.sendNotice('There is a timer running already.', fromUser.name, "#fee"); } }, stopTimer: function() { }, addTime: function(fromUser, noOfMinutes) { }, timeLeft: function(fromUser) { }, calculateTime: function() { } });
var Class = require('define-class'); var _ = require('lodash'); var Definition = require('../model/Definition'); var Profile = require('../model/Profile'); var ProfileBuilder = Class({ build: function(data) { var profile = new Profile(); _.each(data, function (config, name) { profile.add(new Definition(name, config)); }); return profile; } }); module.exports = ProfileBuilder;