Jump to content
UBot Underground

(Solved) simple scripting problem: checking to make sure logged in


Recommended Posts

ui stat monitor("login attempts", #loginattempt)
set(#status, $nothing, "Global")
set(#loginattempt, 0, "Global")
set(#site, 0, "Global")
ui open file("Sites to visit", #accounts)
ui stat monitor("status", #status)
create table from file(#accounts, &accounts)
to do()
define to do {
    loop($table total rows(&accounts)) {
        set(#url, $table cell(&accounts, #site, 0), "Global")
        login()
        increment(#site)
    }
}
define login {
    if($comparison(#loginattempt, "=", 3)) {
        then {
            set(#status, "3 Login Errors", "Global")
        }
        else {
            do login()
        }
    }
}
define do login {
    navigate(#url, "Wait")
    wait for browser event("DOM Ready", "")
    check login()
}
define check login {
    if($search page("Search Page")) {
        then {
            set(#loginattempt, 0, "Global")
            do task()
        }
        else {
            increment(#loginattempt)
            login()
        }
    }
}
define do task {
    load html("good")
}

I have created a sample bot.

 

Basically I have created a bot that I want to make sure I am logged in. if not try again up to three times. Bot dies and does not continue in loop after three successful non logins.

 

In the example above it navigates to a url in a table where you select file to use and then goes to site and searches for "search page" and if its not there it reloads the login script. is there a better way to do this as this is not working. 

 

Ubot studio Version 4.2.16

 

Problem solved

 

Correction below

ui stat monitor("site", #site)
ui stat monitor("login attempts", #loginattempt)
set(#status, $nothing, "Global")
set(#loginattempt, 0, "Global")
set(#site, 0, "Global")
ui open file("Sites to visit", #accounts)
ui stat monitor("status", #status)
create table from file(#accounts, &accounts)
to do()
define to do {
    loop($table total rows(&accounts)) {
        set(#url, $table cell(&accounts, #site, 0), "Global")
        login()
        increment(#site)
        wait(2)
    }
}
define login {
    if($comparison(#loginattempt, "=", 3)) {
        then {
            set(#status, "3 Login Errors", "Global")
            set(#loginattempt, 0, "Global")
        }
        else {
            do login()
        }
    }
}
define do login {
    navigate(#url, "Don\'t Wait")
    wait(5)
    check login()
}
define check login {
    if($search page("Search Page")) {
        then {
            set(#loginattempt, 0, "Global")
            do task()
        }
        else {
            increment(#loginattempt)
            login()
        }
    }
}
define do task {
    load html("good")
}

Link to post
Share on other sites

Try replacing the: 

 

wait for browser event("DOM Ready", "")

 

with something more substantial... DOM Ready is real quirky...

Link to post
Share on other sites

i replaced the wait for dom with a 5 second wait

 

it was a simple error

 

 

if($comparison(#loginattempt, "=", 3)) {
        then {
            set(#status, "3 Login Errors", "Global")
            set(#loginattempt, 0, "Global")
ui stat monitor("site", #site)
ui stat monitor("login attempts", #loginattempt)
set(#status, $nothing, "Global")
set(#loginattempt, 0, "Global")
set(#site, 0, "Global")
ui open file("Sites to visit", #accounts)
ui stat monitor("status", #status)
create table from file(#accounts, &accounts)
to do()
define to do {
    loop($table total rows(&accounts)) {
        set(#url, $table cell(&accounts, #site, 0), "Global")
        login()
        increment(#site)
        wait(2)
    }
}
define login {
    if($comparison(#loginattempt, "=", 3)) {
        then {
            set(#status, "3 Login Errors", "Global")
            set(#loginattempt, 0, "Global")
        }
        else {
            do login()
        }
    }
}
define do login {
    navigate(#url, "Don\'t Wait")
    wait(5)
    check login()
}
define check login {
    if($search page("Search Page")) {
        then {
            set(#loginattempt, 0, "Global")
            do task()
        }
        else {
            increment(#loginattempt)
            login()
        }
    }
}
define do task {
    load html("good")
}
 
Link to post
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.

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.

Loading...
×
×
  • Create New...