is_html=False by default now
This commit is contained in:
@@ -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>"
|
"<li><code>!args arg1 [arg2] ... [arg5]</code> - command that takes 1..5 arguments</li>"
|
||||||
"</ul>"
|
"</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:
|
async def on_time_command(ctx: EventContext, vars: ContextVars) -> None:
|
||||||
"""!time"""
|
"""!time"""
|
||||||
await ctx.bot.send.text(
|
await ctx.bot.send.text(
|
||||||
ctx.room,
|
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:
|
async def on_raise_command(ctx: EventContext, vars: ContextVars) -> None:
|
||||||
"""!raise"""
|
"""!raise"""
|
||||||
await ctx.bot.send.text(
|
await ctx.bot.send.text(
|
||||||
ctx.room,
|
ctx.room,
|
||||||
"<strong>Executing <code>raise RuntimeError()</code>...</strong>"
|
"<strong>Executing <code>raise RuntimeError()</code>...</strong>",
|
||||||
|
is_html=True
|
||||||
)
|
)
|
||||||
raise RuntimeError()
|
raise RuntimeError()
|
||||||
|
|
||||||
@@ -50,7 +56,8 @@ async def on_assert_command(ctx: EventContext, vars: ContextVars) -> None:
|
|||||||
"""!assert"""
|
"""!assert"""
|
||||||
await ctx.bot.send.text(
|
await ctx.bot.send.text(
|
||||||
ctx.room,
|
ctx.room,
|
||||||
"<strong>Executing <code>assert False</code>...</strong>"
|
"<strong>Executing <code>assert False</code>...</strong>",
|
||||||
|
is_html=True
|
||||||
)
|
)
|
||||||
assert False
|
assert False
|
||||||
|
|
||||||
@@ -63,7 +70,11 @@ async def on_mul_command(ctx: EventContext, vars: ContextVars) -> None:
|
|||||||
v *= n
|
v *= n
|
||||||
response = " * ".join(html.escape("%.2f" % n) for n in numbers)
|
response = " * ".join(html.escape("%.2f" % n) for n in numbers)
|
||||||
response += f" = <strong>{html.escape(str(v))}<strong>"
|
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:
|
except Exception as e:
|
||||||
await ctx.bot.send.text(ctx.room, f"Could not process the command: {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>"
|
response += "</ol>"
|
||||||
await ctx.bot.send.text(
|
await ctx.bot.send.text(
|
||||||
ctx.room,
|
ctx.room,
|
||||||
response
|
response,
|
||||||
|
is_html=True
|
||||||
)
|
)
|
||||||
except:
|
except:
|
||||||
await ctx.bot.send.text(
|
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:
|
async def invalid_usage(ctx: EventContext, vars: ContextVars) -> None:
|
||||||
"""This callback is called when the bot used incorrectly."""
|
"""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:
|
async def main() -> None:
|
||||||
|
|||||||
@@ -77,7 +77,8 @@ async def on_wrong_message(ctx: EventContext, vars: ContextVars) -> None:
|
|||||||
"""This callback is called when a wrong message is received."""
|
"""This callback is called when a wrong message is received."""
|
||||||
await ctx.bot.send.text(
|
await ctx.bot.send.text(
|
||||||
ctx.room,
|
ctx.room,
|
||||||
"Text me something like <code>!gen 0.1 0.7 1.0</code> or send an image to blur"
|
"Text me something like <code>!gen 0.1 0.7 1.0</code> or send an image to blur",
|
||||||
|
is_html=True
|
||||||
)
|
)
|
||||||
|
|
||||||
async def main() -> None:
|
async def main() -> None:
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ async def on_help_message(ctx: EventContext, vars: ContextVars) -> None:
|
|||||||
"\n!unban <room_id> <user_id> - unban the user from the room"
|
"\n!unban <room_id> <user_id> - unban the user from the room"
|
||||||
"\n!members <room_id> - get list of room members"
|
"\n!members <room_id> - get list of room members"
|
||||||
)
|
)
|
||||||
await ctx.bot.send.text(ctx.room, RESPONSE, is_html=False)
|
await ctx.bot.send.text(ctx.room, RESPONSE)
|
||||||
|
|
||||||
async def on_cmd_create(ctx: EventContext, vars: ContextVars) -> None:
|
async def on_cmd_create(ctx: EventContext, vars: ContextVars) -> None:
|
||||||
"""!create"""
|
"""!create"""
|
||||||
|
|||||||
@@ -138,7 +138,7 @@ class ClientSender:
|
|||||||
room: MatrixRoom | str,
|
room: MatrixRoom | str,
|
||||||
text: str,
|
text: str,
|
||||||
*,
|
*,
|
||||||
is_html: bool | None = None) -> str:
|
is_html: bool | None = False) -> str:
|
||||||
"""
|
"""
|
||||||
Send text message to `room`.
|
Send text message to `room`.
|
||||||
|
|
||||||
@@ -162,7 +162,7 @@ class ClientSender:
|
|||||||
room: MatrixRoom | str,
|
room: MatrixRoom | str,
|
||||||
path: Path | str, *,
|
path: Path | str, *,
|
||||||
text: str | None = None,
|
text: str | None = None,
|
||||||
is_html: bool | None = None,
|
is_html: bool | None = False,
|
||||||
filename: str | None = None,
|
filename: str | None = None,
|
||||||
timeout: float | None = 60 * 60) -> str:
|
timeout: float | None = 60 * 60) -> str:
|
||||||
"""
|
"""
|
||||||
@@ -221,7 +221,7 @@ class ClientSender:
|
|||||||
filename: str,
|
filename: str,
|
||||||
*,
|
*,
|
||||||
text: str | None = None,
|
text: str | None = None,
|
||||||
is_html: bool | None = None,
|
is_html: bool | None = False,
|
||||||
timeout: float | None = 60 * 60) -> str:
|
timeout: float | None = 60 * 60) -> str:
|
||||||
"""
|
"""
|
||||||
Send the image to `room`. Please note that formatted text is displayed
|
Send the image to `room`. Please note that formatted text is displayed
|
||||||
@@ -284,7 +284,7 @@ class ClientSender:
|
|||||||
*,
|
*,
|
||||||
props: VideoFileProperties | None = None,
|
props: VideoFileProperties | None = None,
|
||||||
text: str | None = None,
|
text: str | None = None,
|
||||||
is_html: bool | None = None,
|
is_html: bool | None = False,
|
||||||
timeout: float | None = 60 * 60) -> str:
|
timeout: float | None = 60 * 60) -> str:
|
||||||
"""
|
"""
|
||||||
Send the video to `room`. Please note that formatted text is displayed
|
Send the video to `room`. Please note that formatted text is displayed
|
||||||
@@ -370,7 +370,7 @@ class ClientSender:
|
|||||||
filename: str | None = None,
|
filename: str | None = None,
|
||||||
mime_type: str | None = None,
|
mime_type: str | None = None,
|
||||||
text: str | None = None,
|
text: str | None = None,
|
||||||
is_html: bool | None = None,
|
is_html: bool | None = False,
|
||||||
timeout: float | None = 60 * 60):
|
timeout: float | None = 60 * 60):
|
||||||
"""
|
"""
|
||||||
Send the file to `room`. Please note that formatted text is displayed
|
Send the file to `room`. Please note that formatted text is displayed
|
||||||
@@ -431,7 +431,7 @@ class ClientSender:
|
|||||||
*,
|
*,
|
||||||
mime_type: str | None = None,
|
mime_type: str | None = None,
|
||||||
text: str | None = None,
|
text: str | None = None,
|
||||||
is_html: bool | None = None,
|
is_html: bool | None = False,
|
||||||
timeout: float | None = 60 * 60) -> str:
|
timeout: float | None = 60 * 60) -> str:
|
||||||
"""
|
"""
|
||||||
Send the file to `room`.
|
Send the file to `room`.
|
||||||
|
|||||||
Reference in New Issue
Block a user