i have a script can execute various commands when prompted to by channel commands. my problem is, is that some of these commands can take up to 30 secs to finish, and while the script is busy doing the command, it renders the bot inactive.
is there a way to maybe have the script execute a command in the background, and then still be able to reply to other requests it gets, even if it just queus them up. so as to make the bot look as if its still alive even if it is in the middle of executing a command.
This is called multi-threading, and no it's not possible directly.
It's all dependant on what script needs what information.
If a script takes 30 seconds to complete, then you should look into reducing that time, as some of my high end script don't take that long.
1 method of doing what you want, is to split your script into 7 or 8 parts. At the end of each part, run a "utimer" for one second, to launch the second part and so on.
Noting again though, it's dependant on what information the script needs as to if this works or not.
yea i figured as much, i think i can fit the timer solution in somehow. its not actually the script thats taking up the time, its actually an external process that the script executes.
If it's an external program, then you can base it on what output it has give.
Insteadn of using the exec command, you can use the "open" command to create non-blocking access to the program. Using a a time, you can work out when the program has finished and close the handle.
are you saying, use a timer (~30 secs) to guess when the program has finished? i can't tell how long for sure the execution may take, might only be a few secs. also i want to be able display a message when the execution is finished...