Jump to content
UBot Underground

Creating Complex Robots the Super Easy Way!


Recommended Posts

Hey guys and gals. Time as come to finally post a tutorial on something that I've been asked about many, many times.

 

How does one manage a large complex bot for the long term? Easy - break it into manageable pieces.

 

I'm a firm believer that a video speaks better then what I can type, so you can watch the low res version here or go to www.ubotjunkie.com and check out the two part video series I created on this specific topic.

Part 1 of 2 of Advanced Ubot Tutorials on UbotJunkie.com

Part 2 of 2 Advanced Ubot Tutorials on UbotJunkie.com

 

http://www.youtube.com/watch?v=WkvWvooK-mg

http://www.youtube.com/watch?v=7K463FKR51M

 

Enjoy!

 

Oh, please feel free to post questions right here if you have any. ;)

 

Frank

  • Like 3
Link to post
Share on other sites

Videos teach you programmers tricks of the trade, why remake something you already made... just call the function! err sub.

 

Overall great stuff worth checking out if you have 0 programming experience.

Link to post
Share on other sites

Yes, the main reason for this tut was to present a way to simplify larger bots. I've had several ask how to do this - even experienced bot programmers.

 

Cheers,

 

Frank

  • Like 1
Link to post
Share on other sites

Hi Frank

 

Good idea with the .dll and also the stat monitor on the subs gave me a few tips thx always do the error checking to a log file but never thought of the stat monitor on subs learn something new everyday

 

Pftg4

Link to post
Share on other sites

Thanks for the tutorial Frank!

 

So I haven't used the Parameter function up till now, thanks for pointing that out. So there's a couple ways of setting variables:

 

SET: I thought this was the way to set it globally. (i.e. used in other scripts if I link/import them)

SET LOCAL: This is only good for the script your running

PARAMETER: If this sets things globally, couldn't I use this to set all my variables as I build things, just in case I want to break up my Ubot later?

 

When would I use SET and when would I use PARAMETER?

 

* I was waiting for the funny message after all that black on the end of tutorial 2. What gives? :-)

Link to post
Share on other sites

SET: I thought this was the way to set it globally. (i.e. used in other scripts if I link/import them)

Yes.

 

SET LOCAL: This is only good for the script your running

Use Set Local if the variable is only used locally, for example within a Sub, and nowhere else.

 

PARAMETER: If this sets things globally, couldn't I use this to set all my variables as I build things, just in case I want to break up my Ubot later?

Use a Parameter to pass a variable's value to a Sub.
Link to post
Share on other sites
Use a Parameter to pass a variable's value to a Sub.

 

OK, this is what's confusing me. I thought anything in a sub would be part of the "global" variables that are created when you use SET.

 

So if I want to create and use subs liberally in my Ubots, I SHOULDN'T be using SET, but PARAMETER? (which at this point I will be using subs within everything) Are subs some sort of exception to the rule? (other than having to include a RUN SUB within a bot)

 

When do I want to use the PARAMETER command? (again)

Link to post
Share on other sites

Hey Frank. Nice job. I have one question about passing variables to a new bot (include).

 

If the global variables are passed throughout the current script (bot) by way of a subroutine, couldn't you simply re-use THAT sub immediately preceding the external bot?

 

For example:

 

If my bot creates accounts. I have a script that sets all the user information (username, password, email, etc). I do this by putting that process in a subroutine (say, "set login information"). This script includes the first 25 sites (of 100) so the variables set will automatically pass to those first 25 sites.

 

Now I have 25 sites in bot A, 25 sites in bot B and 25 sites in bot C

 

So when I "include bot A" I would need to run sub "set login information" again just before running bot A?

 

(and then again before bots B and C?)

 

Thanks,

 

John

 

BTW, on the surface I would think that creating a table with this data would eliminate the need to "re-pass" variables simply by calling data from table cells, right?

Link to post
Share on other sites

OK, this is what's confusing me. I thought anything in a sub would be part of the "global" variables that are created when you use SET.

Yes, setting a variable in a sub will make it global.

 

So if I want to create and use subs liberally in my Ubots, I SHOULDN'T be using SET, but PARAMETER? (which at this point I will be using subs within everything) Are subs some sort of exception to the rule? (other than having to include a RUN SUB within a bot)

One use of Subs is to use them like functions are used in other programming languages. For example, pass in variables values as parameters, and the Sub does some work (e.g. a sum) and if required may also return a value. Using Subs will help to separate your code/bot into manageable chunks.

Link to post
Share on other sites
  • 2 weeks later...

Hey Frank. Nice job. I have one question about passing variables to a new bot (include).

 

If the global variables are passed throughout the current script (bot) by way of a subroutine, couldn't you simply re-use THAT sub immediately preceding the external bot?

 

For example:

 

If my bot creates accounts. I have a script that sets all the user information (username, password, email, etc). I do this by putting that process in a subroutine (say, "set login information"). This script includes the first 25 sites (of 100) so the variables set will automatically pass to those first 25 sites.

 

Now I have 25 sites in bot A, 25 sites in bot B and 25 sites in bot C

 

So when I "include bot A" I would need to run sub "set login information" again just before running bot A?

 

(and then again before bots B and C?)

 

Thanks,

 

John

 

BTW, on the surface I would think that creating a table with this data would eliminate the need to "re-pass" variables simply by calling data from table cells, right?

 

John, I"m going to take the cheater way out of this one. Try it. This method isn't set in stone and there is tons of room for optimization and code trickery.

 

Frank

Link to post
Share on other sites

Using Subs will help to separate your code/bot into manageable chunks.

 

And that Irobot is the most important point of this whole tutorial. Great point.

 

Frank

Link to post
Share on other sites
  • 4 weeks later...

Great video Frank and very similar to how I set up my bots. here's what I do..

 

First I have my controller bot, it's the one that handles all the big chores like navigating here or there, moving data from one routine to the next etc. Those routines however are nested into smaller bots. I'm also very specific with my naming conventions as well so that I don't lose track of sub routines or variables that belong to them.

 

Basic structure is like this... "Module-Page-Action-variable"

 

Here's how it fits together I hope the code is easy enough to follow...

 

Mainbot.ubot
include lib.facebook.ubot
// include lib.crm.ubot
// include lib.linkedin.ubot
// include lib.jigsaw.ubot

#login-test = returnValue:
	runSub
		bot: fb-main
		sub: fb-main-login
		parameters:
			#fb-main-login-name
			#fb-main-login-pass
if (#login-test = "SUCCESS") {
	// Do Stuff
} else {
	// log error in #login-test
}

lib.facebook.ubot
include fb-main.ubot
include fb-search.ubot
include fb-profile.ubot
include fb-friends.ubot
include fb-wall.ubot

fb-main.ubot
sub fb-main-login
	parameter: #fb-main-login-name
	parameter: #fb-main-login-pass
	nav "http://www.facebook.com/"
	// do login stuff
	if (searchPage "What's Happening") {
		return "SUCCESS"
	} else {
		return "Could not log in"
	}

  • Like 1
Link to post
Share on other sites

Dave - now I know why they call you Super! This is brilliant. Do you just create the listing while programming seperately or have you also found a super secret way to print out code from ubot?

 

Either way, this is really smart. Especially long term when you have to look at your code again after two or three weeks.

 

Frank

 

Great video Frank and very similar to how I set up my bots. here's what I do..

 

First I have my controller bot, it's the one that handles all the big chores like navigating here or there, moving data from one routine to the next etc. Those routines however are nested into smaller bots. I'm also very specific with my naming conventions as well so that I don't lose track of sub routines or variables that belong to them.

 

Basic structure is like this... "Module-Page-Action-variable"

 

Here's how it fits together I hope the code is easy enough to follow...

 

Mainbot.ubot
include lib.facebook.ubot
// include lib.crm.ubot
// include lib.linkedin.ubot
// include lib.jigsaw.ubot

#login-test = returnValue:
	runSub
		bot: fb-main
		sub: fb-main-login
		parameters:
			#fb-main-login-name
			#fb-main-login-pass
if (#login-test = "SUCCESS") {
	// Do Stuff
} else {
	// log error in #login-test
}

lib.facebook.ubot
include fb-main.ubot
include fb-search.ubot
include fb-profile.ubot
include fb-friends.ubot
include fb-wall.ubot

fb-main.ubot
sub fb-main-login
	parameter: #fb-main-login-name
	parameter: #fb-main-login-pass
	nav "http://www.facebook.com/"
	// do login stuff
	if (searchPage "What's Happening") {
		return "SUCCESS"
	} else {
		return "Could not log in"
	}

Link to post
Share on other sites

Dave - now I know why they call you Super! This is brilliant. Do you just create the listing while programming seperately or have you also found a super secret way to print out code from ubot?

 

Either way, this is really smart. Especially long term when you have to look at your code again after two or three weeks.

 

Frank

 

 

Hey thanks Frank! The output that you read is hand-coded after I finish each sub. As you may recall I've been lobbying for a print/export feature specifically so I can track changes in larger bots. Right now I code the ubot portion, then the sudo code version, then let my SVN keep track of the changes.

 

If you don't mind, take a look into the other thread and comment on my post at the end. It'd be great to get some feedback from others who use advanced architecture in their bots!

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