1234567891011121314151617181920212223242526272829303132333435 |
- #!/usr/bin/env sh
- if [ $# -lt 1 ]
- then
- echo "usage: $0 plugin-name"
- echo " This command generates a file at src/plugins/plugin-name.py, containing the base of a rollbot plugin."
- echo " The plugin-name must be a valid python identifier, and ideally should only be composed of lowercase letters and underscores"
- exit 1
- fi
- if ! [[ "$1" =~ ^[a-z][a-z_]*$ ]]
- then
- echo "Plugin names should be composed entirely of lowercase letters and underscores"
- exit 1
- fi
- PLUGIN_FILE="./src/plugins/$1.py"
- if [[ -f $PLUGIN_FILE ]]
- then
- echo "Plugin module with this name already exists - pick a new module name. You can always bind it to a different command word later!"
- exit 1
- fi
- echo "Populating $PLUGIN_FILE with basic plugin called $1"
- echo "from command_system import as_plugin, RollbotResponse" >> $PLUGIN_FILE
- echo "" >> $PLUGIN_FILE
- echo "" >> $PLUGIN_FILE
- echo "@as_plugin(\"$1\")" >> $PLUGIN_FILE
- echo "def $1(db, msg):" >> $PLUGIN_FILE
- echo " return RollbotResponse(msg, txt=\"My first plugin!\")" >> $PLUGIN_FILE
- echo "Action required: Insert the following line into the [plugins] section of config/config.toml to activate $1"
- echo "$1 = [ \"$1\" ]"
|