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

add: make-in-sql-store.ts #1183

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Conversation

FaouzKK
Copy link

@FaouzKK FaouzKK commented Dec 31, 2024

I left the author's credits because it's not mine. I just tried to implement it directly in baileys and try it on a few projects.

I left the author's credits because it's not mine. I just tried to implement it directly in baileys and try it on a few projects.
@whiskeysockets-bot
Copy link
Contributor

Thanks for your contribution.

The next step is to wait for review and approval to merge it to main repository

The community can help reacting with a thumb up (:thumbsup:) for approval and rocket (:rocket:) for who has tested it.

To test this PR you can run the following command below:

# NPM
npm install @whiskeysockets/baileys@FaouzKK/Baileys#patch-1
# YARN v2
yarn add @whiskeysockets/baileys@FaouzKK/Baileys#patch-1

@Salientekill
Copy link

Very good

@Salientekill
Copy link

Could you please give me an example of how to use it so I can test it?

@FaouzKK
Copy link
Author

FaouzKK commented Jan 1, 2025

Could you please give me an example of how to use it so I can test it?

const { saveCreds, state } = await useMultiFileAuthState('./auth');
    const { version, isLatest } = await fetchLatestBaileysVersion();
    const store = await makeInSQLiteStore("1", "./store.db", pino({ level: 'silent' }))

    const zk = makeWASocket({
        version: version,
        logger: logger,
        browser: ['Zokou-md', 'safari', '1.0.0'],
        emitOwnEvents: true,
        syncFullHistory: true,
        printQRInTerminal: true,
        markOnlineOnConnect: false,
        receivedPendingNotifications: true,
        generateHighQualityLinkPreview: true,
        auth: {
            creds: state.creds,
            keys: makeCacheableSignalKeyStore(state.keys, logger)

        },
        keepAliveIntervalMs: 30_000,
        getMessage: async (msg) => {

            if (store) {

                const m = await store.loadMessage(msg.remoteJid, msg.id);
                return m?.message || undefined
            }
        }```


same like makeInMemoryStore

@Salientekill
Copy link

Could you please give me an example of how to use it so I can test it?

const { saveCreds, state } = await useMultiFileAuthState('./auth');
    const { version, isLatest } = await fetchLatestBaileysVersion();
    const store = await makeInSQLiteStore("1", "./store.db", pino({ level: 'silent' }))

    const zk = makeWASocket({
        version: version,
        logger: logger,
        browser: ['Zokou-md', 'safari', '1.0.0'],
        emitOwnEvents: true,
        syncFullHistory: true,
        printQRInTerminal: true,
        markOnlineOnConnect: false,
        receivedPendingNotifications: true,
        generateHighQualityLinkPreview: true,
        auth: {
            creds: state.creds,
            keys: makeCacheableSignalKeyStore(state.keys, logger)

        },
        keepAliveIntervalMs: 30_000,
        getMessage: async (msg) => {

            if (store) {

                const m = await store.loadMessage(msg.remoteJid, msg.id);
                return m?.message || undefined
            }
        }```


same like makeInMemoryStore

Thank you, I will test it.

@SheIITear
Copy link
Collaborator

I don't think this should be added. It adds not required weight for people who want to either implement their own or use different one. Instead you could make this into addon/gist.

@hacxk
Copy link

hacxk commented Jan 8, 2025

Could you please give me an example of how to use it so I can test it?

const { saveCreds, state } = await useMultiFileAuthState('./auth');
    const { version, isLatest } = await fetchLatestBaileysVersion();
    const store = await makeInSQLiteStore("1", "./store.db", pino({ level: 'silent' }))

    const zk = makeWASocket({
        version: version,
        logger: logger,
        browser: ['Zokou-md', 'safari', '1.0.0'],
        emitOwnEvents: true,
        syncFullHistory: true,
        printQRInTerminal: true,
        markOnlineOnConnect: false,
        receivedPendingNotifications: true,
        generateHighQualityLinkPreview: true,
        auth: {
            creds: state.creds,
            keys: makeCacheableSignalKeyStore(state.keys, logger)

        },
        keepAliveIntervalMs: 30_000,
        getMessage: async (msg) => {

            if (store) {

                const m = await store.loadMessage(msg.remoteJid, msg.id);
                return m?.message || undefined
            }
        }```


same like makeInMemoryStore

Always bind your events to save to SQLite

await store.bind(zk.ev);

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

Successfully merging this pull request may close these issues.

5 participants