mirror of
https://github.com/avatao-content/baseimage-tutorial-framework
synced 2024-11-22 14:31: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):
|
for message in iter(self._queue.get, None):
|
||||||
wpm = message['wpm'] if 'wpm' in message else self.wpm
|
wpm = message['wpm'] if 'wpm' in message else self.wpm
|
||||||
cps = 5 * wpm / 60
|
cps = 5 * wpm / 60
|
||||||
|
message['typing'] = not self._queue.empty()
|
||||||
self.connector.send_message(message)
|
self.connector.send_message(message)
|
||||||
sleep(len(message['message']) / cps)
|
sleep(len(message['message']) / cps)
|
||||||
|
|
||||||
@ -26,11 +27,9 @@ class MessageQueueHandler:
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _generate_messages_from_queue(queue_message):
|
def _generate_messages_from_queue(queue_message):
|
||||||
last = queue_message['messages'][-1]
|
|
||||||
for message in queue_message['messages']:
|
for message in queue_message['messages']:
|
||||||
yield {
|
yield {
|
||||||
'key': 'message.send',
|
'key': 'message.send',
|
||||||
'typing': message is not last,
|
|
||||||
**message
|
**message
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user