Ignore 's words in /expand. Return letter if nothing starting with it is found.
This commit is contained in:
parent
8f16112b2e
commit
382579ba3f
|
@ -4,6 +4,8 @@ function expand(words, text) {
|
||||||
return letters.map((letter) => {
|
return letters.map((letter) => {
|
||||||
|
|
||||||
const wordsWithLetter = words.filter(i => i.match(RegExp(`^${letter}`, "i")));
|
const wordsWithLetter = words.filter(i => i.match(RegExp(`^${letter}`, "i")));
|
||||||
|
if (! wordsWithLetter.length)
|
||||||
|
return letter;
|
||||||
const word = wordsWithLetter[Math.floor(Math.random() * wordsWithLetter.length)];
|
const word = wordsWithLetter[Math.floor(Math.random() * wordsWithLetter.length)];
|
||||||
return word;
|
return word;
|
||||||
|
|
||||||
|
@ -14,6 +16,7 @@ function expand(words, text) {
|
||||||
|
|
||||||
module.exports = (words = []) => (ctx) => {
|
module.exports = (words = []) => (ctx) => {
|
||||||
|
|
||||||
|
words = words.filter(i => ! i.match(/'s$/));
|
||||||
const message = ctx.message.text.replace(/^[^ ]+/, "");
|
const message = ctx.message.text.replace(/^[^ ]+/, "");
|
||||||
if (message) {
|
if (message) {
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue