Esempio n. 1
0
def add_reminder(message, name, count, user, pattern, text):
    validate_reminder(count, user, text)

    next_time = utils.get_next_time(pattern)

    pcall = db_api.create_periodic_call(
        {
            'name': name,
            'arguments': json.dumps({
                'message': message,
                'text': text
            }),
            'target_method': 'vk_bot.bot.actions.answer_on_message',
            'pattern': pattern,
            'remaining_executions': count,
            'execution_time': next_time,
            'user_id': user
        }
    )

    utils.add_semaphore(pcall.id, 1)

    return pcall