-
Notifications
You must be signed in to change notification settings - Fork 0
/
bot.js
70 lines (51 loc) · 2.39 KB
/
bot.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
______ ______ ______ __ __ __ ______
/\ == \ /\ __ \ /\__ _\ /\ \/ / /\ \ /\__ _\
\ \ __< \ \ \/\ \ \/_/\ \/ \ \ _"-. \ \ \ \/_/\ \/
\ \_____\ \ \_____\ \ \_\ \ \_\ \_\ \ \_\ \ \_\
\/_____/ \/_____/ \/_/ \/_/\/_/ \/_/ \/_/
# EXTEND THE BOT:
Botkit has many features for building cool and useful bots!
Read all about it here:
-> http://howdy.ai/botkit
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
var env = require('node-env-file');
env(__dirname + '/.env');
var Botkit = require('botkit');
var debug = require('debug')('botkit:main');
var bot_options = {
reply: true,
};
// Use a mongo database if specified, otherwise store in a JSON file local to the app.
// Mongo is automatically configured when deploying to Heroku
if (process.env.MONGO_URI) {
// create a custom db access method
var db = require(__dirname + '/components/database.js')({});
bot_options.storage = db;
} else {
bot_options.json_file_store = __dirname + '/.data/db/'; // store user data in a simple JSON format
}
// Create the Botkit controller, which controls all instances of the bot.
var controller = Botkit.socketbot(bot_options);
// Set up an Express-powered webserver to expose oauth and webhook endpoints
var webserver = require(__dirname + '/components/express_webserver.js')(controller);
// Load in some helpers that make running Botkit on Glitch.com better
require(__dirname + '/components/plugin_glitch.js')(controller);
// Load in a plugin that defines the bot's identity
require(__dirname + '/components/plugin_identity.js')(controller);
// Open the web socket server
controller.openSocketServer(controller.httpserver);
// Start the bot brain in motion!!
controller.startTicking();
var normalizedPath = require("path").join(__dirname, "skills");
require("fs").readdirSync(normalizedPath).forEach(function(file) {
require("./skills/" + file)(controller);
});
logUtil.debug('I AM ONLINE! COME TALK TO ME: http://localhost:' + (process.env.PORT || 3000))
function usage_tip() {
logUtil.debug('~~~~~~~~~~');
logUtil.debug('Botkit Starter Kit');
logUtil.debug('Execute your bot application like this:');
logUtil.debug('PORT=3000 node bot.js');
logUtil.debug('~~~~~~~~~~');
}