Execute IF statement based on the result of a keycheck



  • Basically , I'm making a config for some automation (all legal ofc 🙂 , site is owned by me and just basic testing). I want to run a keycheck and then execute an if statement based on the result of that keycheck.

    If keycheck = success
    do *something*
    else
    do *something else*
    end if
    Something very simple like that , I've obviously looked at the documentation for loliscript but just don't see anything about implementing the keycheck function here.

    I've tried implementing a variable in the keycheck block , e.g once it finds ("this") set variable to "true" or "false". The config refused to run with that in. So thought i'd come here to help.

    TL;DR How do I execute an If statement based on the result of a keychecl


  • Admin

    The keycheck block will make a bot stop executing the script when the resulting status is different from NONE or SUCCESS, so it's not the best way to approach this. I suggest instead using an IF statement, for which you can find documentation directly inside the program (Stacker -> Switch to LoliScript view -> Click on the Documentation button at the bottom -> Go to the Flow Control section and check out the IF ELSE paragraph).
    Basically (in loliscript view) you want to write something like this

    IF "<YOURVARIABLE>" Contains "abcd"
    anything you want here (blocks, other code)
    ELSE
    same as above
    ENDIF
    

    For the keycheck instead you have to go to the Blocks section of the LoliScript documentation and you will find a syntax like this one:

    KEYCHECK
      KEYCHAIN SUCCESS OR
        KEY "hello"
        KEY "<YOURVARIABLE>" Contains "abcd"
      KEYCHAIN FAILURE AND
        KEY "2" GreaterThan "1"
        KEY "<YOURVARIABLE>" DoesNotExist
    

    but always remember that after a FAIL status, the bot will stop running! So you should approach this purely using IF statements (if you put one after the other, they will need to all be verified at the same time)

    IF "<a>" Contains "abc"
    IF "<a>" Contains "def"
    other stuff
    ENDIF
    

    the above will do "other stuff" only if all of the IFs were verified. It corresponds to doing a.Contains("abc") && a.Contains("def") in any modern language.

    Obtaining an OR is a bit trickier but can still be done like this

    SET VAR "result" "false"
    
    IF "<a>" Contains "abc"
    SET VAR "result" "true"
    ENDIF
    
    IF "<a>" Contains "def"
    SET VAR "result" "true"
    ENDIF
    
    IF "<result>" EqualTo "true"
    run your code here
    ENDIF
    

    "your code" will only be run if any of the previous IFs was true. The code above is equivalent to doing a.Contains("abc") || a.Contains("def") in a normal programming language.

    Remember that LoliScript is assembler like so you cannot do very complicated stuff, or actually, you can do it, but it's gonna take a lot of instructions!

    As a last note, if you are instead looking to just make an IF between a SUCCESS or NONE response from the keycheck, you can simply use the fixed <STATUS> variable which will contain the status of the bot (the one you see in the Data tab of the debugger). So you can do

    IF "<STATUS>" EqualTo "SUCCESS"
    stuff to do upon SUCCESS
    ELSE
    stuff to do upon NONE
    ENDIF
    


  • Thanks for the guide @Ruri , I would've been there ages without that and I got it all sorted in well under 30 mins ❤ One thing , once all the IF Statements have been completed and I'm ready to execute the Keycheck on Success or Fail etc.. Like you suggested I'd be using a variable (Result = true / false)

    (Bit of background incase your confused) I'm submitting a post request on one part of the site , if it's a hit : Changing a "Success?" variable to true . If not , I'd set "Success?" to false. Then submit a post request on a completely different area of the site.

    
    
    IF "<RESULT>" EqualTo "true"
    #command for manually changing keycheck to success
    ELSE
    #command for manually changing keycheck to fail
    ENDIF
    

    Not sure if I'm being thick here


  • Admin

    You can easily do it with LoliScript commands (the documentation is inside the program)

    IF "<RESULT>" EqualTo "true"
    SET STATUS SUCCESS
    ELSE
    SET STATUS FAIL
    ENDIF
    


  • @Ruri Yep ty , that was obvious . Don't know why I didn't think of that. But thanks very much for your help ❤



  • @Ruri
    didn't want to open a new topic, since you're already explaining "set status" here.
    just a quick follow up question:
    is it possible to set a "tocheck" status?
    i tried

    SET STATUS TOCHECK
    

    but that was invalid.
    or will i have to use a custom status for that?

    i think it would be helpful for debugging work, since you could easily evade the ban loop without having to change ban loop evasion-settings.


  • Admin

    @l2aze-Em TOCHECK is actually called NONE. Bot status and final result of the check are sometimes named differently, that's a choice I made at the beginning of the project and could not change due to the impact it would have on existing configs.



  • @Ruri
    thanks for the reply.
    well... i kinda already knew about NONE.
    but if i change status to NONE - which IIRC is the bot's starting status anyway - the combo in question won't be sent directly to ToCheck ...right?!
    instead the rest of the config will be executed. no?
    so, seems like i will have to use a custom "tocheck" status for my debugging...
    would have loved to avoid this, since i already got a few custom status and being able to use the ToCheck-tab would have been an easier to spot red flag.
    welp, thanks nevertheless. ^^


  • Admin

    You can easily do this

    SET STATUS NONE
    JUMP #END
    
    ... other blocks ...
    
    ## Dummy block that serves as hook for the jump
    #END Function Constant ""
    


  • ...ok...
    i think i'm confused now...
    can you explain to me how the ban loop works/what it does?
    cuz i thought it causes retries if the bot ends with the NONE status.
    so it's nice to have a jump to the end of the config
    ( btw. the dummy block is particular informative, as it would have taken me quiet some time to figure that out^^ )
    but the combo would still be retried (at least if i understood the banloop correctly).
    and to avoid any additional missunderstandings:
    i know about the ban loop evasion setting and that i could set it to a very low value (e.g. 1).
    thing is, i don't like having to change my global OB settings every time i'm debugging a config.


  • Admin

    The ban loop, for me is when a website replies with something e.g. "The item does not exist" that you did not put in a keycheck block. Anything that's not caught by the keys, is going to be marked for BAN (if the "ban if no key found" checkbox is checked of course). So that could mean an endless loop since the item does not exist regardless of what proxy is being used. Ban loop evasion is meant to interrupt that, so that the data can go to "To Check" and you can easily spot what happened through bot log inspection and add that key to the config so it doesn't happen again in the future.
    It's actually good to keep this setting on at all times, on a high value like 100.



  • In maybe simpler/other words:
    You get "invalid request" or something like that when you post special characters you haven't thought of when making the config and selected "ban if no key found" on Keycheck

    Before the Ban loop evasion:
    One or multiple lines from wordlist could "block" some bots with retrying and banning proxies.
    And you notice that the runner seems to get slower and slower over time and on start and resume it is fast again
    This is because these lines which are on a endless loop are then skipped...

    Now these go to ToCheck after the configured number of tries on the same linel



  • @Ruri @meinname
    thanks you two!
    EDIT:
    sry for wasting your time! i'm a retard ~lol~
    but playing this whole thing through helped me understand what i have to do to get it to work ~yay~^^
    thanks again and sry for being stupid 😄


  • Admin

    @l2aze-Em everybody has to start somewhere, no problem! Feel free to ask anything, it's rather unusual to find someone as polite as you these days ^_^



  • @Ruri
    thanks for the compliment 😄
    well, i know how busy you guys must be, so i try to keep my stupidity to a minimum^^


Log in to reply