mirror of
https://github.com/RavenX8/companion-module-streamer.bot-api.git
synced 2026-04-04 05:08:53 -04:00
Initial commit
This commit is contained in:
4
.gitignore
vendored
Normal file
4
.gitignore
vendored
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
node_modules/
|
||||||
|
package-lock.json
|
||||||
|
/pkg
|
||||||
|
/pkg.tgz
|
||||||
2
.prettierignore
Normal file
2
.prettierignore
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
package.json
|
||||||
|
/LICENSE.md
|
||||||
21
LICENSE
Normal file
21
LICENSE
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) 2022 Bitfocus AS - Open Source
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
||||||
3
README.md
Normal file
3
README.md
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
# companion-module-[replace with module name]
|
||||||
|
|
||||||
|
See [HELP.md](./companion/HELP.md) and [LICENSE](./LICENSE)
|
||||||
20
actions.js
Normal file
20
actions.js
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
module.exports = function (self) {
|
||||||
|
self.setActionDefinitions({
|
||||||
|
sample_action: {
|
||||||
|
name: 'My First Action',
|
||||||
|
options: [
|
||||||
|
{
|
||||||
|
id: 'num',
|
||||||
|
type: 'number',
|
||||||
|
label: 'Test',
|
||||||
|
default: 5,
|
||||||
|
min: 0,
|
||||||
|
max: 100,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
callback: async (event) => {
|
||||||
|
console.log('Hello world!', event.options.num)
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
3
companion/HELP.md
Normal file
3
companion/HELP.md
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
## Your module
|
||||||
|
|
||||||
|
Write some help for your users here!
|
||||||
26
companion/manifest.json
Normal file
26
companion/manifest.json
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
{
|
||||||
|
"id": "your-module-name",
|
||||||
|
"name": "your-module-name",
|
||||||
|
"shortname": "module-shortname",
|
||||||
|
"description": "A short one line description of your module",
|
||||||
|
"version": "0.0.0",
|
||||||
|
"license": "MIT",
|
||||||
|
"repository": "git+https://github.com/bitfocus/companion-module-your-module-name.git",
|
||||||
|
"bugs": "https://github.com/bitfocus/companion-module-your-module-name/issues",
|
||||||
|
"maintainers": [
|
||||||
|
{
|
||||||
|
"name": "Your name",
|
||||||
|
"email": "Your email"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"runtime": {
|
||||||
|
"type": "node18",
|
||||||
|
"api": "nodejs-ipc",
|
||||||
|
"apiVersion": "0.0.0",
|
||||||
|
"entrypoint": "../main.js"
|
||||||
|
},
|
||||||
|
"legacyIds": [],
|
||||||
|
"manufacturer": "Your company",
|
||||||
|
"products": ["Your product"],
|
||||||
|
"keywords": []
|
||||||
|
}
|
||||||
33
feedbacks.js
Normal file
33
feedbacks.js
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
const { combineRgb } = require('@companion-module/base')
|
||||||
|
|
||||||
|
module.exports = async function (self) {
|
||||||
|
self.setFeedbackDefinitions({
|
||||||
|
ChannelState: {
|
||||||
|
name: 'Example Feedback',
|
||||||
|
type: 'boolean',
|
||||||
|
label: 'Channel State',
|
||||||
|
defaultStyle: {
|
||||||
|
bgcolor: combineRgb(255, 0, 0),
|
||||||
|
color: combineRgb(0, 0, 0),
|
||||||
|
},
|
||||||
|
options: [
|
||||||
|
{
|
||||||
|
id: 'num',
|
||||||
|
type: 'number',
|
||||||
|
label: 'Test',
|
||||||
|
default: 5,
|
||||||
|
min: 0,
|
||||||
|
max: 10,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
callback: (feedback) => {
|
||||||
|
console.log('Hello world!', feedback.options.num)
|
||||||
|
if (feedback.options.num > 5) {
|
||||||
|
return true
|
||||||
|
} else {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
63
main.js
Normal file
63
main.js
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
const { InstanceBase, Regex, runEntrypoint, InstanceStatus } = require('@companion-module/base')
|
||||||
|
const UpgradeScripts = require('./upgrades')
|
||||||
|
const UpdateActions = require('./actions')
|
||||||
|
const UpdateFeedbacks = require('./feedbacks')
|
||||||
|
const UpdateVariableDefinitions = require('./variables')
|
||||||
|
|
||||||
|
class ModuleInstance extends InstanceBase {
|
||||||
|
constructor(internal) {
|
||||||
|
super(internal)
|
||||||
|
}
|
||||||
|
|
||||||
|
async init(config) {
|
||||||
|
this.config = config
|
||||||
|
|
||||||
|
this.updateStatus(InstanceStatus.Ok)
|
||||||
|
|
||||||
|
this.updateActions() // export actions
|
||||||
|
this.updateFeedbacks() // export feedbacks
|
||||||
|
this.updateVariableDefinitions() // export variable definitions
|
||||||
|
}
|
||||||
|
// When module gets deleted
|
||||||
|
async destroy() {
|
||||||
|
this.log('debug', 'destroy')
|
||||||
|
}
|
||||||
|
|
||||||
|
async configUpdated(config) {
|
||||||
|
this.config = config
|
||||||
|
}
|
||||||
|
|
||||||
|
// Return config fields for web config
|
||||||
|
getConfigFields() {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
type: 'textinput',
|
||||||
|
id: 'host',
|
||||||
|
label: 'Target IP',
|
||||||
|
width: 8,
|
||||||
|
regex: Regex.IP,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: 'textinput',
|
||||||
|
id: 'port',
|
||||||
|
label: 'Target Port',
|
||||||
|
width: 4,
|
||||||
|
regex: Regex.PORT,
|
||||||
|
},
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
updateActions() {
|
||||||
|
UpdateActions(this)
|
||||||
|
}
|
||||||
|
|
||||||
|
updateFeedbacks() {
|
||||||
|
UpdateFeedbacks(this)
|
||||||
|
}
|
||||||
|
|
||||||
|
updateVariableDefinitions() {
|
||||||
|
UpdateVariableDefinitions(this)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
runEntrypoint(ModuleInstance, UpgradeScripts)
|
||||||
20
package.json
Normal file
20
package.json
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
{
|
||||||
|
"name": "your-module-name",
|
||||||
|
"version": "0.1.0",
|
||||||
|
"main": "main.js",
|
||||||
|
"scripts": {
|
||||||
|
"format": "prettier -w ."
|
||||||
|
},
|
||||||
|
"license": "MIT",
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "git+https://github.com/bitfocus/companion-module-your-module-name.git"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"@companion-module/base": "~1.5.1"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@companion-module/tools": "^1.4.1"
|
||||||
|
},
|
||||||
|
"prettier": "@companion-module/tools/.prettierrc.json"
|
||||||
|
}
|
||||||
13
upgrades.js
Normal file
13
upgrades.js
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
module.exports = [
|
||||||
|
/*
|
||||||
|
* Place your upgrade scripts here
|
||||||
|
* Remember that once it has been added it cannot be removed!
|
||||||
|
*/
|
||||||
|
// function (context, props) {
|
||||||
|
// return {
|
||||||
|
// updatedConfig: null,
|
||||||
|
// updatedActions: [],
|
||||||
|
// updatedFeedbacks: [],
|
||||||
|
// }
|
||||||
|
// },
|
||||||
|
]
|
||||||
7
variables.js
Normal file
7
variables.js
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
module.exports = async function (self) {
|
||||||
|
self.setVariableDefinitions([
|
||||||
|
{ variableId: 'variable1', name: 'My first variable' },
|
||||||
|
{ variableId: 'variable2', name: 'My second variable' },
|
||||||
|
{ variableId: 'variable3', name: 'Another variable' },
|
||||||
|
])
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user