我想在延时后使用 Celery 发送一些消息。用户收到消息后,触发新的状态。为此,我需要将 telebot.types.Message 对象作为 Celery 任务中的参数发送。我怎样才能正确地做到这一点?
我启动 Celery 任务的转换功能:
def delay_message(self, event):
celery_utils.delay_message.apply_async(kwargs={'response': self.response}, countdown=1) # self.response is telebot.types.Message
芹菜任务:
@celery.task()
def delay_message(response):
machine = routes.DialogMachine(transitions=app.config['transitions'])
machine.response = response
machine.send_random_motivation_message()
在send_random_motivation_message()我需要 telebot.types.Message 作为 self.response,但不能将此类型发送到 Celery 任务。