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

Updates to the Scripting Engine

Status
Not open for further replies.

flyth

is reticulating splines
Staff member
Developer
Contributor
With the upcoming version 0.9.16, both Windows & Linux will get all functionality of the new scripting engine that some of you might not have heard of yet at all. The new engine generalizes many things so that they are compatible with more backends (Discord for example), more easy to understand, more modular (thereby saving resources)...

If you haven't done it yet and are into scripting, please have a look at the documentation. A few examples are already in there and I hope that many will follow. The shipped scripts will be updated to the new engine soon and while still being available for some time, the old engine will be removed sooner or later. Should you miss any functionality or do have feature requests, please let us know.

SemVer

From 0.9.16 on it's possible to restrict scripts to run on specific bot versions. If for example you use new features in your script that weren't available before, you can use this to disable them for all other versions. That way users will know they have to upgrade to use your script.

Example for a script that won't run with a version below 0.9.18:
Code:
registerPlugin({
    ...
    engine: '>= 0.9.18',
    ...

Restricted Modules

0.9.16 specifically introduces two new modules that require special privileges: net and db - the former to establish tcp connections to other hosts, the latter to connect to MySQL/Postgres databases. Since both modules are more sensitive in terms of security, a user has to manually allow said modules for each separate script that wants to use them in the config.ini file.

Such a configuration looks like this (allowing script dev.js to use the db-module):
Code:
[Scripts.Privileges]
dev = ["db"]

As a script author you can decide if the script should soft-fail (require('db') will just return null in such a case, but the script will run (provided you've done checks on the result of require)) or hard-fail (the script won't run at all).
For the latter case you will have to specify that a module is required by adding the following to your manifest:

Code:
registerPlugin({
    ...
    requiredModules: ['db'],
    ...

In such a case, the script will still show up in the interface but it will not run and instead display a message that it requires more privileges.
 

omano

Member
Nice :)

Hope my script will still work :D and that updating to this new version will not break anything in the bot itself (already had a few problems in the past while updating, one have been solved with the help of Flyth and a magic parameter in the config file, the other needed full reinstall and start from scratch)
 
Status
Not open for further replies.
Top