Errbot: How can I access config file variables - errbot

I see the way it's done in cli.py but it's not set up as a utility for plugin code to make use of.
From http://errbot.io/en/latest/user_guide/plugin_development/configuration.html :
Errbot can keep a simple python object for the configuration of your plugin. This avoids the need for admins to configure settings in some kind of configuration file, instead allowing configuration to happen directly through chat commands.
But, I like config files! I prefer to use them for some things if possible.

Sure, the config.py module is exposed as self.bot_config in the plugins.
There are 2 caveats doing that:
You will not be able to change this config "on the fly", you'll need to restart the entire bot instead of just reloading the plugin
Your plugin won't be installable with !repos install, people will need to stop the bot too.
As an alternative, if you want to make a setup script, you can use the provisioning cli.

Related

How to create custom node.js application starter scripts

I would like to create custom scripts for creating a new application just like npx create-react-app my-app. However, I would like to customize libraries and folder structure etc. However, I am not quite sure how to approach this. I thought about two ways but I am unsure which one will best fit my needs.
Should I create a custom package then create the files I need with fs etc.
A batch script to do the things I mentioned.
I found that express has this feature but it would be nice to be able to customize these settings. Are there any alternative and possibly more efficient methods for doing this?
Also, if I were to do it via nmp packages. How can I run them from the cli?
Thanks in advance!
If customizations are not too advanced, you can start by creating a template repository and place a single setup script in it, which can be implemented by using inquirer npm module. Here is an example:
See https://github.com/kriasoft/nodejs-api-starter -> setup.js

Moodle Atto 'plugin not found'

I've been trying to use the Atto plugin template (https://github.com/justinhunt/moodle-atto_newtemplate) to try and create my own Atto plugin. I've made the changes outlined in the README, and got shifter to run via npm. It appears to generate the build folder that matches the other plugins.
I'm able to see the plugin in configuration, and it's showing up in the Atto Toolbar Settings, but, when I pop open a text editor, I don't get an icon, and the console logs moodle-editor_atto-editor: Plugin 'testplugin' could not be found - skipping initialisation
I've found a few references in the docs that shifter is no longer used, and grunt is the new way to go, but I can't find any actual docs on this, and no gruntfile seems to exist anywhere.
Has anyone come across this before? What am I missing?
You will need to run shifter on your YUI code for it to work - the usual way of doing that, for Moodle 2.9 and above is to use grunt - see https://docs.moodle.org/dev/Grunt for more details.
Not sure if this was ever resolved. The template is really helpful and it also comes with lib, db, and version PHP scripts. The string that you use as the plugin name has to be consistent throughout these scripts, as well as in your JS file. By default, it is set to atto_NEWTEMPLATE. Did you perhaps change this string to atto_testplugin in one place but not in all the others?

Plugin system in SailsJS application

I'm working on a NodeJS application, using SailsJS, and I want to implement (or use if exists) a system to manage plugins. By "plugin", I mean a module that I could add in a "plugins" directory.
Is someone has ever tried to do something like that ?

Node js plugin permissions

I create a web server with Sails.js, and want to allow third dev to create node.js plugins installable from a web page (store).
My problem is I don't want this plugin to require sails (or other critical modules) and have access to database and services and do what they want.
For example using fs and delete all files.
How can I do that ? I have no idea if node.js can lock some scripts on this own directory
I don't think that node expose some sandboxing functionality so when you load a js code into node that code can do what it want.
From your description yours plugins are more like browser javascript code so I think that you can use a headless browser to execute your code and retrieve the result. I've never tried it by myself but it should work. You just have to figure out how to pass parameters to plugin and get the result, also performance will be very bad because the headless browser is quite heavy. Try looking at
http://phantomjs.org/
Another solution is to run the plugins directly inside node but sanitizing the code before running. There are some projects like:
http://gf3.github.io/sandbox/
https://github.com/asvd/jailed
They can help you limiting the powers of the plugins.
Anyway are you sure about it ? in any major CMS platform that I've seen (wordpress, joomla, drupal, liferay ...) the platform's author trusts plugins authors and plugins can always do what they want.

RPM - Install time parameters

I have packaged my application into an RPM package, say, myapp.rpm. While installing this application, I would like to receive some inputs from the user (an example for input could be - environment where the app is getting installed - "dev", "qa", "uat", "prod"). Based on the input, the application will install the appropriate files. Is there a way to pass parameters while installing the application?
P.S.: A possible solution could be to create an RPM package for each environment. However, in our scenario, this is not a viable option since we have around 20 environments and we do not wish to have 20 different packages for the same application.
In general, RPM packages should not require user interaction. Time and time again, the RPM folks have stated that it is an explicit design goal of RPM to not have interactive installs. For packages that need some sort of input before first use, you typically ask for this information on first use, our you put it all in config files with macros or something and tell your users that they will have to configure the application before it is usable.
Even passing a parameter of some sort counts as end-user interaction. I think what you want is to have your pre or install scripts auto detect the environment somehow, maybe by having a file somewhere they can examine. I'll also point out that from an RPM user's perspective, having a package named *-qa.rpm is a lot more intuitive than passing some random parameter.
For your exact problem, if you are installing different content, you should create different packages. If you try to do things differently, you're going to end up fighting the RPM system more and more.
It isn't hard to create a build system that can spit out 20+ packages that are all mostly similar. I've done it with a template-ish spec file and some scripts run by make that will create the various spec files and build the RPMs. Without knowing the specifics, it sounds like you might even have a core package that all 20+ environment packages depend on, then the environment specific packages install whatever is specific to their target environment.
You could use the relocate option, e.g.
rpm -i --relocate /env=/uat somepkg.rpm
and have your script look up the variable data from a file located in the "env" directory
I think this is a very valid question, specially as soon as you are moving into the application development realm. There he configuration of the application for different target systems is your daily bread: you need to configure for Development, Integration Test, Acceptance Test, Production etc. I sure don't think building a seperate package for each enviroment is the solution. Basically it should be the same code running in different enviroments.
I know that this requirement is not supported by rpm. But what you can do as a work around is to use a simple config file, that the %pre script knows
to look for. The config file could be a simple shell script that for example sets environment variables, and then the different und pre and post scripts can use those.

Resources