diff --git a/examples/command_bot.py b/examples/command_bot.py index 8419124..bedfce8 100644 --- a/examples/command_bot.py +++ b/examples/command_bot.py @@ -29,20 +29,26 @@ async def on_help_command(ctx: EventContext, vars: ContextVars) -> None: "
  • !args arg1 [arg2] ... [arg5] - command that takes 1..5 arguments
  • " "" ) - 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 {int(time.time())}" + f"Current UNIX timestamp is {int(time.time())}", + is_html=True ) async def on_raise_command(ctx: EventContext, vars: ContextVars) -> None: """!raise""" await ctx.bot.send.text( ctx.room, - "Executing raise RuntimeError()..." + "Executing raise RuntimeError()...", + 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, - "Executing assert False..." + "Executing assert False...", + 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" = {html.escape(str(v))}" - 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 += "" 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 !help") + await ctx.bot.send.text( + ctx.room, + "Use !help", + is_html=True) async def main() -> None: diff --git a/examples/image_bot.py b/examples/image_bot.py index 1af8ae3..c55c395 100644 --- a/examples/image_bot.py +++ b/examples/image_bot.py @@ -77,7 +77,8 @@ async def on_wrong_message(ctx: EventContext, vars: ContextVars) -> None: """This callback is called when a wrong message is received.""" await ctx.bot.send.text( ctx.room, - "Text me something like !gen 0.1 0.7 1.0 or send an image to blur" + "Text me something like !gen 0.1 0.7 1.0 or send an image to blur", + is_html=True ) async def main() -> None: diff --git a/examples/room_bot.py b/examples/room_bot.py index c729883..0f210a4 100644 --- a/examples/room_bot.py +++ b/examples/room_bot.py @@ -30,7 +30,7 @@ async def on_help_message(ctx: EventContext, vars: ContextVars) -> None: "\n!unban - unban the user from the room" "\n!members - 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: """!create""" diff --git a/src/mab/bot/_client_sender.py b/src/mab/bot/_client_sender.py index 73713f3..2317345 100644 --- a/src/mab/bot/_client_sender.py +++ b/src/mab/bot/_client_sender.py @@ -138,7 +138,7 @@ class ClientSender: room: MatrixRoom | str, text: str, *, - is_html: bool | None = None) -> str: + is_html: bool | None = False) -> str: """ Send text message to `room`. @@ -162,7 +162,7 @@ class ClientSender: room: MatrixRoom | str, path: Path | str, *, text: str | None = None, - is_html: bool | None = None, + is_html: bool | None = False, filename: str | None = None, timeout: float | None = 60 * 60) -> str: """ @@ -221,7 +221,7 @@ class ClientSender: filename: str, *, text: str | None = None, - is_html: bool | None = None, + is_html: bool | None = False, timeout: float | None = 60 * 60) -> str: """ Send the image to `room`. Please note that formatted text is displayed @@ -284,7 +284,7 @@ class ClientSender: *, props: VideoFileProperties | None = None, text: str | None = None, - is_html: bool | None = None, + is_html: bool | None = False, timeout: float | None = 60 * 60) -> str: """ Send the video to `room`. Please note that formatted text is displayed @@ -370,7 +370,7 @@ class ClientSender: filename: str | None = None, mime_type: str | None = None, text: str | None = None, - is_html: bool | None = None, + is_html: bool | None = False, timeout: float | None = 60 * 60): """ Send the file to `room`. Please note that formatted text is displayed @@ -431,7 +431,7 @@ class ClientSender: *, mime_type: str | None = None, text: str | None = None, - is_html: bool | None = None, + is_html: bool | None = False, timeout: float | None = 60 * 60) -> str: """ Send the file to `room`.