Frank 177 Posted July 21, 2010 Report Share Posted July 21, 2010 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.comPart 2 of 2 Advanced Ubot Tutorials on UbotJunkie.com http://www.youtube.com/watch?v=WkvWvooK-mghttp://www.youtube.com/watch?v=7K463FKR51M Enjoy! Oh, please feel free to post questions right here if you have any. Frank 3 Quote Link to post Share on other sites
Dangazzm 0 Posted July 22, 2010 Report Share Posted July 22, 2010 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. Quote Link to post Share on other sites
Frank 177 Posted July 22, 2010 Author Report Share Posted July 22, 2010 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 1 Quote Link to post Share on other sites
pftg4 102 Posted July 22, 2010 Report Share Posted July 22, 2010 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 Quote Link to post Share on other sites
Frank 177 Posted July 27, 2010 Author Report Share Posted July 27, 2010 Yep, gave you my best stuff! No secrets now! Or is there? Frank Quote Link to post Share on other sites
botbie 0 Posted August 3, 2010 Report Share Posted August 3, 2010 hi Frank, thanks for your sharing. It food my mind. Quote Link to post Share on other sites
Kreatus (Ubot Ninja) 422 Posted August 5, 2010 Report Share Posted August 5, 2010 Your run sub is different from my run sub. How come your run sub in the video can add variables in it?? In my ubot theres no option like that... Quote Link to post Share on other sites
Biks 9 Posted August 12, 2010 Report Share Posted August 12, 2010 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 runningPARAMETER: 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? :-) Quote Link to post Share on other sites
IRobot 43 Posted August 12, 2010 Report Share Posted August 12, 2010 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 runningUse 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. Quote Link to post Share on other sites
UBotBuddy 331 Posted August 12, 2010 Report Share Posted August 12, 2010 Nice job Frank! Quote Link to post Share on other sites
Biks 9 Posted August 13, 2010 Report Share Posted August 13, 2010 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) Quote Link to post Share on other sites
JohnB 255 Posted August 13, 2010 Report Share Posted August 13, 2010 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? Quote Link to post Share on other sites
IRobot 43 Posted August 15, 2010 Report Share Posted August 15, 2010 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. Quote Link to post Share on other sites
Frank 177 Posted August 25, 2010 Author Report Share Posted August 25, 2010 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 Quote Link to post Share on other sites
Frank 177 Posted August 25, 2010 Author Report Share Posted August 25, 2010 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 Quote Link to post Share on other sites
Super Dave 26 Posted September 20, 2010 Report Share Posted September 20, 2010 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" } 1 Quote Link to post Share on other sites
Frank 177 Posted September 21, 2010 Author Report Share Posted September 21, 2010 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" } Quote Link to post Share on other sites
Super Dave 26 Posted September 21, 2010 Report Share Posted September 21, 2010 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! Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.