diff --git a/.DS_Store b/.DS_Store index 99e6f00..22e958e 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/modules/.DS_Store b/modules/.DS_Store index 2892f09..d00d811 100644 Binary files a/modules/.DS_Store and b/modules/.DS_Store differ diff --git a/modules/wordbyword/index.js b/modules/wordbyword/index.js new file mode 100644 index 0000000..46a2ebe --- /dev/null +++ b/modules/wordbyword/index.js @@ -0,0 +1,38 @@ +const printf = require('printf') +const isStringInt = require('is-string-int'); + +module.exports = function (bot, api) { + bot.currentWBW = ""; + api.registerCommand('wbw', async (args, message) => { + if (args.length == 1) { + return api.respond(message, bot.currentWBW ? printf(api.strings.CURRENT_STORY, bot.currentWBW) : printf(api.strings.NO_STORY)); + } + if (args.length > 2) { + return api.respond(message, printf(api.strings.TOO_MANY_ARGUMENTS)); + } else { + if (isStringInt(args[1])) { + let story = await api.db.get('select * from WBWStories where story_id=?', parseInt(args[1])) + if(!story) { + return api.respond(message, api.strings.WBW_INVALID_ID) + } else { + return api.respond(message, story.story_text) + } + } else { + let lastUser = await api.db.get('select value from BotState where key="last_wbw"'); + console.log(lastUser.value, message.author.id); + if (message.author.id == lastUser.value) { + return api.respond(message, printf(api.strings.WBW_LAST_USER)) + } else { + bot.currentWBW += args[1] + ' '; + api.respond(message, printf(api.strings.WBW_NEW_WORD, bot.currentWBW)) + await api.db.run('update BotState set value=? where key="last_wbw"', message.author.id); + } + } + } + }) + api.registerCommand('newwbw', async (args, message) => { + await api.db.run('insert into WBWStories (story_text) values(?)', bot.currentWBW); + bot.currentWBW = ''; + api.respond(message, printf(api.strings.WBW_RESET)) + }) +} \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 406b8cd..d24b5b3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5,6 +5,7 @@ "requires": true, "packages": { "": { + "name": "tardis-bot", "version": "1.0.0", "license": "ISC", "dependencies": { @@ -12,6 +13,7 @@ "discord.js": "^12.5.3", "dotenv": "^8.2.0", "google-tts-api": "^2.0.2", + "is-string-int": "^1.0.1", "microsoft-cognitiveservices-speech-sdk": "^1.16.0", "node-fetch": "^2.6.1", "node-google-translate-skidz": "^1.1.2", @@ -1129,6 +1131,11 @@ "resolved": "https://registry.npmjs.org/is-stream-ended/-/is-stream-ended-0.1.4.tgz", "integrity": "sha512-xj0XPvmr7bQFTvirqnFr50o0hQIh6ZItDqloxt5aJrR4NQsYeSsyFQERYGCAzfindAcnKjINnwEEgLx4IqVzQw==" }, + "node_modules/is-string-int": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/is-string-int/-/is-string-int-1.0.1.tgz", + "integrity": "sha1-qK1EXObyqD0JdTwx3k26TXuKGSw=" + }, "node_modules/is-typedarray": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz", @@ -1895,7 +1902,6 @@ "hasInstallScript": true, "dependencies": { "node-addon-api": "^3.0.0", - "node-gyp": "3.x", "node-pre-gyp": "^0.11.0" }, "optionalDependencies": { @@ -3077,6 +3083,11 @@ "resolved": "https://registry.npmjs.org/is-stream-ended/-/is-stream-ended-0.1.4.tgz", "integrity": "sha512-xj0XPvmr7bQFTvirqnFr50o0hQIh6ZItDqloxt5aJrR4NQsYeSsyFQERYGCAzfindAcnKjINnwEEgLx4IqVzQw==" }, + "is-string-int": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/is-string-int/-/is-string-int-1.0.1.tgz", + "integrity": "sha1-qK1EXObyqD0JdTwx3k26TXuKGSw=" + }, "is-typedarray": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz", diff --git a/package.json b/package.json index fa6b072..eb9123c 100644 --- a/package.json +++ b/package.json @@ -14,6 +14,7 @@ "discord.js": "^12.5.3", "dotenv": "^8.2.0", "google-tts-api": "^2.0.2", + "is-string-int": "^1.0.1", "microsoft-cognitiveservices-speech-sdk": "^1.16.0", "node-fetch": "^2.6.1", "node-google-translate-skidz": "^1.1.2", diff --git a/strings/en.json b/strings/en.json index 9df8b39..2e66d54 100644 --- a/strings/en.json +++ b/strings/en.json @@ -6,5 +6,11 @@ "USER_VOICE_CHANGED": "Your new voice is %s from %s", "INVALID_ENGINE": "%s is not a valid engine name.", "INVALID_VOICE": "invalid voice name. Using default voice %s for %s instead.", - "TOO_MANY_ARGUMENTS": "too many arguments for command." + "TOO_MANY_ARGUMENTS": "too many arguments for command.", + "CURRENT_STORY": "Here's the current story: %s", + "NO_STORY": "No story in progress at the moment.", + "WBW_LAST_USER": "You were the last user to add a word to the story. Wait for someone else to add another one.", + "WBW_NEW_WORD": "Added to story. It now reads: %s", + "WBW_RESET": "The story has been reset.", + "WBW_INVALID_ID": "No story with that ID." } \ No newline at end of file diff --git a/t.js b/t.js new file mode 100644 index 0000000..9577cdf --- /dev/null +++ b/t.js @@ -0,0 +1,9 @@ +const t=require('node-google-translate-skidz') + +t({ +text: 'this is a test of the meow', +'source': 'en', +target: 'ta' +}, (res) => { +console.log(res); +}); \ No newline at end of file diff --git a/tts/.DS_Store b/tts/.DS_Store index 3668c01..1d74779 100644 Binary files a/tts/.DS_Store and b/tts/.DS_Store differ