-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
51 lines (39 loc) · 1.56 KB
/
index.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
'use strict';
const BootBot = require('bootbot');
const cfg = require('config')
const bot = new BootBot({
accessToken: cfg.get('accessToken'),
verifyToken: cfg.get('verifyToken'),
appSecret: cfg.get('appSecret'),
});
const helpMod = require('./modules/help')
const actions = require('./actions')
const state = require('./state')
const generate = require('./generate')
const player = require('./player')
//console.log(JSON.stringify(generate.generateMapAndPlayer('random')))
bot.module(helpMod);
bot.setGreetingText('Welcome To Dungeon #, where magic and mystery await your exploration.')
bot.setGetStartedButton((payload, chat) => {
chat.say('generating rooms', {typing: true})
chat.say('selecting entry point', {typing: true})
chat.say('You are in a room, check the map from the menu or type show map', {typing: true})
})
let menuButtons = [
{ type: 'postback', title: 'Show Map', payload: 'show_map' },
{ type: 'postback', title: 'Show Inventory', payload: 'show_inventory' },
]
bot.setPersistentMenu(menuButtons)
bot.on('postback:show_map', actions.showMap)
bot.on('postback:show_inventory', actions.showInventory)
bot.on('postback:show_room', actions.showRoom)
bot.on('postback:show_neighbors', actions.showNeighbors)
bot.hear('show map', actions.showMap)
bot.hear('show room', actions.showRoom)
bot.hear('show inventory', actions.showInventory)
bot.hear('show neighbors', actions.showNeighbors)
bot.hear('move up', actions.moveUp)
bot.hear('move down', actions.moveDown)
bot.hear('move left', actions.moveLeft)
bot.hear('move right', actions.moveRight)
bot.start();