From 7220c6d2c251303db46291b014c1af7ab4663fdd Mon Sep 17 00:00:00 2001 From: leca Date: Fri, 9 Aug 2024 02:08:46 +0300 Subject: [PATCH] asking range --- messages.json | 40 ---------------------------------------- src/index.js | 13 +++++++++++-- translations/en.json | 5 +++-- translations/ru.json | 5 +++-- 4 files changed, 17 insertions(+), 46 deletions(-) delete mode 100644 messages.json diff --git a/messages.json b/messages.json deleted file mode 100644 index d0dcd5d..0000000 --- a/messages.json +++ /dev/null @@ -1,40 +0,0 @@ -{ - "general": { - "welcome": "Hello! I am a bot for new meetings in Matrix!\nTo start, please, type \"!start\"\nI'll ask some questions to fill your profile. You can change that info later, if you will.\nThen, I'll start showing you another people's profiles.\nYou can like other profile, skip or send a message to the person.\nIf you mutually liked each other, you'll be given each other's MXID to start a DM.\nMy source code can be found on gitea: https://git.foxarmy.org/leca/heart2heart.\n\nGood luck!", - "rate": "Decide wether you like (πŸ‘οΈ, ❀️ or 1), dislike (πŸ‘ŽοΈ, πŸ’” or 2) or wanna send a messsage (πŸ’Œ or 3). Write '🏠️' or 4 to quit to menu. Any other response counts as dislike.", - "menu": "Pick an action:\n1) Start watching profiles\n2) Check for mutual likes\n3) Check for messages", - "newlikes": "You have new mutual like(s)! Go into menu (🏠️) to see!", - "showalike": "This person and you mutually liked each other!", - "mxid": "Go drop them a line! Their MXID is: ", - "message": "Write one message to this person or upload one picture/video to send them!", - "newmessage": "You've got new message(s)! Go to a menu (🏠️) to see!", - "showmessage": " sent you this: ", - "nonewmessages": "You have no new messages!", - "messagesent": "You message was sent!" - }, - "setup": { - "country": "Write a name of country you are living in. Prefer local language. For example, 'Россия', 'United States' or 'Π£ΠΊΡ€Π°Ρ—Π½Π°'.", - "city": "Write a name of city you are living in. Prefer local language. For example, 'Москва', 'Washington, D.C.', or 'ΠšΠΈΡ—Π²'.", - "name": "Write a name of your profile. Not longer than 32 symbols", - "description": "Write a description of your profile. Not longer than 512 symbols.", - "age": "Write your age. People yonger than 14 are disallowed to use the service.", - "sex": "Write your sex: Male or female.", - "interest": "Write who you are interested to talk to? Write 'both', 'male', or 'female'.", - "pictures": "Send up to five pictures that will be shown in your profile. Write any text message when you are done.", - "done": "Phew! You are done filling your profile! Now I'll start showing you others profiles!", - "more": "Got that cool picture! You still can upload up to this amount of pictures: ", - "enough": "That's enough of pictures! Let's go further!" - }, - "errors": { - "notadm": "This room is not a DM (direct or private messages). You should invite me in a DM! By the way, I support encrypted rooms! Bye and see you in DM!", - "toobig": "Sorry! The length of what you have written here is bigger than I expected! If you beleive that it is an error, please, file an issue on my git: https://git.foxarmy.org/leca/heart2heart. Otherwise, write something a little bit smaller! Thank you!", - "tooyoung": "Sorry! You are too young for this! Please, come back when you'll turn at least 14! Thank you and good bye!", - "toomuch": "You have loaded more that 5 pictures. I'll not upload that. Going to the next step...", - "twosexes": "There are only two sexes! Please, choose your biological one.", - "didntunderstand": "I cannot understand your answer. Please, read my question again and answer!", - "notimplemented": "This feature is not yet implemented! Please, keep track of my updates at https://git.foxarmy.org/leca/heart2heart. Bother your admins to update, if released! ;)", - "noprofiles": "There are no profiles left for you! I'm sorry. Please, come back later!", - "alreadymessaged": "You have already messaged that person. Your message was not sent!" - - } -} \ No newline at end of file diff --git a/src/index.js b/src/index.js index 363c58e..16a8e1e 100644 --- a/src/index.js +++ b/src/index.js @@ -81,12 +81,21 @@ client.on("room.message", async (roomId, event) => { i18n.locale = a[1] await setUserState(roomId, "country"); await client.sendText(roomId, i18n.t(["setup", "country"])); - + break; case "country": await processRequest(client, roomId, current_action, answer, 'city'); break; case "city": + await processRequest(client, roomId, current_action, answer, 'range'); + break; + case "range": + answer = parseInt(answer.split(" ")[0]); + console.log(answer) + if (!answer) { + await client.sendText(roomId, i18n.t(["setup", "range"])); + return; + } await processRequest(client, roomId, current_action, answer, 'name'); break; case "name": @@ -95,7 +104,7 @@ client.on("room.message", async (roomId, event) => { case "age": answer = parseInt(answer) if (!answer) { - await client.sendText(roomId, i18n.t(["general", "age"])); + await client.sendText(roomId, i18n.t(["setup", "age"])); return; } diff --git a/translations/en.json b/translations/en.json index 07d1cf9..49f5a6c 100644 --- a/translations/en.json +++ b/translations/en.json @@ -15,8 +15,9 @@ "setopt": "Got \"%{opt}\"" }, "setup": { - "country": "Write a name of country you are living in. Prefer local language. For example, 'Россия', 'United States' or 'Π£ΠΊΡ€Π°Ρ—Π½Π°'.", - "city": "Write a name of city you are living in. Prefer local language. For example, 'Москва', 'Washington, D.C.', or 'ΠšΠΈΡ—Π²'.", + "country": "Write a name of country you are living in. Write them in English. For example, 'Russia', 'United States' or 'Ukraine'.", + "city": "Write a name of city you are living in. Write them in English. For example, 'Moscow', 'Washington', or 'Kyiv'.", + "range": "Write a radius (in kilometers) of a circle you'd like to find people in (Write 0 if you don't care or small values to find people in your city only)", "name": "Write a name of your profile. Not longer than 32 symbols", "description": "Write a description of your profile. Not longer than 512 symbols.", "age": "Write your age. People yonger than 14 are disallowed to use the service.", diff --git a/translations/ru.json b/translations/ru.json index e4082cc..239a5c9 100644 --- a/translations/ru.json +++ b/translations/ru.json @@ -15,8 +15,9 @@ "setopt": "Записал \"%{opt}\"" }, "setup": { - "country": "ΠΠ°ΠΏΠΈΡˆΠΈΡ‚Π΅ имя страны, Π² ΠΊΠΎΡ‚ΠΎΡ€ΠΎΠΉ Π²Ρ‹ Π½Π°Ρ…ΠΎΠ΄ΠΈΡ‚Π΅ΡΡŒ. ΠŸΡ€Π΅Π΄ΠΏΠΎΡ‡Ρ‚ΠΈΡ‚Π΅Π»ΡŒΠ½ΠΎ Π½Π° мСстном языкС. НапримСр, 'Россия', 'United States' ΠΈΠ»ΠΈ 'Π£ΠΊΡ€Π°Ρ—Π½Π°'.", - "city": "ΠΠ°ΠΏΠΈΡˆΠΈΡ‚Π΅ имя Π³ΠΎΡ€ΠΎΠ΄Π°, Π² ΠΊΠΎΡ‚ΠΎΡ€ΠΎΠΌ Π²Ρ‹ Π½Π°Ρ…ΠΎΠ΄ΠΈΡ‚Π΅ΡΡŒ. ΠŸΡ€Π΅Π΄ΠΏΠΎΡ‡Ρ‚ΠΈΡ‚Π΅Π»ΡŒΠ½ΠΎ Π½Π° мСстном языкС. НапримСр, 'Москва', 'Washington, D.C.', ΠΈΠ»ΠΈ 'ΠšΠΈΡ—Π²'.", + "country": "ΠΠ°ΠΏΠΈΡˆΠΈΡ‚Π΅ имя страны, Π² ΠΊΠΎΡ‚ΠΎΡ€ΠΎΠΉ Π²Ρ‹ Π½Π°Ρ…ΠΎΠ΄ΠΈΡ‚Π΅ΡΡŒ. ΠŸΠΈΡΠ°Ρ‚ΡŒ Π½Π° английском языкС. НапримСр, 'Russia', 'United States' or 'Ukraine'.", + "city": "ΠΠ°ΠΏΠΈΡˆΠΈΡ‚Π΅ имя Π³ΠΎΡ€ΠΎΠ΄Π°, Π² ΠΊΠΎΡ‚ΠΎΡ€ΠΎΠΌ Π²Ρ‹ Π½Π°Ρ…ΠΎΠ΄ΠΈΡ‚Π΅ΡΡŒ. ΠŸΠΈΡΠ°Ρ‚ΡŒ Π½Π° английском языкС. НапримСр, 'Moscow', 'Washington', or 'Kyiv'.", + "range": "ΠΠ°ΠΏΠΈΡˆΠΈΡ‚Π΅ радиус (Π² ΠΊΠΈΠ»ΠΎΠΌΠ΅Ρ‚Ρ€Π²Ρ…), Π² ΠΊΠΎΡ‚ΠΎΡ€ΠΎΠΌ Π²Ρ‹ Ρ…ΠΎΡ‚Π΅Π»ΠΈ Π±Ρ‹ Π½Π°ΠΉΡ‚ΠΈ людСй (ΠΠ°ΠΏΠΈΡˆΠΈΡ‚Π΅ 0, Ссли Π²Π°ΠΌ Π½Π΅ Π²Π°ΠΆΠ΅Π½ радиус ΠΈΠ»ΠΈ малСнькиС значСния, Ссли Ρ…ΠΎΡ‚ΠΈΡ‚Π΅ Π½Π°ΠΉΡ‚ΠΈ людСй Ρ‚ΠΎΠ»ΡŒΠΊΠΎ Π² своём Π³ΠΎΡ€ΠΎΠ΄Π΅)", "name": "ΠΠ°ΠΏΠΈΡˆΠΈΡ‚Π΅ имя вашСго профиля. НС большС 32 символов", "description": "ΠΠ°ΠΏΠΈΡˆΠΈΡ‚Π΅ описаниС вашСго профиля. НС большС 512 символов.", "age": "ΠΠ°ΠΏΠΈΡˆΠΈΡ‚Π΅ ваш возраст. Π›ΡŽΠ΄ΡΠΌ, младшС 14 Π½Π΅ Ρ€Π°Π·Ρ€Π΅ΡˆΠ΅Π½ΠΎ ΠΈΡΠΏΠΎΠ»ΡŒΠ·ΠΎΠ²Π°Ρ‚ΡŒ этот сСрвис.",