Jump to content
UBot Underground

How can I load a script from a text file?


Recommended Posts

Using the $read file command I know this must be possible! I am trying to take a bot I created and copied all the code into a text file, and actually execute that code using the text file. I can't seem to find any commands that does this. I'm sure javascript has a way but I'm clueless, anyone have any ideas? :)

Link to post
Share on other sites

Using the $read file command I know this must be possible! I am trying to take a bot I created and copied all the code into a text file, and actually execute that code using the text file. I can't seem to find any commands that does this. I'm sure javascript has a way but I'm clueless, anyone have any ideas? :)

I like where you're aiming on this.

 

loop($table total rows(&what_to_do)) {
   if($comparison($table cell(&what_to_do, #row, #column), "=", "Camon")) {
       then {
           wait($table cell(&wait, #row_to_wait, #column))
           increment(#row_to_wait)
           click(<image="___IMAGE___26___IMAGE___">, "Left Click", "No")
           wait(8)
           click(<image="___IMAGE___27___IMAGE___">, "Left Click", "No")
           wait(5)
           click(<image="___IMAGE___28___IMAGE___">, "Left Click", "No")
           increment(#row)
       }
       else {
           if($comparison($table cell(&what_to_do, #row, #column), "=", "Camoff")) {
               then {
                   wait($table cell(&wait, #row_to_wait, #column))
                   increment(#row_to_wait)
                   click(<image="___IMAGE___40___IMAGE___">, "Left Click", "No")
                   increment(#row)
               }
               else {
                   if($comparison($table cell(&what_to_do, #row, #column), "=", "text")) {
                       then {
                           wait($table cell(&wait, #row_to_wait, #column))
                           increment(#row_to_wait)
                           type text(<image="___IMAGE___31___IMAGE___">, $table cell(&what_to_say, #row_to_say, #column), "Standard")
                           wait(2)
                           type text(<image="___IMAGE___34___IMAGE___">, "\{ENTER\}", "Standard")
                           increment(#row)
                           increment(#row_to_say)
                       }
                       else {
                       }
                   }
               }
           }
       }
   }
}

 

This is something I wrote a while ago, it's a loose example if you modify it quite a bit. Using if then statements to evaluate a trigger word, then executing commands based on that. It would take a lot of work to break down and map out, but you could sort of make a ubot within a ubot. ubotception O_O

Link to post
Share on other sites

ui drop down("Action", "Navigate,Scrape,Save As", #action)
clear table(&action)
set(#row, 0, "Global")
set(#action_col, 0, "Global")
set(#url_col, 1, "Global")
set(#left_col, 2, "Global")
set(#right_col, 3, "Global")
if($comparison(#action, "=", "Navigate")) {
   then {
       set(#URL, $prompt("Url To Navigate To"), "Global")
       set table cell(&action, #row, #action_col, #action)
       set table cell(&action, #row, #url_col, #URL)
       increment(#row)
   }
   else {
   }
}
if($comparison(#action, "=", "Scrape")) {
   then {
       set(#Left, $prompt("Left Side"), "Global")
       set(#right, $prompt("Right Side"), "Global")
       set table cell(&action, #row, #action_col, #action)
       set table cell(&action, #row, #left_col, #Left)
       increment(#row)
   }
   else {
   }
}
if($comparison(#action, "=", "Save As")) {
   then {
       set(#file_name, $prompt("Save As?"), "Global")
       save to file("{$special folder("Application")}\\script\\{#file_name}.csv", &action)
   }
   else {
   }
}

This is a better example I wrote, All it really does is let you write a script for navigating and scraping that you can then load into this below.

ui open file("Script", #script)
ui button("Run") {
   clear table(&script)
   clear list(%scrape)
   create table from file(#script, &script)
   set(#row, 0, "Global")
   set(#action_col, 0, "Global")
   set(#url_col, 1, "Global")
   set(#left_col, 2, "Global")
   set(#right_col, 3, "Global")
   loop($table total rows(&script)) {
       Evaluate()
   }
   set(#save, $prompt("Save Scrape As?"), "Global")
   save to file("{$special folder("Application")}\\scrape\\{#save}.txt", %scrape)
}
define Evaluate {
   if($comparison($table cell(&script, #row, #action_col), "=", "Navigate")) {
       then {
           set(#navigate, $table cell(&script, #row, #url_col), "Global")
           navigate(#navigate, "Wait")
           increment(#row)
       }
       else {
       }
   }
   if($comparison($table cell(&script, #row, #action_col), "=", "Scrape")) {
       then {
           add item to list(%scrape, $page scrape($table cell(&script, #row, #left_col), $table cell(&script, #row, #right_col)), "Delete", "Global")
           increment(#row)
       }
       else {
       }
   }
}

Never fiddled with 3.5, but I guess it's doable (though a major pita)

botception.ubot

run_botception.ubot

Link to post
Share on other sites

ui drop down("Action", "Navigate,Scrape,Save As", #action)
clear table(&action)
set(#row, 0, "Global")
set(#action_col, 0, "Global")
set(#url_col, 1, "Global")
set(#left_col, 2, "Global")
set(#right_col, 3, "Global")
if($comparison(#action, "=", "Navigate")) {
   then {
       set(#URL, $prompt("Url To Navigate To"), "Global")
       set table cell(&action, #row, #action_col, #action)
       set table cell(&action, #row, #url_col, #URL)
       increment(#row)
   }
   else {
   }
}
if($comparison(#action, "=", "Scrape")) {
   then {
       set(#Left, $prompt("Left Side"), "Global")
       set(#right, $prompt("Right Side"), "Global")
       set table cell(&action, #row, #action_col, #action)
       set table cell(&action, #row, #left_col, #Left)
       increment(#row)
   }
   else {
   }
}
if($comparison(#action, "=", "Save As")) {
   then {
       set(#file_name, $prompt("Save As?"), "Global")
       save to file("{$special folder("Application")}\\script\\{#file_name}.csv", &action)
   }
   else {
   }
}

This is a better example I wrote, All it really does is let you write a script for navigating and scraping that you can then load into this below.

ui open file("Script", #script)
ui button("Run") {
   clear table(&script)
   clear list(%scrape)
   create table from file(#script, &script)
   set(#row, 0, "Global")
   set(#action_col, 0, "Global")
   set(#url_col, 1, "Global")
   set(#left_col, 2, "Global")
   set(#right_col, 3, "Global")
   loop($table total rows(&script)) {
       Evaluate()
   }
   set(#save, $prompt("Save Scrape As?"), "Global")
   save to file("{$special folder("Application")}\\scrape\\{#save}.txt", %scrape)
}
define Evaluate {
   if($comparison($table cell(&script, #row, #action_col), "=", "Navigate")) {
       then {
           set(#navigate, $table cell(&script, #row, #url_col), "Global")
           navigate(#navigate, "Wait")
           increment(#row)
       }
       else {
       }
   }
   if($comparison($table cell(&script, #row, #action_col), "=", "Scrape")) {
       then {
           add item to list(%scrape, $page scrape($table cell(&script, #row, #left_col), $table cell(&script, #row, #right_col)), "Delete", "Global")
           increment(#row)
       }
       else {
       }
   }
}

Never fiddled with 3.5, but I guess it's doable (though a major pita)

 

yeah that could work if you wrote every bot to be specific to what your doing, in your example the scraping. I'm looking for a way to actually execute any piece of ubot code from a text file. For example, in a text file a piece of ubot code would say "alert(hi!)" and in ubot the code would be something like "run script($read file(c:/textfile.txt)) then when the ubot script ran, it would look at the text file and see the alert command and run it. I'm not sure if its possible, it sounds like something javascript could do though!

Link to post
Share on other sites

yeah that could work if you wrote every bot to be specific to what your doing, in your example the scraping. I'm looking for a way to actually execute any piece of ubot code from a text file. For example, in a text file a piece of ubot code would say "alert(hi!)" and in ubot the code would be something like "run script($read file(c:/textfile.txt)) then when the ubot script ran, it would look at the text file and see the alert command and run it. I'm not sure if its possible, it sounds like something javascript could do though!

 

Yeah, I'm kind of curious if there's a way to do it that way. This is pretty much the only way I know of off hand, which would be more of a pain than its worth since you'd have to map out everything ahead of time.

Link to post
Share on other sites

what do u looking for is a include command which is not possible with v4

its a shame and pain in the a... that a includefunction we had in v3.5 not workable for v4

 

we ask the ubot team for that a long time one of the most wanted here in the forum

but the only answer is "use the botbank"

 

i called buttbank because dont works for what we need

greetings to seth :)

  • Like 1
Link to post
Share on other sites

it's one of the things I hate most. The bot bank is hopeless for my needs which are essentially to include various functions. I am almost always in code view and bot bank requires I write in egyptian pretty much so I never use it and just copy and paste in functions that I keep in a onenote noteboook. But it makes version control and avoiding duplication a bit of a mare.

 

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

Zonfar,

 

I didn't quite understand what you meant here:

 

"I am trying to take a bot I created and copied all the code in a text file, and actually execute that code using the text file."

 

Are you trying to say, you want to feed your bot commands from a text file so whatever instructions it reads in a text file, it executes action based upon it ?

Example:

 

If a text file looks like this:

 

"Go to youtube.com

Type in search box: bots

If search results yield less than 10,000 results then do nothing; Otherwise scrape all urls of videos found to hdd and message the following message "blah blah blah" to video owners."

 

Then, your bot understands that it must navigate to youtube and make search for the keyword "bots" and if there's less than 10k videos listed then do nothing otherwise scrape all video links found to your hdd and email all video owners your message.

 

In short, I think you find it difficult to program in Ubot and so whenever you need to create a bot from time to time to do different kinds of tasks, you don't want to pull-up Ubot everytime to build a bot. You instead want to create one single bot that understands all your commands from a text file and get it to do different tasks each time you feed it an instruction file to make your life easier. Correct ?

If that's the case, I was gonna build such a bot in the past but guess what ? Building such a bot would be like building another Ubot and this might end-up us losing our Ubot licenses and once that happens, our Ubots would never launch. The reason why there's a risk we'd lose our license is this clause in the license agreement:

 

"2 - Restrictions

 

You may not rent, sublicense, assign, lease, loan, resell for profit, distribute, publish or network the Software or related materials or create derivative works based upon the Software or any part thereof. "

 

The last part of the clause is what I'm worried about:

 

"....or create derivative works based upon the Software or any part thereof. "

 

And therefore, I suggest, you open a support ticket and ask Ubot staff if what you're trying to do is allowed or not and if it is then to make this clear on their site or atleast come and make a post here to clear the misconception.

Once that's done, I'll try helping you build your bot, if I have the time.

 

Thanks

I was actually wanting to load a certain part of a script off of my webhost if I needed to update it as opposed to re-compiling it and sending it to everyone who uses it. I could see how that might be a problem because anyone could make a text file and load it into a ubot bot configured to load a text file and essentially have a script-only version of ubot for free. I was thinking there was an easy way to do it using javascript or something. oh well!

Link to post
Share on other sites

yes u can use javascript to do some includes

but u will see the end if u work with captcha or some linksclicks whos

not working with only js...

its a shame that uBot 4 dont got includes like v3

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