mirror of
https://github.com/avatao-content/baseimage-tutorial-framework
synced 2024-11-22 08:51:32 +00:00
Display typing indicator based on global message queue
This commit is contained in:
parent
0518716df8
commit
251bc6325a
@ -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
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user