1
0
mirror of https://github.com/fumiama/NanoBot.git synced 2026-06-09 12:40:24 +08:00

finish dms

This commit is contained in:
源文雨
2023-10-12 00:12:04 +09:00
parent c85d8701d5
commit 4c93bb6ff8
5 changed files with 81 additions and 28 deletions

View File

@@ -27,3 +27,23 @@ func getThisFuncName() string {
func getCallerFuncName() string {
return getFuncNameWithSkip(2)
}
// MessageEscape 消息转义
//
// https://bot.q.qq.com/wiki/develop/api/openapi/message/message_format.html
func MessageEscape(text string) string {
text = strings.ReplaceAll(text, "&", "&")
text = strings.ReplaceAll(text, "<", "&lt;")
text = strings.ReplaceAll(text, ">", "&gt;")
return text
}
// MessageUnescape 消息解转义
//
// https://bot.q.qq.com/wiki/develop/api/openapi/message/message_format.html
func MessageUnescape(text string) string {
text = strings.ReplaceAll(text, "&amp;", "&")
text = strings.ReplaceAll(text, "&lt;", "<")
text = strings.ReplaceAll(text, "&gt;", ">")
return text
}