Skip to content

Commit

Permalink
bot,util,locales,tests: don't use objects in locales
Browse files Browse the repository at this point in the history
Don't use object properties inside locales, as it doesn't work
and leads to parse errors.
  • Loading branch information
webwarrior-ws committed Sep 26, 2024
1 parent ba09fdd commit 706b9fd
Show file tree
Hide file tree
Showing 13 changed files with 56 additions and 54 deletions.
20 changes: 11 additions & 9 deletions bot/modules/dispute/messages.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
const { getDisputeChannel, getDetailedOrder, sanitizeMD } = require('../../../util');
const {
getDisputeChannel,
getDetailedOrder,
sanitizeMD,
} = require('../../../util');
const { logger } = require('../../../logger');

exports.beginDispute = async (ctx, initiator, order, buyer, seller) => {
Expand Down Expand Up @@ -91,11 +95,11 @@ exports.disputeData = async (
// Fix Issue 543: Escape underscores in usernames
const escapedInitiatorUsername = sanitizeMD(initiatorUser.username);
const escapedCounterPartyUsername = sanitizeMD(counterPartyUser.username);

const message = ctx.i18n.t('dispute_started_channel', {
initiatorUser: { ...initiatorUser, username: escapedInitiatorUsername },
initiatorUser: escapedInitiatorUsername,
initiatorTgId: initiatorUser.tg_id,
counterPartyUser: { ...counterPartyUser, username: escapedCounterPartyUsername },
counterPartyUser: escapedCounterPartyUsername,
counterPartyUserTgId: counterPartyUser.tg_id,
buyer,
seller,
Expand All @@ -107,11 +111,9 @@ exports.disputeData = async (
buyerToken: order.buyer_dispute_token,
});
console.log(`Contens of message:\n${message}`);
await ctx.telegram.sendMessage(
solver.tg_id,
message,
{ parse_mode: 'MarkdownV2' }
);
await ctx.telegram.sendMessage(solver.tg_id, message, {
parse_mode: 'MarkdownV2',
});
// message to both parties letting them know the dispute
// has been taken by a solver
await ctx.telegram.sendMessage(
Expand Down
8 changes: 4 additions & 4 deletions locales/de.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -202,16 +202,16 @@ order_detail: |
seller: Käufer
buyer: Verkäufer
dispute_started_channel: |
Benutzer ${type} @${initiatorUser.username} TG ID: ${initiatorTgId}
hat einen Streitfall mit @${counterPartyUser.username} TG ID: ${counterPartyUserTgId} für den folgenden Auftrag eröffnet
Benutzer ${type} @${initiatorUser} TG ID: ${initiatorTgId}
hat einen Streitfall mit @${counterPartyUser} TG ID: ${counterPartyUserTgId} für den folgenden Auftrag eröffnet
${detailedOrder}
Seller Token: ${sellerToken}
Buyer Token: ${buyerToken}
@${initiatorUser.username} war an ${initiatorUser.disputes} Streitfällen beteiligt
@${counterPartyUser.username} war an ${counterPartyUser.disputes} Streitfällen beteiligt
@${initiatorUser} war an ${buyerDisputes} Streitfällen beteiligt
@${counterPartyUser} war an ${sellerDisputes} Streitfällen beteiligt
you_started: '🥴 Sie haben einen Streitfall zu Ihrer Bestellnummer begonnen: ${orderId}.'
counterpart_started: '🥴 Ihre Gegenpartei hat einen Streit über Ihre Bestellungsnummer begonnen: ${orderId}.'
dispute_started: '${who} Wenn er/sie Ihrem Streitfall zugewiesen wird, teilt der Bot Ihnen seinen/ihren Benutzernamen mit, und nur er/sie kann Sie betreuen. Sie können ihm/ihr direkt schreiben, aber wenn er/sie Sie zuerst kontaktiert, müssen Sie ihn/sie bitten, Ihnen den Token Ihres Streitfalls mitzuteilen, Ihr Token ist: ${token}.'
Expand Down
8 changes: 4 additions & 4 deletions locales/en.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -204,16 +204,16 @@ order_detail: |
seller: seller
buyer: buyer
dispute_started_channel: |
User ${type} @${initiatorUser.username} TG ID: ${initiatorTgId}
has started a dispute with @${counterPartyUser.username} TG ID: ${counterPartyUserTgId} for the order
User ${type} @${initiatorUser} TG ID: ${initiatorTgId}
has started a dispute with @${counterPartyUser} TG ID: ${counterPartyUserTgId} for the order
${detailedOrder}
Seller Token: ${sellerToken}
Buyer Token: ${buyerToken}
@${initiatorUser.username} has been involved in ${initiatorUser.disputes} disputes
@${counterPartyUser.username} has been involved in ${counterPartyUser.disputes} disputes
@${initiatorUser} has been involved in ${buyerDisputes} disputes
@${counterPartyUser} has been involved in ${sellerDisputes} disputes
you_started: '🥴 You have started a dispute on your order Id: ${orderId}.'
counterpart_started: '🥴 Your counterparty started a dispute on your order Id: ${orderId}.'
dispute_started: '${who} A solver will attend you soon, when he/she is assigned to your dispute the bot will tell you his/her username, only he/she will be able to attend you. You can write to him/her directly, but if he/she contacts you first, you must ask him/her to tell you what is the token of your dispute, your token is: ${token}.'
Expand Down
8 changes: 4 additions & 4 deletions locales/es.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -202,16 +202,16 @@ order_detail: |
seller: vendedor
buyer: comprador
dispute_started_channel: |
El ${type} @${initiatorUser.username} TG ID: ${initiatorTgId}
ha iniciado una disputa con @${counterPartyUser.username} TG ID: ${counterPartyUserTgId} en la orden:
El ${type} @${initiatorUser} TG ID: ${initiatorTgId}
ha iniciado una disputa con @${counterPartyUser} TG ID: ${counterPartyUserTgId} en la orden:
${detailedOrder}
Seller Token: ${sellerToken}
Buyer Token: ${buyerToken}
@${initiatorUser.username} ya tiene ${buyerDisputes} disputas
@${counterPartyUser.username} ya tiene ${sellerDisputes} disputas
@${initiatorUser} ya tiene ${buyerDisputes} disputas
@${counterPartyUser} ya tiene ${sellerDisputes} disputas
you_started: '🥴 Has iniciado una disputa en tu orden con Id: ${orderId}.'
counterpart_started: '🥴 Tu contraparte ha iniciado una disputa en tu orden con Id: ${orderId}.'
dispute_started: '${who} Un solver te atenderá pronto, cuando él/la solver sea asignado a tu disputa el bot te dirá su username, solo él/ella podrá atenderte. Puedes escribirle directamente, pero si él/ella te contacta primero, debes pedirle que te diga cuál es el token de tu disputa, tu token es: ${token}.'
Expand Down
8 changes: 4 additions & 4 deletions locales/fa.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -204,16 +204,16 @@ order_detail: |
seller: seller
buyer: buyer
dispute_started_channel: |
کاربر ${type} @${initiatorUser.username} TG ID: ${initiatorTgId}
بابت سفارش زیر یک مشاجره را با کاربر @${counterPartyUser.username} TG ID: ${counterPartyUserTgId} آغاز کرده
کاربر ${type} @${initiatorUser} TG ID: ${initiatorTgId}
بابت سفارش زیر یک مشاجره را با کاربر @${counterPartyUser} TG ID: ${counterPartyUserTgId} آغاز کرده
${detailedOrder}
Seller Token: ${sellerToken}
Buyer Token: ${buyerToken}
کابر@${initiatorUser.username} بابت ${initiatorUser.disputes} به اختلاف خورده
کاربر@${counterPartyUser.username} بابت ${counterPartyUser.disputes} به اختلاف خورده
کابر@${initiatorUser} بابت ${buyerDisputes} به اختلاف خورده
کاربر@${counterPartyUser} بابت ${sellerDisputes} به اختلاف خورده
you_started: '🥴 شما در مورد شناسه سفارش خود اختلاف نظر شروع کرده اید: ${orderId}.'
counterpart_started: '🥴 طرف مقابل شما یک اختلاف بر سر شناسه سفارش شما شروع کرد: ${orderId}.'
dispute_started: '${who} یک حل کننده به زودی در شما حضور خواهد یافت، هنگامی که او به منازعه شما منصوب شد، ربات نام کاربری خود را به شما می گوید، فقط او می تواند در شما حضور داشته باشد. شما می توانید مستقیماً برای او نامه بنویسید، اما اگر ابتدا با شما تماس گرفت، باید از او بخواهید که به شما بگوید نشانه اختلاف شما چیست، رمز شما این است: ${token}.'
Expand Down
8 changes: 4 additions & 4 deletions locales/fr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -204,16 +204,16 @@ order_detail: |
seller: vendeur
buyer: acheteur
dispute_started_channel: |
L'utilisateur ${type} @${initiatorUser.username} TG ID: ${initiatorTgId}
à déclenché un litige avec @${counterPartyUser.username} TG ID: ${counterPartyUserTgId} concernant l'offre
L'utilisateur ${type} @${initiatorUser} TG ID: ${initiatorTgId}
à déclenché un litige avec @${counterPartyUser} TG ID: ${counterPartyUserTgId} concernant l'offre
${detailedOrder}
Seller Token: ${sellerToken}
Buyer Token: ${buyerToken}
@${initiatorUser.username} a été impliqué.e dans ${initiatorUser.disputes} litiges
@${counterPartyUser.username} a été impliqué.e dans ${counterPartyUser.disputes} litiges
@${initiatorUser} a été impliqué.e dans ${buyerDisputes} litiges
@${counterPartyUser} a été impliqué.e dans ${sellerDisputes} litiges
you_started : '🥴 Vous avez commencé un litige sur votre commande Id : ${orderId}.'
counterpart_started : '🥴 Votre contrepartie a démarré un litige sur votre commande Id : ${orderId}.'
dispute_started : "${who} Un solver va bientôt venir vous voir, lorsqu'il/elle sera assigné(e) à votre litige, le bot vous indiquera son nom d'utilisateur, il/elle seul(e) sera en mesure de venir vous voir. Vous pouvez lui écrire directement, mais s'il vous contacte en premier, vous devez lui demander de vous dire quel est le jeton de votre litige, votre jeton est : ${token}."
Expand Down
8 changes: 4 additions & 4 deletions locales/it.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -202,16 +202,16 @@ order_detail: |
seller: venditore
buyer: acquirente
dispute_started_channel: |
User ${type} @${initiatorUser.username} TG ID: ${initiatorTgId}
ha iniziato una disputa con @${counterPartyUser.username} TG ID: ${counterPartyUserTgId} per l'ordine
User ${type} @${initiatorUser} TG ID: ${initiatorTgId}
ha iniziato una disputa con @${counterPartyUser} TG ID: ${counterPartyUserTgId} per l'ordine
${detailedOrder}
Seller Token: ${sellerToken}
Buyer Token: ${buyerToken}
@${initiatorUser.username} è stato coinvolto in ${initiatorUser.disputes} dispute
@${counterPartyUser.username} è stato coinvolto in in ${counterPartyUser.disputes} disputee
@${initiatorUser} è stato coinvolto in ${buyerDisputes} dispute
@${counterPartyUser} è stato coinvolto in in ${sellerDisputes} disputee
you_started: '🥴 Hai aperto una controversia per il tuo ordine Id: ${orderId}.'
counterpart_started: '🥴 La tua controparte ha aperto una controversia sul tuo ordine Id: ${orderId}.'
dispute_started: '${who} Un risolutore ti assisterà presto, quando sarà assegnato alla tua controversia il bot ti dirà il suo nome utente, solo lui potrà assisterti. Potete scrivergli direttamente, ma se vi contatta prima, dovete chiedergli di dirvi qual è il token della vostra controversia, il vostro token è: ${token}.'
Expand Down
8 changes: 4 additions & 4 deletions locales/ko.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -203,16 +203,16 @@ order_detail: |
seller: 판매자
buyer: 구매자
dispute_started_channel: |
사용자 ${type} @${initiatorUser.username} TG ID: ${initiatorTgId}
님께서 @${counterPartyUser.username} TG ID: ${counterPartyUserTgId} 와의 분쟁 조정을 시작하였습니다. 주문 상세 내역은 다음과 같습니다.
사용자 ${type} @${initiatorUser} TG ID: ${initiatorTgId}
님께서 @${counterPartyUser} TG ID: ${counterPartyUserTgId} 와의 분쟁 조정을 시작하였습니다. 주문 상세 내역은 다음과 같습니다.
${detailedOrder}
Seller Token: ${sellerToken}
Buyer Token: ${buyerToken}
${initiatorUser.disputes} 분쟁 조정에 @${initiatorUser.username}님께서 참여하셨습니다.
${counterPartyUser.disputes} 분쟁 조정에 @${counterPartyUser.username}님께서 참여하셨습니다.
${buyerDisputes} 분쟁 조정에 @${initiatorUser}님께서 참여하셨습니다.
${sellerDisputes} 분쟁 조정에 @${counterPartyUser}님께서 참여하셨습니다.
you_started: '🥴 주문 ID에 대한 분쟁이 시작되었습니다: ${orderId}'
counterpart_started: '🥴 거래 상대방이 주문 ID에 대해 분쟁을 시작했습니다: ${orderId}'
dispute_started: '${who} 해결사가 분쟁에 배정되면 봇이 자신의 사용자 아이디를 알려주며, 해당 해결사만 분쟁에 참석할 수 있습니다. 해결사에게 직접 편지를 보낼 수도 있지만, 해결사가 먼저 연락하는 경우 분쟁의 토큰이 무엇인지 알려달라고 요청해야 합니다(토큰은 ${토큰}입니다).'
Expand Down
8 changes: 4 additions & 4 deletions locales/pt.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -201,16 +201,16 @@ order_detail: |
seller: vendedora
buyer: compradora
dispute_started_channel: |
Usuário ${type} @${initiatorUser.username} TG ID: ${initiatorTgId}
iniciou uma disputa com @${counterPartyUser.username} TG ID: ${counterPartyUserTgId} para o pedido
Usuário ${type} @${initiatorUser} TG ID: ${initiatorTgId}
iniciou uma disputa com @${counterPartyUser} TG ID: ${counterPartyUserTgId} para o pedido
${detailedOrder}
Seller Token: ${sellerToken}
Buyer Token: ${buyerToken}
@${initiatorUser.username} esteve envolvido em ${initiatorUser.disputes} disputas
@${counterPartyUser.username} esteve envolvido em ${counterPartyUser.disputes} disputas
@${initiatorUser} esteve envolvido em ${buyerDisputes} disputas
@${counterPartyUser} esteve envolvido em ${sellerDisputes} disputas
you_started: '🥴 Você iniciou uma disputa em seu pedido Id: ${orderId}.'
counterpart_started: '🥴 Sua contraparte iniciou uma disputa em seu pedido Id: ${orderId}.'
dispute_started: '${who} Um solucionador o atenderá em breve. Quando ele for designado para sua disputa, o bot informará seu nome de usuário e somente ele poderá atendê-lo. Você pode escrever diretamente para ele/ela, mas se ele/ela entrar em contato com você primeiro, você deve pedir a ele/ela que lhe diga qual é o token de sua disputa, seu token é: ${token}.'
Expand Down
8 changes: 4 additions & 4 deletions locales/ru.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -201,16 +201,16 @@ order_detail: |
seller: продавец
buyer: покупатель
dispute_started_channel: |
${type} @${initiatorUser.username} TG ID: ${initiatorTgId}
инициировал разбирательство с @${counterPartyUser.username} TG ID: ${counterPartyUserTgId} относительно заявки:
${type} @${initiatorUser} TG ID: ${initiatorTgId}
инициировал разбирательство с @${counterPartyUser} TG ID: ${counterPartyUserTgId} относительно заявки:
${detailedOrder}
Seller Token: ${sellerToken}
Buyer Token: ${buyerToken}
@${initiatorUser.username} уже имел разбирательств: ${initiatorUser.disputes}
@${counterPartyUser.username} уже имел разбирательств: ${counterPartyUser.disputes}
@${initiatorUser} уже имел разбирательств: ${buyerDisputes}
@${counterPartyUser} уже имел разбирательств: ${sellerDisputes}
you_started: '🥴 Вы начали спор по вашему заказу Id: ${orderId}.'
counterpart_started: '🥴 Ваш контрагент начал спор по вашему заказу Id: ${orderId}.'
dispute_started: '${who} Скоро к вам придет решатель, когда он будет назначен на ваш спор, бот сообщит вам его/ее имя пользователя, только он/она сможет прийти к вам. Вы можете написать ему напрямую, но если он свяжется с вами первым, вы должны попросить его сказать вам, какой токен у вашего спора, ваш токен: ${token}.'
Expand Down
8 changes: 4 additions & 4 deletions locales/uk.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -201,16 +201,16 @@ order_detail: |
seller: продавець
buyer: покупець
dispute_started_channel: |
${type} @${initiatorUser.username} TG ID: ${initiatorTgId}
ініціював диспут з @${counterPartyUser.username} TG ID: ${counterPartyUserTgId} щодо заявки:
${type} @${initiatorUser} TG ID: ${initiatorTgId}
ініціював диспут з @${counterPartyUser} TG ID: ${counterPartyUserTgId} щодо заявки:
${detailedOrder}
Seller Token: ${sellerToken}
Buyer Token: ${buyerToken}
@${initiatorUser.username} вже мав спір: ${initiatorUser.disputes}
@${counterPartyUser.username} вже мав спір: ${counterPartyUser.disputes}
@${initiatorUser} вже мав спір: ${buyerDdisputes}
@${counterPartyUser} вже мав спір: ${sellerDisputes}
you_started: '🥴 Ви почали оскарження свого замовлення з ідентифікатором: ${orderId}.'
counterpart_started: '🥴 Ваш контрагент розпочав суперечку щодо вашого замовлення з ідентифікатором: ${orderId}.'
dispute_started: "${who} Розв'язувач незабаром прийде до вас, коли його/її буде призначено до вашої суперечки, бот повідомить вам своє ім'я користувача, лише він/вона зможе прийти до вас. Ви можете написати йому/їй безпосередньо, але якщо він/вона зв’яжеться з вами першим, ви повинні попросити його/її сказати вам, що є символом вашої суперечки, ваш маркер: ${token}."
Expand Down
8 changes: 4 additions & 4 deletions tests/bot/modules/dispute/messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@ const mockI18n = {
t: sinon.stub((key, params) => {
switch (key) {
case 'dispute_started_channel':
return `User ${params.type} @${params.initiatorUser.username} TG ID: ${params.initiatorTgId}
has started a dispute with @${params.counterPartyUser.username} TG ID: ${params.counterPartyUserTgId} for the order
return `User ${params.type} @${params.initiatorUser} TG ID: ${params.initiatorTgId}
has started a dispute with @${params.counterPartyUser} TG ID: ${params.counterPartyUserTgId} for the order
${params.detailedOrder}
Seller Token: ${params.sellerToken}
Buyer Token: ${params.buyerToken}
@${params.initiatorUser.username} has been involved in ${params.buyerDisputes} disputes
@${params.counterPartyUser.username} has been involved in ${params.sellerDisputes} disputes`;
@${params.initiatorUser} has been involved in ${params.buyerDisputes} disputes
@${params.counterPartyUser} has been involved in ${params.sellerDisputes} disputes`;
case 'seller':
return 'seller';
case 'buyer':
Expand Down
2 changes: 1 addition & 1 deletion util/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ const getDetailedOrder = (i18n: I18nContext, order: IOrder, buyer: UserDocument,
takenAt = sanitizeMD(takenAt);
const previousDisputeStatus = sanitizeMD(order.previous_dispute_status);
const status = sanitizeMD(order.status);
const fee = order.fee ? Number(order.fee) : '';
const fee = order.fee ? sanitizeMD(Number(order.fee)) : '';
const creator =
order.creator_id === buyerId ? buyerUsername : sellerUsername;
const buyerAge = buyer? getUserAge(buyer) : '';
Expand Down

0 comments on commit 706b9fd

Please sign in to comment.