frontend: cleanup telegram replies

This commit is contained in:
Lan Tian 2020-06-29 13:44:48 +08:00
parent df18bd153c
commit 721b3f6cc7
No known key found for this signature in database
GPG Key ID: 27F31700E751EC22
2 changed files with 9 additions and 3 deletions

View File

@ -43,5 +43,9 @@ func dn42WhoisFilter(whois string) string {
commandResult += s + "\n"
}
return commandResult + fmt.Sprintf("\n%d line(s) skipped.\n", skippedLines)
if skippedLines > 0 {
return commandResult + fmt.Sprintf("\n%d line(s) skipped.\n", skippedLines)
} else {
return commandResult
}
}

View File

@ -45,7 +45,9 @@ func telegramBatchRequestFormat(servers []string, endpoint string, command strin
results := batchRequest(servers, endpoint, command)
result := ""
for i, r := range results {
result += servers[i] + "\n"
if len(servers) > 1 {
result += servers[i] + "\n"
}
result += postProcess(r) + "\n\n"
}
return result
@ -149,7 +151,7 @@ func webHandlerTelegramBot(w http.ResponseWriter, r *http.Request) {
response := &tgWebhookResponse{
Method: "sendMessage",
ChatID: request.Message.Chat.ID,
Text: "```\n" + strings.TrimSpace(commandResult) + "\n```",
Text: "```\n" + commandResult + "\n```",
ReplyToMessageID: request.Message.MessageID,
ParseMode: "Markdown",
}