is_html=False by default now

This commit is contained in:
2026-11-08 20:14:02 +03:00
parent d758bdedac
commit b7a471659d
4 changed files with 31 additions and 15 deletions

View File

@@ -29,20 +29,26 @@ async def on_help_command(ctx: EventContext, vars: ContextVars) -> None:
"<li><code>!args arg1 [arg2] ... [arg5]</code> - command that takes 1..5 arguments</li>"
"</ul>"
)
await ctx.bot.send.text(ctx.room, HELP_MESSAGE)
await ctx.bot.send.text(
ctx.room,
HELP_MESSAGE,
is_html=True
)
async def on_time_command(ctx: EventContext, vars: ContextVars) -> None:
"""!time"""
await ctx.bot.send.text(
ctx.room,
f"Current UNIX timestamp is <strong>{int(time.time())}</strong>"
f"Current UNIX timestamp is <strong>{int(time.time())}</strong>",
is_html=True
)
async def on_raise_command(ctx: EventContext, vars: ContextVars) -> None:
"""!raise"""
await ctx.bot.send.text(
ctx.room,
"<strong>Executing <code>raise RuntimeError()</code>...</strong>"
"<strong>Executing <code>raise RuntimeError()</code>...</strong>",
is_html=True
)
raise RuntimeError()
@@ -50,7 +56,8 @@ async def on_assert_command(ctx: EventContext, vars: ContextVars) -> None:
"""!assert"""
await ctx.bot.send.text(
ctx.room,
"<strong>Executing <code>assert False</code>...</strong>"
"<strong>Executing <code>assert False</code>...</strong>",
is_html=True
)
assert False
@@ -63,7 +70,11 @@ async def on_mul_command(ctx: EventContext, vars: ContextVars) -> None:
v *= n
response = " * ".join(html.escape("%.2f" % n) for n in numbers)
response += f" = <strong>{html.escape(str(v))}<strong>"
await ctx.bot.send.text(ctx.room, response)
await ctx.bot.send.text(
ctx.room,
response,
is_html=True
)
except Exception as e:
await ctx.bot.send.text(ctx.room, f"Could not process the command: {e}")
@@ -81,7 +92,8 @@ async def on_args_command(ctx: EventContext, vars: ContextVars) -> None:
response += "</ol>"
await ctx.bot.send.text(
ctx.room,
response
response,
is_html=True
)
except:
await ctx.bot.send.text(
@@ -91,7 +103,10 @@ async def on_args_command(ctx: EventContext, vars: ContextVars) -> None:
async def invalid_usage(ctx: EventContext, vars: ContextVars) -> None:
"""This callback is called when the bot used incorrectly."""
await ctx.bot.send.text(ctx.room, "Use <code>!help</code>")
await ctx.bot.send.text(
ctx.room,
"Use <code>!help</code>",
is_html=True)
async def main() -> None: