gramjs icon indicating copy to clipboard operation
gramjs copied to clipboard

Multiple session qr

Open thaziz opened this issue 3 years ago • 6 comments

I found a bug, so I used qrcode login and used multiple sessions, when session 1 was successfully scanned and session 2 had not been scanned, if the sessions are run sequentially there is no problem, but if session 2 I run it first than session 1 then session 1 asks for a re-scan

thaziz avatar Feb 15 '22 15:02 thaziz

This is very complicated, can you provide some code to go with it?

painor avatar Feb 15 '22 15:02 painor

This is very complicated, can you provide some code to go with it?

this is my code. I run in order

tele()
tele2()

then I scanned for tele() and connected successfully. and for tele2() I didn't scan it, then I stopped node js and changed it

tele2()
tele()

but what happens tele2() and tele() ask for both scans. tele() shouldn't need to scan because it's already scanned. I hope you understand what I mean sir, thank you

const tele = async () => {
    const client = new TelegramClient(new StoreSession("tele"), apiId, apiHash, {});
    await client.connect();
    if (!await client.isUserAuthorized()){
        await client.signInUserWithQrCode({ apiId, apiHash },
            {
                onError: async function(p1) {
                    console.log("error", p1);
                    // true = stop the authentication processes
                    return true;
                },
                qrCode: async (code) => {
                    console.log("Convert the next string to a QR code and scan it");
                    console.log(
                        `tg://login?token=${code.token.toString("base64url")}`
                    );


                },
                password: async (hint) => {
                    // password if needed
                    return "1111";
                }
            }
        );
    }

    console.log("You should now be connected.");
    console.log(client.session.save());
    await client.sendMessage("me", { message: "Hello!" });
  }
const tele2 = async () => {
    const client = new TelegramClient(new StoreSession("tele2"), apiId, apiHash, {});
    await client.connect();
    if (!await client.isUserAuthorized()){
        await client.signInUserWithQrCode({ apiId, apiHash },
            {
                onError: async function(p1) {
                    console.log("error", p1);
                    // true = stop the authentication processes
                    return true;
                },
                qrCode: async (code) => {
                    console.log("Convert the next string to a QR code and scan it");
                    console.log(
                        `tg://login?token=${code.token.toString("base64url")}`
                    );


                },
                password: async (hint) => {
                    // password if needed
                    return "1111";
                }
            }
        );
    }

    console.log("You should now be connected.");
    console.log(client.session.save());
    await client.sendMessage("me", { message: "Hello!" });
  }
tele()
tele2()

thaziz avatar Feb 16 '22 14:02 thaziz

@painor helpme sir

thaziz avatar Feb 17 '22 12:02 thaziz

@thaziz Please have patience, everyone might not be as free as you are.

rojvv avatar Feb 17 '22 13:02 rojvv

Hallo sir can yo helpme

thaziz avatar Apr 23 '22 20:04 thaziz

is this still an issue in the latest version?

painor avatar Apr 23 '22 21:04 painor