1
0
mirror of synced 2024-11-25 13:16:02 +03:00

improve translate, add markdowm formatting

This commit is contained in:
DmitryZagorulko 2018-09-24 17:31:31 +03:00
parent 4318e8c062
commit 52d3bfada6
2 changed files with 10 additions and 8 deletions

View File

@ -587,7 +587,7 @@ func mgWebhookHandler(c *gin.Context) {
var mb string
switch msg.Data.Type {
case v1.MsgTypeProduct:
mb = fmt.Sprintf("%s\n", msg.Data.Product.Name)
mb = fmt.Sprintf("*%s*\n", msg.Data.Product.Name)
if msg.Data.Product.Cost != nil && msg.Data.Product.Cost.Value != 0 {
mb += fmt.Sprintf(
@ -624,6 +624,8 @@ func mgWebhookHandler(c *gin.Context) {
m.ReplyToMessageID = qid
}
m.ParseMode = "Markdown"
msgSend, err := bot.Send(m)
if err != nil {
logger.Error(err)
@ -669,7 +671,7 @@ func mgWebhookHandler(c *gin.Context) {
}
func getOrderMessage(dataOrder *v1.MessageDataOrder) string {
mb := getLocalizedMessage("order")
mb := "*" + getLocalizedMessage("order")
if dataOrder.Number != "" {
mb += " " + dataOrder.Number
@ -678,7 +680,7 @@ func getOrderMessage(dataOrder *v1.MessageDataOrder) string {
if dataOrder.Date != "" {
mb += fmt.Sprintf(" (%s)", dataOrder.Date)
}
mb += "\n"
mb += "*\n"
if len(dataOrder.Items) > 0 {
mb += "\n"
for k, v := range dataOrder.Items {
@ -691,7 +693,7 @@ func getOrderMessage(dataOrder *v1.MessageDataOrder) string {
if v.Quantity != nil {
if v.Quantity.Value != 0 {
mb += fmt.Sprintf(
" %v",
" _%v_",
v.Quantity.Value,
)
}
@ -700,7 +702,7 @@ func getOrderMessage(dataOrder *v1.MessageDataOrder) string {
if v.Price != nil {
if val, ok := currency[strings.ToLower(v.Price.Currency)]; ok {
mb += fmt.Sprintf(
" x %s\n",
" _x %s_\n",
getLocalizedTemplateMessage(
"cost_currency",
map[string]interface{}{
@ -719,7 +721,7 @@ func getOrderMessage(dataOrder *v1.MessageDataOrder) string {
if dataOrder.Delivery != nil {
if dataOrder.Delivery.Name != "" {
mb += fmt.Sprintf(
"\n%s:\n%s",
"\n*%s:*\n%s",
getLocalizedMessage("delivery"),
dataOrder.Delivery.Name,
)
@ -749,7 +751,7 @@ func getOrderMessage(dataOrder *v1.MessageDataOrder) string {
if len(dataOrder.Payments) > 0 {
mb += fmt.Sprintf(
"\n%s:\n",
"\n*%s:*\n",
getLocalizedMessage("payment"),
)
for _, v := range dataOrder.Payments {

View File

@ -48,4 +48,4 @@ order: "Order"
delivery: "Delivery"
payment: "Payment"
order_total: "Order total"
cost_currency: "{{.Amount}} {{.Currency}}"
cost_currency: "{{.Currency}}{{.Amount}}"