Jump to content

ResponseCode usage


sudoinit6

Recommended Posts

35 minutes ago, Lemons said:

So your mistake is thinking ResponseCode.isDisabledError knows the response code. It does not, it only checks the given response code (and your always giving 4 and 18, so its always true on any response code). Simple misunderstanding, those have bit all of us in the ass at some point.

 

That makes perfect sense. Thanks again for your help.

Link to comment
Share on other sites

With lemon's help I found a way to make it work without a custom login handler, at least well enough to suit my needs here is what I did:

Spoiler

@Override
    public
     void onResponseCode(int responseCode)
            throws InterruptedException {
        if (ResponseCode.isDisabledError(responseCode)) {
        
            log("Account locked");
            try {
                log("trying to create text file.");
                PrintWriter writer = new PrintWriter(
                        
                        "/root/OSBot/Data/lockedAccounts.txt",
                        "UTF-8");
                writer.println("FIGJAM");
                writer.close();
            } catch (IOException e) {
                log("creating text file failed");
                // TODO Auto-generated catch block
                e.printStackTrace();
                System.exit(0);

            }
            System.exit(0);
        }if (ResponseCode.isConnectionError(responseCode)){
            log("login failed");
            try {
                log("trying to create text file.");
                PrintWriter writer = new PrintWriter(
                        
                        "/root/OSBot/Data/failedLogin.txt",
                        "UTF-8");
                writer.println("FIGJAM");
                writer.close();
            } catch (IOException e) {
                log("creating text file failed");
                // TODO Auto-generated catch block
                e.printStackTrace();
                System.exit(0);
        }
            
    }
}
}

What this does is write one file if the error type is disable error but a different file if it is a connection error (although I don't really need to write the second file).

 

Before it was executing my code on any error because I was passing thorough something that would always match. With this code it checks to see what kind of code it is, if it isn't a disabled code, it doesn't execute my instructions in the first section (which include an exit) and moves to the second. Since the second doesn't include an exit, the default login handler handles it like a normal connection error and waits 17 seconds to try again. Hopefully someone else can find use out of this.

 

Thanks Alek and lemons!

Edited by sudoinit6
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...