🎨 parametrize typing_loop with typing_loop

This commit is contained in:
Laureηt 2023-10-19 16:13:05 +00:00
parent 0f312a0a70
commit 5b5a18d73b
Signed by: Laurent
SSH key fingerprint: SHA256:kZEpW8cMJ54PDeCvOhzreNr4FSh6R13CMGH/POoO8DI

View file

@ -74,14 +74,22 @@ class LLMClient(AsyncClient):
# add callbacks # add callbacks
self.add_event_callback(self.message_callback, RoomMessageText) # type: ignore self.add_event_callback(self.message_callback, RoomMessageText) # type: ignore
async def typing_loop(self) -> None: async def typing_loop(
"""Send typing indicators every 5 seconds.""" self,
sleep_time: int = 10,
) -> None:
"""Send typing indicators every `sleep_time` seconds.
Args:
sleep_time (`int`, default `10`):
The time to sleep between sending typing indicators.
"""
logging.debug("Started typing indicator.") logging.debug("Started typing indicator.")
try: try:
while True: while True:
logging.debug("Sending typing indicator.") logging.debug("Sending typing indicator.")
await self.room_typing(self.room, True) await self.room_typing(self.room, True)
await asyncio.sleep(5) await asyncio.sleep(sleep_time)
except asyncio.CancelledError: except asyncio.CancelledError:
await self.room_typing(self.room, False) await self.room_typing(self.room, False)
logging.debug("Stopped typing indicator.") logging.debug("Stopped typing indicator.")