Got rid of proxy methods in MatrixBot, v0.6.0
- Updated README.md - Updated examples - `MatrixBot` does not redefine methods from classes it is composed of anymore
This commit is contained in:
@@ -24,9 +24,9 @@ async def on_gen_command(data: EventContext) -> None:
|
||||
try:
|
||||
r, g, b = [float(v) for v in data[CTX_CMD_ARGS]]
|
||||
except:
|
||||
await data.bot.send_text(data.room, "Invalid arguments")
|
||||
await data.bot.send.text(data.room, "Invalid arguments")
|
||||
return
|
||||
await data.bot.send_text(data.room, "Generating the noise...")
|
||||
await data.bot.send.text(data.room, "Generating the noise...")
|
||||
# create the basic noise
|
||||
img = Image.new("RGB", (16, 16))
|
||||
for x in range(img.width):
|
||||
@@ -44,13 +44,13 @@ async def on_gen_command(data: EventContext) -> None:
|
||||
buf.seek(0)
|
||||
buf = buf.read()
|
||||
# send
|
||||
await data.bot.send_image_bytes(data.room, buf, "noise.png")
|
||||
await data.bot.send.image_bytes(data.room, buf, "noise.png")
|
||||
|
||||
async def on_image(ctx: EventContext) -> None:
|
||||
"""This callback is called when an image is received."""
|
||||
# download
|
||||
s = time.time()
|
||||
data = await ctx.bot.download_file(ctx)
|
||||
data = await ctx.bot.download.file(ctx)
|
||||
took_time = time.time() - s
|
||||
# convert to Image
|
||||
with BytesIO(data) as buf:
|
||||
@@ -66,7 +66,7 @@ async def on_image(ctx: EventContext) -> None:
|
||||
buf.seek(0)
|
||||
buf = buf.read()
|
||||
# send
|
||||
await ctx.bot.send_image_bytes(
|
||||
await ctx.bot.send.image_bytes(
|
||||
ctx.room,
|
||||
buf,
|
||||
"blurred.png",
|
||||
@@ -75,7 +75,7 @@ async def on_image(ctx: EventContext) -> None:
|
||||
|
||||
async def on_wrong_message(data: EventContext) -> None:
|
||||
"""This callback is called when a wrong message is received."""
|
||||
await data.bot.send_text(
|
||||
await data.bot.send.text(
|
||||
data.room,
|
||||
"Text me something like <code>!gen 0.1 0.7 1.0</code> or send an image to blur"
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user