<?php
// handlers/referral.php

function generateReferralCode($length = 8) {
    return substr(str_shuffle('ABCDEFGHJKLMNPQRSTUVWXYZ23456789'), 0, $length);
}

function getReferralCodeFromStart($text) {
    if (strpos($text, '/start ') !== 0) {
        return null;
    }
    $parts = explode(' ', $text);
    return $parts[1] ?? null;
}