[PoC] How to use a Dedicated Bot
meinname last edited by Ruri
As the old BB Forum is closing soon and don't want to get this great guide by ruri not get lost here a copy and paste - maybe some small things need to be changed as it was written for the old BB Loliscript
This guide is meant for advanced config makers.
This concept will assume you have to get a specific authorization token (or maybe a cookie) at the start of the config and then use that token with all the bots for all the following checks.
## First of all we instantiate the global variable that will hold the authorization ## we assign it the value NONE by default. This is only executed the first time. SET NEWGVAR "AUTH" "NONE" ## If the bot is number 1 (note that in debugger the bot number is 0 so this won't work) IF "<BOTNUM>" EqualTo "1" ## We use 2 IF statements one after the other in order to verify them both IF "<AUTH>" EqualTo "NONE" ## In this case bot is #1 and we don't have an auth yet, so we go get it! JUMP #GETAUTH ENDIF ## If we didn't jump to GETAUTH, it means we have to skip over it JUMP #SKIP ## This is the section where we get the authorization (just an example one) ## We need to use a label here to identify this cause we jump to it earlier #GETAUTH REQUEST GET "http://example.com" PARSE SOURCE LR "Authorization=" ";" -> VAR "LOCAUTH" ## Now we push the local authorization to the global variable SET GVAR "AUTH" "<LOCAUTH>" ## This is just a dummy block so we can skip over the part above #SKIP FUNCTION Constant "" ## Now we wait until bot 1 succesfully sets the authorization, then we can proceed WHILE "<AUTH>" EqualTo "NONE" FUNCTION DELAY "1000" ENDWHILE ## Do the normal check using the authorization that was set by bot 1 on the first round! REQUEST GET "http://google.com" PARSE ... KEYCHECK ...
What can be improved:
- You can put a timeout inside the while loop so it doesn't loop infinitely, just set a local variable to 0 and increase it by 1 inside the loop. Then add another WHILE statement (e.g. that the variable is less than 10) just below the first one so both will be verified!
- If the AUTH expires, set it back to NONE so the bot #1 will grab a fresh one on its next sweep (just do an IF "<SOURCE>" Contains "something" SET GVAR "AUTH" "NONE" ENDIF)