“ I understand the difference between functions and commands, but I’m still kind of unclear on parameters. Not sure if i can or should use them to send or receive data, when the proper time to use them might be (as opposed to just using a “Set” value within a simple command define to retrieve data) and so on.. “
And I think that’s an excellent question. I can see why you may not understand why we should ever use parameters and by the end of this video you are going to hopefully not only understand why we need them but also start to use them all the time.
Now before we begin I have a little announcement, I just launched Elite Botters, so the website is now live. And so is our first course, it’s called Ubot Studio: Mastering The Fundamentals.
This course is designed to get you from wherever you are right now to a solid understanding of the fundamentals.
And we have some super cool features like fun quizzes, video search and more. So be sure to check it out, there is a link in the description below.
Now what exactly is a parameter and why should you care?
In this context we are talking about parameters which can be defined when you create a custom command or function. To do that you can just drag out the define command and then you will see a section for parameters.
You will notice that parameters have a purple background, this means that its a variable input field, so whatever name you put here will turn into a new variable.
Now it should be noted that this variable is a local variable. And that means that only things inside of the command or function you are making can see it. So that means that you won’t see its value in the debugger.
For this reason, I like to preface it with an underscore, this tells me that it’s a local variable and when I am looking in the debugger I won’t expect to see values for local variables.
So now that you have a rough idea of what a parameter is – let’s talk about why you would want to use one over just a normal set.
And the reason is because it makes the custom command or function independent. So that is to say that it doesn’t need to rely on some outside source of information. Instead, it can take in information and then use it in some way.
Now that probably won’t make too much sense if you are new to Ubotting or programming in general. But don’t worry, this is one of those things that’s better to show rather than tell, so with than in mind lets go over some examples.
Let’s create a custom function which adds some bank balances and returns the result:
Now in this example we are not using parameters, however, as you can see when we run the program, it works!
So, this isn’t making a great case as to why we should use parameters, but let’s see what happens when we want to introduce two new account types.
In this example let’s just say the person has money invested in crypto currencies as well as a stock portfolio and we want to get a combined total of those extra accounts as well.
Well right now our function only adds together the balances of the checking and savings accounts, because it is dependent on those variables. In order to add more accounts we would have to go in and either make another function, change this one or update those variables.
Instead of doing all that extra work, we can actually use the same function. But now we can use parameters to make it more independent and not have to rely on specific variables being set before.
So let’s change our function to now accept parameters so you can see the difference.
Now that we changed it we have to also update the function in our combined balances variable.
So it still works with combine balances, now let’s try it with the extra accounts as well.
As you can see, now that we are using parameters we can use this function whenever we need to add two things together!
With that in mind we can actually take this one step further and also add up the combined balances and combined extra balances to get a total of all the accounts together, all by using the same function!
Now I already know what some of you are thinking, “Why can’t I just always use the same two variables and set them before using the function?”
And the reason is because this will not work in a multi-threaded environment. You can’t set global variables from several threads at once and then send them through a function like this because your data is going to get corrupted. So while this may technically work in a single threaded environment, it’s just bad practice.
So as you can see using parameters can be really powerful. We took a function which was not using parameters and relied on variables being set before, this was only able to add two specific variables together. And then we added parameter so that now it can add any two values. Doing this allowed us to use the function three times in the same program!
If you liked the video be sure to tell me in the comments below.
And be sure to check out our new course Ubot Studio: Mastering The Fundamentals, the link is in the description below.
That’s it for this video and I’ll see you in the next one!
In this video I want to talk about 3 useful functions in Ubot Studio that you may not know about and cover some examples of how and when to use them. This video is going to be a bit different than normal so be sure to leave a comment if you like the format or even if you don’t like it. Your feedback is always welcome and it helps me craft better videos for you.
So let’s get to it and dive right in with #3
The third useful function is called pad text, this can be found under the text functions section. Pad text will return your original text padded with a character. This means you can add a character to the start or end of your original text. You can also ensure that the text is a certain length.
This may sound pretty useless and I think it’s often overlooked but it does have some special use cases and I want to go over one that comes up from time to time.
Let’s say that you needed to have a series of numbers 1 to 100 in our case and they always need to be 3 digits. So the first number is 001 and the next is 002 and so on.
This is when pad text is going to be useful. You can pad the numbers with a 0 character and set the desired length to be 3. Pad text does all the heavy lifting and will ensure that if the digits are less than 3 a 0 will be added to the side you specify.
While pad text may not be something you use in every bot, the next function I want to talk about is something you are going to want to use all the time.
The second useful function is actually two functions. But they are so similar that I want to talk about both of them together.
I am talking about the is blank and is number functions, both of which can be found in the bot bank under the advanced text section.
Now don’t worry if you don’t have access to the bot bank because I will show you a workaround for these. But if you do have access to the bot bank then these functions are quick and easy to use and will speed up your coding.
Is blank simply looks to see if the text to check is either blank or white space, if it is then it will return true. This is a great way to validate user input. You can ensure that your user entered something for the field you want to check.
You can also use it for other purposes such as seeing if the text you scraped is blank.
Is number will check to see if the text to check only contains numbers. This is another great function to use for input validation. If you expect your user to enter a number into a field you can use this function to ensure they entered a number and not something else.
Another use is to ensure what you are scraping is a number. If you expect a number and get something else that may be a sign that something has gone wrong and your bot can self correct itself or maybe send you an email saying something isn’t quite right.
Now I’ll show you some work around.
For is blank you can simply use a comparison function and check to see if the first value equals nothing. This is pretty quick and easy so if you don’t have access to the bot bank it’s just a little bit of extra work to do this.
However, if you want to check for a number it’s going to be a bit more involved.
What you can do is use a comparison function again, but this time in the first value you will need to use a regular expression. You can use a backslash, then the letter d for digit and then a plus sign. This will look to see if there is one or more numbers.
Then use the equals sign as the condition and for the second value put the text you want to check in there as well.
This will check to see if there is one or more numbers and if so will return them to the first value. Then if the first value equals the second we know that the text only contains numbers. If the text contains anything else then the first value will be shorter than the second.
And now I want to talk about the number one useful function you may not know about. That is subtract lists which is located under the data functions section.
Subtract lists will allow you to remove items from one list based on another. It does this by returning the unique items from the first list, so that you can add those to another list.
It’s probably easier to just show you how this works rather than trying to draw out an explanation.
So these are a few functions you may not have known about before. This video was a bit different so If you liked this format be sure to leave me a comment and let me know. Also, be sure to subscribe to this Youtube channel so you can get updates and check out Elite Botters dot com as well.
Thanks for watching and I’ll see you in the next one!
In this video I want to cover the latest update for version 5.9.55. There were a couple of small fixes as well as a bunch of new commands and functions added.
So let’s dive right in.
The first issue was regarding drag and drop not working properly in the last version. This was referring to dragging elements from the browser into the scripting area.
In the past I’ve been able to crash the browser by using this feature on certain web sites. I have checked in this version and replicating that does not crash the browser any more. Also, the responsiveness feels good when using this feature now.
That being said I’ve only used it a little bit and so it’s’ hard to say how well it really works just yet.
In fact I suggest not using this feature if you can help it because of the problems it’s had in the past. Instead, you can drag out the command you want first and then use the element selector.
But if dragging from the browser into the scripting area is more comfortable for you then hopefully this update solves the issues it’s been having.
The next update addresses the issue of playing videos on Facebook and Vimeo. One of the examples is: https://vimeo.com/227890020
And it looks like it plays just fine.
Finally, the bot bank had duplicate items showing, and this has now been fixed as well.
That wraps it up for the bug fixes, all around pretty minor but at least it’s a step in the right direction.
There are a bunch of new commands and functions in this update for audio as well as images. These are a nice addition since we already have a bunch of video commands – although people have had issues with those video commands.
Now all of these are in the bot bank and so you will only be able to access them if you are subscribed to updates.
However, that being said these commands along with the video commands are all using libraries which support command line operations. So that means you can basically do all of these commands on your own by using the shell command.
I can’t get into that in this video but what I will say is this.
The video commands use FFmpeg. And you can use the shell command to call the ffmpeg.exe along with some command line arguments, these arguments can be looked up online.
The image libraries are ImageMagick.
And the audio is using Lame and SoX, and that is spelled S – O – X
Again you will need to look those up but generally they just involve using the shell command and some arguments.
So the first thing you need to do when working with these commands is to ensure that you have the libraries, and you can use the verify audio, image and video library commands to do that.
Now there is a lot to cover in regards to the new image and audio commands, and I haven’t had enough time to dive deep and test them out. But I can at least show you most of them and hopefully you can see what’s possible and get some ideas from it.
I showed most of the commands and functions in this video but I encourage you to explore these features further. There’s quite a lot here so hopefully you find it useful.
That’s going to do it for this video, I’ll see you in the next one.
In this video I am going to show you the exact process I take to do multithreading in Ubot Studio.
I have used this technique in hundreds of bots, including the account creator we are going to make today.
I see people asking on Ubot forums all the time about multi threading and using Thread Spawn, and so I wanted to make a video showing you the right way to do multi threading in Ubot Studio.
The truth is that you don’t need thread spawn in order to do multithreading and doing it the right way gives you more control over the process. More control is better because it can lead to less errors and headaches later on. I know multithreading can be scary to some but I will break it down and show you that it’s pretty straight-forward and easy to do.
So let’s jump right in and learn the exact process I use.
Today we will be making an account creator for a form on the Ubot Playground.
First of all I am going to get rid of all this code so that we can make this together step-by-step.
Before we begin we need to list our requirements for this project:
- We need to make an account creator for the simple form on Ubot playground.
- This account creator should be able to be ran multi-threaded
- We should be able to control the thread count, it should not be fixed
- Accept a number of accounts to create
- Use random account information for the username and password fields
- First name, last name, and about me fields are spun text
- Save the username and password to a list
As you can see we have a number of specific requirements that should be met for this project.
So let’s get started.
The first thing I always want to do when creating a multi-threaded program is to make the core part of the program, and test that to ensure that it works before adding any multi-threaded logic.
Once the program is multithreaded you don’t want to do any major debugging. In fact the only debugging you should be doing at that point should be related to the multithreading logic itself, and not the core of your program. If you find any problems with the core of your script then copy it out from the multi-threaded environment so that you can properly debug it.
With that in mind let’s make the core part of the program, and in this case it’s pretty simple, we need to go to a webpage and fill in a form.
Recall that requirements 5 and 6 have to do with the information to be filled in. Requirement 5 states that we should “Use random account information for the username and password fields” and 6 says “First name, last name, and about me fields are spun text.” We can take care of that part now, and then later modify it for multi-threading.
Our last requirement says that we need to save the username and password combination to a list, we can also do that now.
Now we have the core of the application, the part that is doing the actual work. So now we should run this a couple of times to be sure we get the expected results.
In the real world your application would be much more complex than this. You would want to have built in logic to solve problems such as:
- Info already taken such as username, or email
- Invalid passwords
- Failed captchas
- And more
For now we want to keep it as simple as possible just to demonstrate how multi-threading works, so with that in mind we won’t be doing any more than this.
So let’s run it a couple of times and make sure it does everything we expect.
Now we can fulfill requirement number 4 which was to accept the number of accounts to create. This is simply just going to be the number of times we loop.
Because I know that we are going to multi-thread this I am going to save some time and put the main process in it’s own custom command. For more complex programs you may already have done this, and you should be doing this if you are not yet.
Now I can just drop the custom command into a loop and add the user input.
We can give this another test to ensure we still don’t have any problems.
Now that we have the core of our program we can now work on the multithreading part. Multithreading scares a lot of people because they think that it’s complicated. But I don’t want you to think about it that way. Remember that at this point we have already made the core of the program and we know that it works. Now all that is left is creating a little bit of code to manage how many threads can run at once.
To accomplish this we only need a few simple things:
- We need to know how many threads can run at once
- We need to limit the application so that it does not exceed that number
- And finally, we need to know when a thread starts and ends
And that is really all there is to it. When you break down multithreading it’s not really all that complicated. Our job is to make sure that no more than a certain number of threads are running at the same time. And to do that we only need to use a little bit of code.
Now the first thing we need to do is make sure that we know how many threads the user wants and to accomplish this task we can use a dropdown. We use a drop down here because that way we can control the input. Not only are we limiting the input only to numbers but we can also specify a minimum and maximum thread count.
Now that we know the thread count our job is to simply ensure that the number of open threads does not exceed that number.
So let’s first ensure that the part we want to be multithreaded – is in a thread.
We need to keep track of the open threads so that we don’t exceed the max thread count. To do this we can simply use a variable.
So far we already know how many threads to run and we already know when a thread begins and ends. Believe it or not were already almost done, now all we really need to do is limit how many threads are open at once and we can do that using a loop while.
So you are going to want to put this above the increment.
This loop while is the heart of the multithreaded code, it controls how many threads are open at one time.
Now that is basically it, however, there is a few extra bits we need to add to really make this work well in all situations.
The first is really important, we need to put a small wait after we create a new thread. This is going to make sure everything runs smoothly and will essentially eliminate any errors that you would normally see while multithreading.
And finally, once our main loop is finished we will likely still have open threads. So typically you want to wait until all threads are finished before letting your program continue.
To do this we simply put a loop while after the loop which contains your multithreaded logic.
And that’s all there is to it. Now our application will allow the user to specify the number of threads and the program will not exceed that number. When the main loop is finished the program will wait for all threads to finish as well before continuing.
And now that our program is multithreaded we can give it a shot.
At this point we have fulfilled our 7 requirements. We have made an account creator and then multi-threaded it. The program accepts a number of accounts to create as well as the thread count. We are using random account information and save off the username and password to a list.
The multithreading part was achieved simply by accepting a maximum thread count and then managing it with a loop while. We kept track of when threads open and close simply by incrementing and decrementing a variable. And when our main loop was finished we waited for all threads to finish before allowing our script to continue.
I hope you can see that multithreading is fairly straight forward and easy to implement. If you liked this video please feel free to like and subscribe and don’t forget to check out Elite Botters.com as well.
That’s going to do it for me for this one. If you have any questions leave them in the comments section below and I’ll see you in the next video.