• If you need help or want to discuss things, you now can also join us on our Discord Server!
  • A first preview of the unlimited version of SinusBot can be found in the Upcoming Changes thread. A version for Windows will follow, but we don't have a release date, yet.

Feature [Scripting] Split into multiple files / modules

cakemasher

Well-Known Member
Contributor
Personally I'de like to split large scripts into multiple files to maintain overview, or split classes from the main script.

When setting the 'enableWeb' to true, a directory should be created using the same name as the script. The web files are then placed within the 'html' folder located in the folder that was created for the plugin, making the folder structure like this (where [name] is the name of the script):
scripts/[name]
scripts/[name]/html

I would propose to create another folder within the [name] folder with a name something like 'modules', creating a folder structure like this:
scripts/[name]
scripts/[name]/html
scripts/[name]/modules

Requireing those 'modules' could be done like this:
JavaScript:
var my_module = require('script_name/modules/module_name.js')
// or
var my_module = require('modules/module_name.js');
// or
var my_module = require(__modules + '/module_name.js');

Kind regards,
Cakemasher
 

Tuetchen

Diesmon Dominator
is awesome!
Contributor
Insider
Is already possible, as its already been done for our library

Not possible in another directory tho
 

cakemasher

Well-Known Member
Contributor
Yes, I tested it myself as well. The thing is, if everybody would split their files into multiple files (like I prefer to do), the /scripts folder wil get extremely messy and populated. Also, the user has to enable each and every single 'plugin' to get the main script working. Not an ideal situation if you ask me.

Another possible example would be using the same structure as NodeJS modules, creating a folder structure like:
scripts/[name]/package.json (containing the index path of the file that should be opened first, lets say that's my_script.js for this example.)
scripts/[name]/my_script.js
scripts/[name]/html
scripts/[name]/html/index.html
scripts/[name]/modules
scripts/[name]/modules/my_module.js
 

Tuetchen

Diesmon Dominator
is awesome!
Contributor
Insider
Also, the user has to enable each and every single 'plugin' to get the main script working.
There is an autorun option

But yeah it would get messy indeed

And having an own directory with read/write permissions could be helpfull for the managment of assets or additional script related resources like webinterfaces etc
 

flyth

is reticulating splines
Staff member
Developer
Contributor
I thought about this many times myself, but I worry about security issues. A single script without any dependencies is pretty easy to screen for us, but with dependencies we won't be able to handle it anymore. Since I guess about 70% of the users don't care about security at all, they won't do it either.

But yeah, I can see that there needs to be a way to somehow organize large scripts (and maybe additional HTML pages) better. We'll discuss this internally.
 

cakemasher

Well-Known Member
Contributor
It would be a great feature, allowing me to add multiple scripts / features / functionalities within one script and keep the code kinda structured.

I understand the screening of scripts like that could be a pain in the ass, especially when someone creats a huge script and is applying hot fixes often. Maybe you could introduce a system to 'trust' certain developers or resources, basically accepting any update automatically. Maybe a report feature can be added to 'trusted developers' in case a user detects a security issue, meaning that you'll only have to screen a script when one or more reports or complaints are received.

If I come up with a possible solution, I'll let you know :).
 

cakemasher

Well-Known Member
Contributor
@flyth (or any other staff member) is it possible to receive any feedback of discussions for this feature requests? I would be interested in any outcomes.
 

Tuetchen

Diesmon Dominator
is awesome!
Contributor
Insider
Problems didnt change since last time and pushing the thread wont really help either
 

cakemasher

Well-Known Member
Contributor
@Tuetchen Could you maybe stay on-topic? 3 of your 5 posts in this topic have nothing to do with the feature request. Anyway, I'm not pushing this topic obviously. I could've send a private message to one of the crew asking the same thing, but I can imagine that they would prefer the forums, also allowing others within this community to get updated if they are interested.
 

cakemasher

Well-Known Member
Contributor
Sorry for bumping this old topic, but opening a new topic for this would seem unnecessary to me.

I've haven't looked into SinusBot scripting for a while and I was wondering if it's possible to split the script in multiple files as explained in my first message in this topic. If it happend to be implemented, does anyone know where I can find documentation and/or examples on how I could use this feature?

Thanks in advance!
 
Top