This repository has been archived by the owner on Oct 31, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
8,065 additions
and
455 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// !songrequest | ||
|
||
module.exports = (function () { | ||
let store = require('../lib/store') | ||
|
||
function run(text, username, mod, sub) { | ||
store.emit('command:songrequest', { | ||
text, | ||
username, | ||
}) | ||
} | ||
|
||
return { type: 'static', run } | ||
})() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
|
||
// implement points here as a Map, send points to dynamic commands and static commands | ||
module.exports = (function () { | ||
const commandSymbol = '!' | ||
|
||
let bot = require('../lib/tapic-bot') | ||
|
||
let commandList = new Map() | ||
|
||
let fs = require('fs') | ||
const commandsPath = './commands/' | ||
fs.readdir(commandsPath, function (err, files) { | ||
if (err) console.error(err) | ||
if (!files) console.error(err) | ||
for (let f = 0; f < files.length; f++) { | ||
const commandName = files[f].split('.')[0] | ||
commandList.set(commandName, require('.' + commandsPath + files[f])) | ||
} | ||
}) | ||
|
||
bot.listen('message', res => { | ||
if (res.action || res.text.substring(0,1) !== commandSymbol) return null | ||
let textArray = res.text.split(' ') | ||
let commandKeyword = textArray.shift().substring(1) | ||
let text = textArray.join(' ') | ||
if (commandList.has(commandKeyword)) { | ||
let command = commandList.get(commandKeyword) //(text, res.from, res.mod, res.sub) | ||
if (command.type === 'dynamic') { | ||
runDynamicCommand(command, text, res.from, res.mod, res.sub) | ||
} | ||
else if (command.type === 'static') { | ||
command.run(text, res.from, res.mod, res.sub) | ||
} | ||
} | ||
}) | ||
|
||
function runDynamicCommand(command, text, username, mod, sub) { | ||
// check permissions | ||
// replace wildcards with the appropriate tokens | ||
// output the string | ||
} | ||
|
||
// dynamicCommand = { | ||
// type: 'dynamic', | ||
// requireMod: true, | ||
// requireSub: false, | ||
// requirePoints: 0, | ||
// action: '', | ||
// } | ||
})() |
Oops, something went wrong.