From 06c872d4945cfdbfb2175ce8350038cf2e082610 Mon Sep 17 00:00:00 2001 From: Lluis Date: Wed, 14 Feb 2024 00:35:14 +0100 Subject: [PATCH] change commands for birhtday to make it easy to use --- README.md | 15 +++++++++++++++ lib/inputParser.js | 6 +++++- lib/messenger.js | 4 ++-- 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 7b6ba87..353ced6 100644 --- a/README.md +++ b/README.md @@ -57,3 +57,18 @@ Take a screenshot of the current stream and send it to the chat. !foto //result: https://external.url/images/cclj35.png ``` + +## Birthday +Save your own birthdate and get other users birthdays + +### commands + +```javascript +!micumple 03-08 +//result: @myuser cumple el dia 3 de Setiembre +``` + +```javascript +!cumple @otheruser +//result: @otheruser cumple el dia 3 de Setiembre +``` diff --git a/lib/inputParser.js b/lib/inputParser.js index cc876ab..c0dc9f8 100644 --- a/lib/inputParser.js +++ b/lib/inputParser.js @@ -27,7 +27,11 @@ class InputParser { return text.toLowerCase().startsWith('!f5') } - isAskingForBirthday (text) { + isAskingForGetBirthday (text) { + return text.toLowerCase().startsWith('!cuandocumple') + } + + isAskingForAddBirthday (text) { return text.toLowerCase().startsWith('!cumple') } } diff --git a/lib/messenger.js b/lib/messenger.js index fdc1305..304b719 100644 --- a/lib/messenger.js +++ b/lib/messenger.js @@ -83,11 +83,11 @@ class Messenger { if (textSplit.length > 0 && inputParser.isAskingForF5(textSplit[0]) && (context['mod'] || context['vip'])) return handlers.stream.refreshPage(target, this.bot, this.notifier.bot) - if (textSplit.length === 2 && inputParser.isAskingForBirthday(textSplit[0]) && textSplit[1].includes('-')) { + if (textSplit.length === 2 && inputParser.isAskingForAddBirthday(textSplit[0]) && textSplit[1].includes('-')) { return handlers.birthday.addBirthday(target, textSplit.slice(1).join(' '), this.bot, context['display-name']) } - if (textSplit.length === 2 && inputParser.isAskingForBirthday(textSplit[0]) && !textSplit[1].includes('-')) { + if (textSplit.length === 2 && inputParser.isAskingForGetBirthday(textSplit[0]) && !textSplit[1].includes('-')) { return handlers.birthday.getBirthday(target, textSplit[1], this.bot) } }