Jump to content
UBot Underground

Recommended Posts

Ok don't laugh guys but i've never done multi-threaded bots (for real...) because i never had too so here is my first try.

ui drop down("Num. of threads", "1,2,3,4,5,6,7,8,9,10", #threadnumber)
ui open file("Get File", #getfile)
clear table(&test)
create table from file(#getfile, &test)
set(#resettablerow, $table cell(&proxy table, 0, 2), "Global")
loop(#threadnumber) {
    thread {
        in new browser {
            change proxy($table cell(&proxy table, 0, 2))
            set proxy credentials($table cell(&proxyusername, 0, 3), $table cell(&proxypassword, 0, 4))
            clear cookies
            navigate("https://www.whatismyip.com/", "Wait")
            loop while($true) {
                wait(5)
            }
        }
    }
}

accounts are listed as this (in a .txt file)

username1,usernamepassword1,201.221.91.61:47781,proxyusername,proxypassword
username2,usernamepassword2,49.49.39.181:36393,proxyusername,proxypassword
etc...

It's not working as the loop keeps going on.

Hey, remember that i'm just a musician LOL. This is way too much for me right now.

In fact, i want to learn to do something multi-threaded.

So i must be able to change the rows so it gets the next account (well  i think ?)

Link to post
Share on other sites

Couple of things.

 

There are some errors in your example code. You are using tables that don't exist. The only table you filled from the file is &test.

Your bot is opening exactly the amount of threads you select in your dropdown. That's working fine.

 

The bot will only end if you press stop because your loop while routine will loop forever.

 

loop while($true) {
                wait(1)
            }

 

 

Normally the Threads dropdown is used to define the amount of threads you want to run in parallel. Because you don't know how many entries your list / table might have. 

So you run 5 threads in paralell, until all entries from your list are processed.

 

I highly recommend that you use the free Threads Counter plugin with Ubot V4. That helps a lot. 

 

 

Here's an example of your code using the ThreadsPlugin and using the Dropdown as "max threads in parallel" option. I also removed the loop while ($true). So that it doesn't run forever :-)

 

 

ui stat monitor("Active Threads: "#active threads)
ui stat monitor("Table Position: "#TablePosition)
ui drop down("Num. of threads""1,2,3,4,5,6,7,8,9,10"#threadnumber)
ui open file("Get File"#getfile)
set(#active threads$plugin function("Threads Counter.dll""threads counter""reset"), "Global")
clear table(&test)
create table from file(#getfile&test)
set(#TablePosition, 0, "Global")
loop($table total rows(&test)) {
    loop while($comparison($plugin function("Threads Counter.dll""threads counter""read"), ">="#threadnumber)) {
        wait(0.5)
    }
    set(#active threads$plugin function("Threads Counter.dll""threads counter""increment"), "Global")
    threadcommand(#TablePosition)
    increment(#TablePosition)
}
define threadcommand(#position) {
    thread {
        in new browser {
            change proxy($table cell(&test#position, 2))
            set proxy credentials($table cell(&test#position, 3), $table cell(&test#position, 4))
            clear cookies
            navigate("https://www.whatismyip.com/""Wait")
            wait(1)
            set(#active threads$plugin function("Threads Counter.dll""threads counter""decrement"), "Global")
        }
    }
}

 

 

Hint: You should have the command you want to run in a thread in a define command. So that you can hand over the current position in your list or table to the thread command. 

You will see that in my example.

 

The two stat monitors will help you to watch what's going on.

 

If you have any questions, please let me know.

 

Cheers

Dan

  • Like 1
Link to post
Share on other sites

DAN i cannot thank you enough ! It is working perfectly. Nothing beats a code as tutorial to understand something as you can see with your own 2 eyes !

It wasn't working at first cause i didn't have the THREAD COUNTER plugin installed

 

I STRONGLY recommend you guys to paste DAN's code into your UB, to learn multi threading with private proxies.

It all comes clear after. Don't forget to add the THREAD COUNTER plugin first or you will get an error.

 

I really appreciate the time you took to arrange the script Dan (and all the others, i ain't forgetting you lol).

Heck this should be pinned !

 

Man i love this board and UBOT. Best move i made to expand my online biz trust me.

Cheers

 

EDITED:

There's only one thing left.

I just did a test using 4 threads and it worked perfectly but i then tried using only 2 threads (just after my first test) and it popped up 4 threads again. Like if it wasn't listening to the new rule/selection ? I will try to see what's wrong but if you guys know right away what is the problem, be my guess hahahaha

Link to post
Share on other sites

DAN i cannot thank you enough ! It is working perfectly. Nothing beats a code as tutorial to understand something as you can see with your own 2 eyes !

It wasn't working at first cause i didn't have the THREAD COUNTER plugin installed

 

I STRONGLY recommend you guys to paste DAN's code into your UB, to learn multi threading with private proxies.

It all comes clear after. Don't forget to add the THREAD COUNTER plugin first or you will get an error.

 

I really appreciate the time you took to arrange the script Dan (and all the others, i ain't forgetting you lol).

Heck this should be pinned !

 

Man i love this board and UBOT. Best move i made to expand my online biz trust me.

Cheers

 

EDITED:

There's only one thing left.

I just did a test using 4 threads and it worked perfectly but i then tried using only 2 threads and it poped up 4 again. Like if it wasn't listening to the new rule ? I will try to see what's wrong but if you guys know right away what is the problem, be my guess hahahaha

 

Hmm that's strange. Just tested it and it works fine for me.

I'm using Ubot V4.

 

I can even change it on the fly. And it will increase / decrease the threads.

 

Please let me know if you use V5 and I will test that as well. but at the moment V5 still has a couple of issues in some basic functions.

 

 

Dan

Link to post
Share on other sites

No i'm still waiting to use UB5. i'M USING ub4  for now.

I will try to compile it to see if it works fine.

 

Right now my txt file as only 4 private proxies to choose from with username/pass of course and like i said, i tried using 4 threads and it worked perfectly but not with 2 (or any oher numbers in fact) as it sticks to 4 threads no matter what. Odd that it works on your end ?

I'll try to compile right away.

 

Thanks

Link to post
Share on other sites

Wow this is really odd ?

If i select 2 threads (after trying with 4) it looks like it's working fine. Active threads stat monitor shows 2 Active threads but after a few secs, the remaining threads open up and stat monitor shows 0 ????

Go figure !

It's doing this on my end in UB4 and as compiled. Man i don't know why it's doing this ! I'll try to reboot.

 

 

 

By the way I added a 45sec wait time after it navigates to whatismyip.com so i have time to check out each popped threads, to see if it's using the right proxy/username/pass combination and that it loads fine. Cause if you don't, the threads "die" just after.

 

EDITED:

 

Ok i just reboot the hole thing and it's still doing this. Don't know what to try as it looks ok and you say that on your end it's working fine. Lucky me again hehehehehe. So if anyone knows what the issue could be, let me know

Thanks

Link to post
Share on other sites

The stat monitor shows the active threads variable. So when you select 4 and start the bot, It will always have 4 active threads. 

if one thread ends, it will start another one. Until your list / table comes to the end.

 

So when you change it to 2 in the UI, the thread monitor will remain at 4 as long as there are still 4 threads running. 

So if you have a 45 second pause, it will take 45second before the thread ends. Then you should see 3 and then 2.

 

And now it will only launch a new thread if one of the last two threads ends. 

 

So the stat monitor shows you how many threads are currently active. 

The threads are not automatically stopped when you reduce the thread max value.

 

Could that be the issue?

 

Dan

Link to post
Share on other sites

Humm ain't sure.

I just did another test which load a fresh copy of the compiled test bot and i selected 2 threads then ran it and it gave me 4 threads (i got 4 private proxies/username/pass in the .txt file)

So it's not taking in consideration whatever i choose from the pull down UI (num of threads) it's always 4 no matter what. I bet that if i add another proxy to the list it would generate 5 threads...

 

Dan, is it still working fine on your end ? I'm confused lol ! Why me MOM !

Link to post
Share on other sites

Please give it a try without the proxy stuff:

 

ui stat monitor("Active Threads: "#active threads)
ui stat monitor("Table Position: "#TablePosition)
ui drop down("Num. of threads""1,2,3,4,5,6,7,8,9,10"#threadnumber)
ui open file("Get File"#getfile)
set(#active threads$plugin function("Threads Counter.dll""threads counter""reset"), "Global")
clear table(&test)
create table from file(#getfile&test)
set(#TablePosition, 0, "Global")
loop($table total rows(&test)) {
    loop while($comparison($plugin function("Threads Counter.dll""threads counter""read"), ">="#threadnumber)) {
        wait(0.5)
    }
    set(#active threads$plugin function("Threads Counter.dll""threads counter""increment"), "Global")
    threadcommand(#TablePosition)
    increment(#TablePosition)
}
define threadcommand(#position) {
    thread {
        in new browser {
            clear cookies
            navigate("https://www.whatismyip.com/""Wait")
            wait(1)
            set(#active threads$plugin function("Threads Counter.dll""threads counter""decrement"), "Global")
        }
    }
}

 

 

And choose a txt file with 50 lines of:

username1,usernamepassword1,201.221.91.61:47781,proxyusername,proxypassword
username2,usernamepassword2,49.49.39.181:36393,proxyusername,proxypassword
username1,usernamepassword1,201.221.91.61:47781,proxyusername,proxypassword
username2,usernamepassword2,49.49.39.181:36393,proxyusername,proxypassword
username1,usernamepassword1,201.221.91.61:47781,proxyusername,proxypassword
 
And then test it. 
 
I'm running all my test without proxies because I don't have a proxy file with the correct format.
 
Give it a try with the exact code I posted above. Please let me know if that works.
 
Dan
Link to post
Share on other sites

This is damn weird ?

I tried without the proxy feature and using this text file

username1,usernamepassword1,201.221.91.61:47781,proxyusername,proxypassword
username2,usernamepassword2,49.49.39.181:36393,proxyusername,proxypassword
username1,usernamepassword1,201.221.91.61:47781,proxyusername,proxypassword
username2,usernamepassword2,49.49.39.181:36393,proxyusername,proxypassword
username1,usernamepassword1,201.221.91.61:47781,proxyusername,proxypassword

It opened up 5 threads ? Even tho i had chosen 2 from the UI pull down

 

Thanks

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...