Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions examples/command_bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
- bio -> fetch sender about/bio using contact user info API
- help -> show available commands
"""

from __future__ import annotations

import asyncio
Expand Down Expand Up @@ -88,12 +89,18 @@ async def on_message(client: TryxClient, event: EvMessage) -> None:
return

if text == "ping":
await client.chatstate.send_composing(chat_jid) # Show typing indicator for a more interactive feel.
await client.chatstate.send_composing(
chat_jid
) # Show typing indicator for a more interactive feel.
await asyncio.sleep(2) # Simulate some processing delay.
await client.chatstate.send_recording(chat_jid) # Stop typing indicator before sending the reply.
await client.chatstate.send_recording(
chat_jid
) # Stop typing indicator before sending the reply.
await client.send_text(chat_jid, "pong", quoted=event)
await asyncio.sleep(1) # Brief pause before sending follow-up message.
await client.chatstate.send_paused(chat_jid) # Clear any lingering typing indicators.
await client.chatstate.send_paused(
chat_jid
) # Clear any lingering typing indicators.
return

if text == "pushname":
Expand Down Expand Up @@ -124,7 +131,9 @@ async def on_message(client: TryxClient, event: EvMessage) -> None:
)
k = await client.send_photo(
chat_jid,
open("/home/krypton-byte/Downloads/ai.jpg.jpeg","rb").read(), # Send empty photo first to indicate loading state.
open(
"/home/krypton-byte/Downloads/ai.jpg.jpeg", "rb"
).read(), # Send empty photo first to indicate loading state.
# mimetype="image/jpeg",
# caption="Mengambil profile picture...",
# quoted=event,
Expand Down
Loading