Add word by word

master
guilevi 2021-11-05 02:15:50 +01:00
parent 78e2c77bc7
commit dd618bf785
8 changed files with 67 additions and 2 deletions

BIN
.DS_Store vendored

Binary file not shown.

BIN
modules/.DS_Store vendored

Binary file not shown.

View File

@ -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))
})
}

13
package-lock.json generated
View File

@ -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",

View File

@ -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",

View File

@ -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."
}

9
t.js 100644
View File

@ -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);
});

BIN
tts/.DS_Store vendored

Binary file not shown.