require_once $config['site_path'] . '/classes/social_messages/VkMessage.php';
use ClientBase\social_messages\VkMessage;
if ($line['{$message_field}'] != '' && $line['{$msg_author_field}'] != 'Клиент') {

    if (!$line['{$msg_client_link_field}']['id'] && $line['{$msg_link_field}']['{$user_link_field}']['id']) {
        $line['{$msg_client_link_field}'] = $line['{$msg_link_field}']['{$user_link_field}']['id'];
        $vk_id = $line['{$msg_link_field}']['{$new_field}'];
    } else if (!$line['{$msg_link_field}']['id'] && $line['{$msg_client_link_field}']['id']) {
        $res = data_select_field({$user_table_id}, 'id, {$new_field} AS VK', '{$user_link_field} = ', $line['{$msg_client_link_field}']['id']);
        $row = sql_fetch_assoc($res);
        $vk_id = $row['VK'];
        $line['{$msg_link_field}'] = $row['id'];
    } else if ($line['{$msg_client_link_field}']['id'] && $line['{$msg_link_field}']['id']) {
        $vk_id = $line['{$msg_link_field}']['{$new_field}'];
    } else {
        $vk_id = $line['{$msg_link_field}']['{$new_field}'];
    }
    $scl_msg_token = sql_select_array($config['table_prefix'] . 'module_social_messages');
    $token = $scl_msg_token['token'];
    $vk_msg = new VkMessage();
    $vk_msg->sendMessage(
        $vk_id,
        $line['{$message_field}'],
        $token
    );
}