// Generated by CoffeeScript 2.2.4
(function() {
  var BotApi, BotPoller, SimpleBot;

  BotPoller = require("./bot-poller");

  BotApi = require("./bot-api");

  // A very simple bot, you can just instantiate it
  // and set onStart, onStop and onUpdates for it.
  SimpleBot = class SimpleBot {
    constructor(token) {
      this.loop = this.loop.bind(this);
      this.botApi = new BotApi(token);
      this.poller = new BotPoller(this.botApi, this.onUpdates, pollingInterval);
    }

    async loop() {
      if (this.onStart instanceof Function) {
        await this.onStart();
      }
      this.poller.startPollUpdates();
      if (process.platform === "win32") {
        require("readline").createInterface({
          "input": process.stdin,
          "output": process.stdout
        }).on("SIGINT", function() {
          return process.emit("SIGINT");
        });
      }
      return process.on("SIGINT", async() => {
        this.poller.stopPollUpdates();
        if (this.onStop instanceof Function) {
          await this.onStop();
        }
        return process.exit();
      });
    }

    onStart() {}

    onStop() {}

    onUpdates(updates) {}

  };

  module.exports = SimpleBot;

}).call(this);
