How to do this in OB2!

i did this on OB1

IF "<IsTokAlive>" EqualTo "yes"
JUMP #Continue
ENDIF

REQUEST GET "https://example.com/api/get-cookie"
...

SET GVAR "TOK" "<COOKIES(TOKEN)>"
SET GVAR "IsTokAlive" "yes"

#Continue
REQUEST GET "https://example.com/api/check/<DATA>/"
  COOKIE "TOKEN: <TOK>" 

IF "<RESPONSECODE>" EqualTo "401"
SET GVAR "IsTokAlive" "no"
SET STATUS RETRY
ENDIF

KEYCHECK 
...

How can i do the same in OB2?

IF BOOLKEY @globals.IsTokAlive Is true
JUMP #Continue
END

// Request block

...

LOCK globals
globals.TOK = data.COOKIES["TOKEN"];
globals.IsTokAlive = true;
END

#Continue
// Request block here, use <globals.TOK> instead of just <TOK>

IF INTKEY @data.RESPONSECODE EqualTo 401
globals.IsTokAlive = false;
data.STATUS = "RETRY";
return;
END

// Keycheck block here

Something like this, I didn’t test it

ERROR, Can’t run the config
image

add any request block and try it yourself, can’t even run it
because OB2 need @IsTokAlive to be declared before using it

TRY
IF BOOLKEY @globals.IsTokAlive Is true
JUMP #Continue
END
CATCH
END
1 Like

Can i do same, but each bot have it’s own cookie?
not only 1 cookie be shared to all bots

No that’s not possible in OB2, or at least not easily. Why do you need to do that anyways?

Can’t do that for real?
can’t we share a List in Globals and use that like globals.cookieslist[<BOTNUM>]
BOTNUM is for OB1, idk is there a unique thing for each bot in OB2 or not

but what is the usage?
more CPMs, less BANs, less requests, less pressure on the target, less bandwidth/traffic
Also useful for scraper or some special configs

There is not BOTNUM in OB2 because the threading works differently. In OB2 there was 1 background worker per bot which was constantly running, while here I’m using asynchronous tasks, and a new one is created for each line of the data pool.

so there is no variable with unique value for each bot?
can’t you add something like that? a unique variable for each bot?

and then, if we had that, could we done the job?

As I said, there’s no “bots” like in OB1.
Take this example: 4 lines, 2 bots

OB1 was like
bot 1 → process line 1 → process line 3
bot 2 → process line 2 → process line 4

in OB2 it’s
task 1 → process line 1
task 2 → process line 2
task 3 → process line 3
task 4 → process line 4

The “bots” amount in OB2 just defines how many tasks can be active at the same time. The tasks are destroyed as soon as the line finishes processing so there’s no persistence from 1 line to the other, the only way is to use global variables but you can only set 1 token unless you use a queue or something, but it’s not something the average user can write.