Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

help-wanted #1

Open
mainak0907 opened this issue Dec 7, 2023 · 1 comment
Open

help-wanted #1

mainak0907 opened this issue Dec 7, 2023 · 1 comment

Comments

@mainak0907
Copy link

mainak0907 commented Dec 7, 2023

Greetings @nevo-david ,
I was implementing the Resume maker with ChatGPT and encountered this error.

image
@WillKirkmanM
Copy link

Hey Mainak,

As shown in the error, the issue is that the message must be shorter than 262144 bytes, to solve this, split your message into sections split by 262144. Here's how you would do it in TypeScript

function splitStringByBytes(str: string, byteSize: number): string[] {
    const buffer = Buffer.from(str, 'utf-8');
    let start = 0;
    const result = [];

    while (start < buffer.length) {
        let end = start + byteSize;
        if (end > buffer.length) {
            end = buffer.length;
        }
        result.push(buffer.slice(start, end).toString('utf-8'));
        start = end;
    }

    return result;
}

const chunks = splitStringByBytes('The Resume Message', 262144);

Kind Regards,
WillKirkmanM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants