I have some code that prints out any messages that it receives in a loop:
import pytg
import pytg.utils
import pytg.receiver
@pytg.utils.coroutine
def receiver_function(tg_receiver):
while True:
message = (yield)
print(message)
tg_receiver = pytg.receiver.Receiver()
tg_receiver.start()
tg_receiver.message(receiver_function(tg_receiver))
receiver.stop()
I want to change this code such that it uses a simple function that halts until a message is encountered and then returns that one message and, of course, control:
import pytg
import pytg.receiver
def get_one_message():
tg_receiver.start()
while #<insert magic>:
#<insert magic>
message = #<insert magic>
tg.receiver.stop()
return message
print(get_one_message())
How could this be done?