{"size": 3609, "ext": "js", "max_stars_repo_path": "lib/plugins/_system.js", "max_stars_repo_name": "epochwolf/pious-plum", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "lib/plugins/_system.js", "max_issues_repo_name": "epochwolf/pious-plum", "max_issues_repo_issues_event_min_datetime": "2015-01-15T18:12:29.000Z", "max_issues_repo_issues_event_max_datetime": "2015-07-06T03:37:29.000Z", "max_forks_repo_path": "lib/plugins/_system.js", "max_forks_repo_name": "epochwolf/pious-plum", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": 1, "max_forks_count": null, "avg_line_length": 32.5135135135, "max_line_length": 185, "alphanum_fraction": 0.5594347465}
// Generated by CoffeeScript 1.6.2
(function() {
  var Plugin, le_admin, util,
    __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };

  util = require("util");

  le_admin = "epochwolf";

  Plugin = (function() {
    function Plugin(bot, config) {
      this.bot = bot;
      this.config = config;
      this.pluginCmd = __bind(this.pluginCmd, this);
      this.quitCmd = __bind(this.quitCmd, this);
      this.partCmd = __bind(this.partCmd, this);
      this.joinCmd = __bind(this.joinCmd, this);
      this.aboutCmd = __bind(this.aboutCmd, this);
      this.error_handler = __bind(this.error_handler, this);
      this.__name = "system";
      this.__author = "epochwolf";
      this.__version = "v0.0.1";
      this.__listeners = {
        error: [this.error_handler]
      };
      this.__commands = {
        about: this.aboutCmd
      };
      this.__admin_commands = {
        join: this.joinCmd,
        part: this.partCmd,
        quit: this.quitCmd,
        plugin: this.pluginCmd
      };
      this.__autoload = true;
      this.__prevent_unload = true;
    }

    Plugin.prototype.error_handler = function(message) {
      return console.log("error: " + (util.inspect(message)));
    };

    Plugin.prototype.aboutCmd = function(channel, who, args) {
      return this.bot.say(channel, "I am a Pious Plum IRC Bot " + this.config.version + " written in Node.JS https://github.com/epochwolf/pious-plum");
    };

    Plugin.prototype.joinCmd = function(channel, who, args) {
      if (args[0]) {
        this.bot.say(channel, "Okay.");
        return this.bot.join(args[0]);
      } else {
        return this.bot.action(channel, "yawns");
      }
    };

    Plugin.prototype.partCmd = function(channel, who, args) {
      this.bot.say(channel, "Okay.");
      return this.bot.part(args[0] || channel);
    };

    Plugin.prototype.quitCmd = function(channel, who, args) {
      this.bot.say(channel, "Okay.");
      return this.bot.disconnect("" + who + " asked me to quit", process.exit);
    };

    Plugin.prototype.pluginCmd = function(channel, who, args) {
      var name, plugin, plugins, subcmd;

      subcmd = args[0], name = args[1];
      if (subcmd === "list") {
        plugins = (function() {
          var _ref, _results;

          _ref = this.bot.plugins.plugins;
          _results = [];
          for (name in _ref) {
            plugin = _ref[name];
            _results.push(plugin.__loaded ? name : "" + name + " (not loaded)");
          }
          return _results;
        }).call(this);
        return this.bot.say(channel, "Plugins: " + (plugins.sort().join(", ")));
      } else {
        plugin = this.bot.plugins.get(name);
        if (plugin) {
          switch (subcmd) {
            case "load":
              this.bot.plugins.load(name);
              return this.bot.say(channel, "Plugin \"" + name + "\" loaded.");
            case "unload":
              this.bot.plugins.unload(name);
              return this.bot.say(channel, "Plugin \"" + name + "\" unloaded.");
            case "info":
              return this.bot.say(channel, "" + name + " provides: " + (Object.keys(plugin.__commands).join(", ")) + " and listens to: " + (Object.keys(plugin.__listeners).join(", ")));
            default:
              return this.bot.say(channel, "Available sub commands: load [plugin], unload [plugin], info [plugin], list");
          }
        } else {
          return this.bot.say(channel, "No plugin named \"" + name + "\"");
        }
      }
    };

    return Plugin;

  })();

  module.exports = Plugin;

}).call(this);
