Skip to content

Commit

Permalink
Adding gravemind library for system commands, added bits to package j…
Browse files Browse the repository at this point in the history
…son so I can access releasenotes at runtime, and hooked into bot. Resolves #11
  • Loading branch information
jake@chrx committed Mar 21, 2018
1 parent fc3de67 commit f7328e6
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 3 deletions.
6 changes: 5 additions & 1 deletion bot.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//All the custom stuff, separated by converns
const dungeonary = require('./dungeonary')
const discordlib = require('./discordlib')
const gravemind = require('./gravemind')
//TODO: Map all the libs at boot, so there isn't a loop to find each op. Way better.
//var knownOps = []; for ( func in req('./lib') ){ knownOps[func] = lib[func] }

Expand All @@ -22,7 +23,7 @@ client.on('ready', () => {
if (process.env.NODE_ENV) {
console.log(`${process.env.NODE_ENV} mode activated!`)
}
console.log(`I'm rolling initiative as ${client.user.tag}!`)
console.log(`Tavernbot v${process.env.npm_package_version} has logged in as ${client.user.tag}!`)
client.user.setPresence({
"status": "online",
"game": { "name": gameStatus }
Expand All @@ -47,6 +48,9 @@ client.on('message', msg => {
} else if (cmd in discordlib) {
console.log(execTime + 'running discordlib.' + cmd + '(' + input + ') for ' + msg.author.username)
msg.reply(discordlib[cmd](input, msg, client))
} else if (cmd in gravemind) {
console.log(execTime + 'running gravemind.' + cmd + '(' + input + ') for ' + msg.author.username)
msg.reply(gravemind[cmd](input, msg, client))
} else {
console.log(execTime + ' WARN: failed to run ' + cmd + '(' + input + ') for ' + msg.author.username)
}
Expand Down
14 changes: 14 additions & 0 deletions gravemind/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// List all local components here
const components = [
'./sysinfo'
]

// Go through each chunk of the library and set each exported
// function as its own export of this module
for (sublib of components) {
let lib = require(sublib)
for (operation in lib) {
exports[operation] = lib[operation]
}
console.log(sublib + " loaded!")
}
15 changes: 15 additions & 0 deletions gravemind/sysinfo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Simple version, bug link, and release notes output
exports.version = function() {
let response = `I am Tavernbot v**${process.env.npm_package_version}**!\n\n`
response += `**Release notes**\n${process.env.npm_package_releasenotes}\n\n`
response += `**Bug or feature request? Drop it here!**\n${process.env.npm_package_bugs_url}\n`
return response
}

// Util calls for the github issues link
exports.bug = function() {
return `if you found a bug, please report it here: ${process.env.npm_package_bugs_url}`
}
exports.feedback = exports.request = exports.feature = function() {
return `got a feature idea or some feedback? Awesome! Let me know here: ${process.env.npm_package_bugs_url}`
}
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
{
"name": "tavernbot",
"version": "0.1.3",
"releasenotes": "This is a test release, and is currently under heavy development. Feel that? Change. It's in the air.",
"description": "A Dungeons and Dragons GM bot for discord, written in Node. This bot supports common tabletop RPG functionality, common Discord operations, and more",
"main": "bot.js",
"scripts": {
"bot": "node bot.js",
"start": "node bot.js",
"devbot": "nodemon bot.js",
"test": "node test.js",
"build": "echo Placeholder text for smushing libs into an rpgapp.js for web page usage"
Expand Down Expand Up @@ -45,4 +46,4 @@
"devDependencies": {
"nodemon": "^1.17.2"
}
}
}

0 comments on commit f7328e6

Please # to comment.