Skip to content

Commit

Permalink
feat: add basic functionality
Browse files Browse the repository at this point in the history
Other changes:
– update linter rules
– update recipes data
– add new dependencies
  • Loading branch information
Vyachowski committed Dec 15, 2023
1 parent 6bcfbe8 commit 5a3df70
Show file tree
Hide file tree
Showing 10 changed files with 596 additions and 130 deletions.
16 changes: 0 additions & 16 deletions .eslintrc.cjs

This file was deleted.

23 changes: 23 additions & 0 deletions .eslintrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---

plugins:
- jest

# https://eslint.org/docs/user-guide/configuring#specifying-environments
env:
node: true

extends:
- 'airbnb-base'
- 'plugin:jest/recommended'

parserOptions:
ecmaVersion: latest

rules:
no-console: 0
import/extensions:
- error
- ignorePackages
- js: always
no-underscore-dangle: [2, { "allow": ["__filename", "__dirname"] }]
2 changes: 1 addition & 1 deletion .npmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
node-options=--experimental-vm-modules
node-options=--no-warnings --experimental-vm-modules
28 changes: 13 additions & 15 deletions bin/bot.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,20 @@
#!/usr/bin/env node --env-file=.env
import { Bot } from 'grammy';

const getIntroMessage = (type) => {
const welcomeMessage = "Hi! Let me introduce you 'Bity Smarty' – a special bot that can provide a healthy diet and a grocery list for your next shopping.\n\n";
const featureMessage = 'Here is 5 main features of this bot:\n'
+ '1. Save your time: Only 1 hour for cooking per 3 day!\n'
+ '2. No complex equipment. Just a multi cooker to start!\n'
+ '3. Healthy diet with fancy recipes that looks great\n'
+ '4. Most recipes can be easily stored in the fridge or in the freezer\n'
+ '5. And to make it even tastier – It is completely free :)';
return (type === 'welcome' ? welcomeMessage : featureMessage);
};
import { getIntroMessage, provideMenuWithGroceryList } from '../src/index.js';
import { basicCookBook } from '../src/basicCookBook.js';

const bot = new Bot(process.env.BOT_TOKEN);

bot.onText(/\/start/, (msg) => {
const chatId = msg.chat.id;
const userId = msg.from.id;
bot.command('start', async (ctx) => {
await ctx.reply(getIntroMessage('welcome'));
await ctx.reply(getIntroMessage('features'));
});

bot.command('menu', async (ctx) => {
const menuWithGroceryList = provideMenuWithGroceryList(basicCookBook);

bot.sendMessage(chatId, `ID: ${userId}. Chat ID: ${chatId}\n\n${getIntroMessage('welcome')}`).then(() => true);
await ctx.reply(menuWithGroceryList.menuText);
await ctx.reply(menuWithGroceryList.groceryListText);
});

bot.start().then((r) => r).catch((e) => e);
3 changes: 1 addition & 2 deletions nodemon.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,5 @@
"src/",
".env"
],
"ext": ".js",
"exec": "node --env-file=.env bin/index.js"
"ext": ".js"
}
Loading

0 comments on commit 5a3df70

Please sign in to comment.