From dd618bf78516428f369d7c923046a4fb6b37f155 Mon Sep 17 00:00:00 2001 From: guilevi Date: Fri, 5 Nov 2021 02:15:50 +0100 Subject: [PATCH] Add word by word --- .DS_Store | Bin 10244 -> 12292 bytes modules/.DS_Store | Bin 8196 -> 10244 bytes modules/wordbyword/index.js | 38 ++++++++++++++++++++++++++++++++++++ package-lock.json | 13 +++++++++++- package.json | 1 + strings/en.json | 8 +++++++- t.js | 9 +++++++++ tts/.DS_Store | Bin 10244 -> 10244 bytes 8 files changed, 67 insertions(+), 2 deletions(-) create mode 100644 modules/wordbyword/index.js create mode 100644 t.js diff --git a/.DS_Store b/.DS_Store index 99e6f00b1a9c97141dd69e03d5fd9dd3e67ed255..22e958e497d1665f51c2269e82ce1799e2690311 100644 GIT binary patch literal 12292 zcmeHNdu$X%82`R)OLy%-7bs9ppa&IEEO>=lK}D|*6hv&(2Q3e2?`~JRVQ;tG?p@Vd zt>`~Wi1=2bCh8w*e8d(N^(l#?G z%jr|6C*x)^W5!**$uv8SD|E`MbdqV?G}~>*V9jjqb@j_!RyLuicZ*}E-4@^YIeOHXfDwWg^zX{S=UbihsG}r$iPdL?LTah%D5C7#`IH1N(cD7K$m(0NEZ4^N z|HOf*jj^{kg<2s1_=sv_QIS^Y)juCrKr37X{g8%X*b8^Ueee{#4sXCm@CAGeN8ndP zoQ5;88kb-c8}S@GA1}ss?8GkY#_iaT2~47fDYS7HrqRJG@hTj}Yj8L2!M%7R?!%jK zKi-Y^;Jx@DK8%mxqxcv;gU{k~_&mObuj8Be79PO2@qPRRzsB$IN6|rvtzZ^53X!`a zA75oI>B;>h%e@a&Zh`Np@1*G;6dDabOw>r(t*v4UfV^v9UaaDj*P15N(*A_j;DG;W zqwJvt{mFKwEz`DkPzf7a(T$lHa=eWR&*nDfhu+34SIR5OFX^P6*XhRHjME%XZ)K@2 z+cp#8-fNzOOyB(=1PBBO1PJ6Iz+OKQicH2lIVvQ}V)@L3V3L^-JkUM)0X#3_$(Scc zh2&MK4zE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.DS_Store b/modules/.DS_Store index 2892f09e3c4a713d42db9cad30cc52f3b740bf91..d00d811f7f56642ddc492f433ee911ec64fcb123 100644 GIT binary patch delta 549 zcmZp1XbF&DU|?W$DortDU{C-uIe-{M3-C-V6q~50$SAilU^hRb+~h(*vB@f8HzxlQ zP-J460pbef=DWBg<>V)Uv^6h&;oIXeIbTp>a;zW^8-%+#U(lVgJ}2EUI5|JJ0H_QI z*q;Ll4hCn2M20+u5+F=u$YIDvHcB+}!qg-DhaIu2OMzR7PhCL<+|J28;#`}T3&}Am zF&zdP$;OZiwmKbXZ7Q<0hd9)nCqEZfU;#6@MU*D@i?ePv5;0(8VqP`*fT+~uI#C|h zEsNJJxIVdGR1?mUoqS7_52SYTVNvnTEMgLjjDIIj6c-UeHhjefpfWfY zC<2Y*Z5tah*aew^?gIh^ZXn?bii3@X-F7nGPBE6BqJ;cm_sbZ6Y`C(O^t#K15)UPOlFRo6oM z$@L-%5XNE=B}RtL$3#pR85t%wib;zgn;5igo?<)SVaLgTL}i3h;1(eXOYs+E7zQWj z=N15600NsE#f%vlZ%v*kE;9L~I1k6fC6koi@dAwi3INSU7=kP@SyG}+kQrit1UHa& k1^Ikq;dkcA{3?MQjF9jEI-h6i?cW&i*H 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 3668c01861dd70110973727df8328e5d20cae955..1d74779f8266dcca1197d81de212404bf8bf9641 100644 GIT binary patch literal 10244 zcmeHM&1(}u6rWAgWMi#H@$2S-2r5DIQDQ<7VoX5~iWpJxgLGp;8oJpH*~DODB;G{5 zTfOLCARYxh*@N_=2f^Y&^w|HwgT9&BY-T6BHV4Jf&cMvu-Fa^&@Au=)?t4K9N!eB@ zhLC~~lA&W6-VTFH!}GWgHJ|n57)S~15o(}vv2E6ino%6m77qjh0s(=5KtLcM5Eusp z;GK<|JVm7#1p)#Afq;zwJ|7h5SY|BQqmmpQFpv}gq#quW2G@`W5F5pk8B6x4B&M(? z%^oDnRI*YGiJHT_g4IE0EZL)ynj?vtBgxuXvN9Bj><)GcQAbjSN-+uq1Omed;M_fc zjw2NN zNynoRWhNEvc0=;sLnmf06&AIcZakuHNY+t+ra8AB^FC>nSpK$At5ZFt%+J@1T+XUl z$Vb2Ko{jHXIX$dX+EAyy!0r>p+c~hklW*vnp;zEJ{_RtMdj&NCbrtEzL>kDZqk{6G z&%m0+fDACn)3OT(7uDv1&B0&b1MgG_@9T6<#v@81I-nytgX!3RICkpXeC_U1=U(^z zQ|u}D)F)&oy|>3@xbkq;NsaW{TazW})5ljY*LDz+Jl3rl1G+ZWb`nQkAs*{;6#9We z6KJb3Wv|u$O&UZ|JPDDLh^GEX+cQd#CvDGR-geMQlrscQx z5$2&gAZsIC7s_1M2PI2?PWJ0)Z`ozy$SD!S(++@Bja|1Qxx?CPR1$O0A?6@yHUFRg88GIx cGA`fdK9@!QKXOr-7BO)>OyvJilwtFo-#Z+OQvd(} delta 463 zcmZn(XbG6$FDk>pz`)4BAi%&-%#hEJmsDO{kd(8ra2or>2Hwr=94s7+GMjgZure|+ z^-ta}DyJh>R=4Io?_o!vHg*O*hH{2Ph7yR@-24=mq@4UDpbQ5@)nraFS58)-iYkUu zhN8)dViP%x4J~vOj7-cX8%a4bvQEwul-%qmCcwzV_+oN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