Bot for searching cocktails by their names, ingredients and tags.
NOTE! Only Russian language is supported.
The bot suggest you to choose search method:
- by name ( e.g
ΠΌΠ°ΡΠ³Π°ΡΠΈΡΠ°
):
Bot will search cocktail by its name ( levenshtein distance is used for fuzzy search ) - by ingredients ( e.g.
Π΄ΠΆΠΈΠ½, ΡΠΎΠ΄ΠΎΠ²Π°Ρ
):
Bot will search cocktail by ingredients, separated by comma - by tags ( e.g.
ΡΠΎΡΡ, ΡΠΈΡΡΡΡΠΎΠ²ΡΠ΅
):
Bot will search cocktail by tags, separated by comma
One-to-many relationship ( cocktail - ingredient, cocktail - tag ).
There are 3 tables:
Example:
id | name | ingredient_names | tag_names | recipe |
---|---|---|---|---|
1 | Π΄Π°ΠΉΠΊΠΈΡΠΈ | Π±Π΅Π»ΡΠΉ ΡΠΎΠΌ,ΡΠ°Ρ Π°ΡΠ½ΡΠΉ ΡΠΈΡΠΎΠΏ,Π»Π°ΠΉΠΌΠΎΠ²ΡΠΉ ΡΠΎΠΊ,Π»Π΅Π΄ Π² ΠΊΡΠ±ΠΈΠΊΠ°Ρ | ΠΊΡΠ΅ΠΏΠΊΠΈΠ΅/ΠΊΠΈΡΠ»ΡΠ΅/ΡΠΈΡΡΡΡΠΎΠ²ΡΠ΅/Π½Π° ΡΠΎΠΌΠ΅/ΠΊΠ»Π°ΡΡΠΈΠΊΠ° | 1. ΠΠ°Π»Π΅ΠΉ Π² ΡΠ΅ΠΉΠΊΠ΅Ρ Π»Π°ΠΉΠΌΠΎΠ²ΡΠΉ ΡΠΎΠΊ 30 ΠΌΠ», ΡΠ°Ρ Π°ΡΠ½ΡΠΉ ΡΠΈΡΠΎΠΏ 15 ΠΌΠ» ΠΈ Π±Π΅Π»ΡΠΉ ΡΠΎΠΌ 60 ΠΌΠ» 2. ΠΠ°ΠΏΠΎΠ»Π½ΠΈ ΡΠ΅ΠΉΠΊΠ΅Ρ ΠΊΡΠ±ΠΈΠΊΠ°ΠΌΠΈ Π»ΡΠ΄Π° ΠΈ Π²Π·Π±Π΅ΠΉ 3. ΠΠ΅ΡΠ΅Π»Π΅ΠΉ ΡΠ΅ΡΠ΅Π· ΡΡΡΠ΅ΠΉΠ½Π΅Ρ Π² ΠΎΡ Π»Π°ΠΆΠ΄Π΅Π½Π½ΠΎΠ΅ ΡΠ°ΠΌΠΏΠ°Π½ΡΠΊΠΎΠ΅ Π±Π»ΡΠ΄ΡΠ΅ |
NOTE! See temporary workaround for details.
Example:
id | name | amount | unit | π cocktail_id | π cocktail_name |
---|---|---|---|---|---|
1 | Π±Π΅Π»ΡΠΉ ΡΠΎΠΌ | 60 | ΠΌΠ» | 1 | Π΄Π°ΠΉΠΊΠΈΡΠΈ |
2 | ΡΠ°Ρ Π°ΡΠ½ΡΠΉ ΡΠΈΡΠΎΠΏ | 15 | ΠΌΠ» | 1 | Π΄Π°ΠΉΠΊΠΈΡΠΈ |
Example:
id | name | π cocktail_id | π cocktail_name |
---|---|---|---|
1 | ΠΊΡΠ΅ΠΏΠΊΠΈΠ΅ | 1 | Π΄Π°ΠΉΠΊΠΈΡΠΈ |
2 | ΠΊΠ»Π°ΡΡΠΈΠΊΠ° | 1 | Π΄Π°ΠΉΠΊΠΈΡΠΈ |
Parser will parse one url, which contains all cocktails. Then all cocktail data will be parsed and saved to database.
- Java 11 or higher
Simple clone this repository :)
Configure application.properties
spring.datasource.url
- url to your PostgreSQL database
spring.datasource.username
- database username
spring.datasource.password
- database password
Also, you need to install fuzzystrmatch extension to PostgreSQL database:
simple execute query: CREATE EXTENSION fuzzystrmatch;
Configure parser.properties
NOTE! Only one site is supported, so there is no need to configure parser manually.
domain
- main url
fullCocktailLink
- url, which contains all cocktails.
Configure bot.properties
token
- your Telegram bot token
username
- your Telegram bot username
cd into cloned repo and run program by
mvn spring-boot:run
There is REST controller with updateCocktailDb
mapping for database update.
So you can run curl <ip>:<port>/updateCocktailDb
to update db.
This project is still under development, so there are some temporary workarounds, which should be fixed in the future.
There are columns tag_names and ingredient_names in the cocktail table, while there are separate tables for tags and ingredients.
By this way I am able to search cocktails by substring with multiple ingredients or tags.
Way to fix:
Select cocktail from ingredient table or tag table, that contains all ingredients or tags from user input (use substring search for each element)