Display typing indicator based on global message queue

This commit is contained in:
Kristóf Tóth 2019-10-07 13:24:23 +02:00
parent 0518716df8
commit 251bc6325a

View File

@ -17,6 +17,7 @@ class MessageQueueHandler:
for message in iter(self._queue.get, None):
wpm = message['wpm'] if 'wpm' in message else self.wpm
cps = 5 * wpm / 60
message['typing'] = not self._queue.empty()
self.connector.send_message(message)
sleep(len(message['message']) / cps)
@ -26,11 +27,9 @@ class MessageQueueHandler:
@staticmethod
def _generate_messages_from_queue(queue_message):
last = queue_message['messages'][-1]
for message in queue_message['messages']:
yield {
'key': 'message.send',
'typing': message is not last,
**message
}