add code language support for event_hack and exception report

This commit is contained in:
A.C.Sukazyo Eyre 2023-11-17 01:19:22 +08:00
parent 720771719e
commit 7ee4a0d3c5
Signed by: Eyre_S
GPG Key ID: C17CE40291207874
4 changed files with 5 additions and 4 deletions

View File

@ -5,7 +5,7 @@ MORNY_ARCHIVE_NAME = morny-coeur
MORNY_CODE_STORE = https://github.com/Eyre-S/Coeur-Morny-Cono MORNY_CODE_STORE = https://github.com/Eyre-S/Coeur-Morny-Cono
MORNY_COMMIT_PATH = https://github.com/Eyre-S/Coeur-Morny-Cono/commit/%s MORNY_COMMIT_PATH = https://github.com/Eyre-S/Coeur-Morny-Cono/commit/%s
VERSION = 1.3.0-dev4 VERSION = 1.3.0-dev5
USE_DELTA = false USE_DELTA = false
VERSION_DELTA = VERSION_DELTA =

View File

@ -196,6 +196,7 @@ class Encryptor (using coeur: MornyCoeur) extends ITelegramCommand {
import cc.sukazyo.cono.morny.util.tgapi.formatting.TelegramParseEscape.escapeHtml as h import cc.sukazyo.cono.morny.util.tgapi.formatting.TelegramParseEscape.escapeHtml as h
coeur.account exec SendMessage( coeur.account exec SendMessage(
event.message.chat.id, event.message.chat.id,
// language=html
s"<pre><code>${h(_text.text)}</code></pre>" s"<pre><code>${h(_text.text)}</code></pre>"
).parseMode(ParseMode HTML).replyToMessageId(event.message.messageId) ).parseMode(ParseMode HTML).replyToMessageId(event.message.messageId)

View File

@ -42,7 +42,7 @@ class EventHacker (using coeur: MornyCoeur) {
coeur.account exec SendMessage( coeur.account exec SendMessage(
x.from_chat, x.from_chat,
// language=html // language=html
s"<code>${h(GsonBuilder().setPrettyPrinting().create.toJson(update))}</code>" s"<pre><code class='language-json'>${h(GsonBuilder().setPrettyPrinting().create.toJson(update))}</code></pre>"
).parseMode(ParseMode HTML).replyToMessageId(x.from_message toInt) ).parseMode(ParseMode HTML).replyToMessageId(x.from_message toInt)
true true
} }

View File

@ -46,7 +46,7 @@ class MornyReport (using coeur: MornyCoeur) {
def _tgErrFormat: String = e match def _tgErrFormat: String = e match
case api: EventRuntimeException.ActionFailed => case api: EventRuntimeException.ActionFailed =>
// language=html // language=html
"\n\ntg-api error:\n<pre><code>%s</code></pre>" "\n\ntg-api error:\n<pre><code class='language-json'>%s</code></pre>"
.formatted(GsonBuilder().setPrettyPrinting().create.toJson(api.response)) .formatted(GsonBuilder().setPrettyPrinting().create.toJson(api.response))
case _ => "" case _ => ""
executeReport(SendMessage( executeReport(SendMessage(
@ -54,7 +54,7 @@ class MornyReport (using coeur: MornyCoeur) {
// language=html // language=html
s"""<b>▌Coeur Unexpected Exception </b> s"""<b>▌Coeur Unexpected Exception </b>
|${if description ne null then h(description)+"\n" else ""} |${if description ne null then h(description)+"\n" else ""}
|<pre><code>${h(exceptionLog(e))}</code></pre>$_tgErrFormat""" |<pre><code class="language-log">${h(exceptionLog(e))}</code></pre>$_tgErrFormat"""
.stripMargin .stripMargin
).parseMode(ParseMode HTML)) ).parseMode(ParseMode HTML))
} }