improve translate, add markdowm formatting
This commit is contained in:
parent
4318e8c062
commit
52d3bfada6
@ -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 {
|
||||
|
@ -48,4 +48,4 @@ order: "Order"
|
||||
delivery: "Delivery"
|
||||
payment: "Payment"
|
||||
order_total: "Order total"
|
||||
cost_currency: "{{.Amount}} {{.Currency}}"
|
||||
cost_currency: "{{.Currency}}{{.Amount}}"
|
||||
|
Loading…
Reference in New Issue
Block a user