mirror of
https://github.com/RavenX8/companion-module-voicemod.git
synced 2026-04-03 21:08:51 -04:00
Added connection state
Added some basic actions
This commit is contained in:
56
main.js
56
main.js
@@ -1,22 +1,41 @@
|
||||
const { InstanceBase, Regex, runEntrypoint, InstanceStatus } = require('@companion-module/base')
|
||||
const { InstanceBase, runEntrypoint, InstanceStatus } = require('@companion-module/base')
|
||||
const UpgradeScripts = require('./upgrades')
|
||||
const UpdateActions = require('./actions')
|
||||
const UpdateFeedbacks = require('./feedbacks')
|
||||
const UpdateVariableDefinitions = require('./variables')
|
||||
const { VoiceMod } = require('voicemod')
|
||||
|
||||
class ModuleInstance extends InstanceBase {
|
||||
constructor(internal) {
|
||||
super(internal)
|
||||
|
||||
this.config = {}
|
||||
this.memes = []
|
||||
}
|
||||
|
||||
async init(config) {
|
||||
this.config = config
|
||||
this.log('debug', 'init called')
|
||||
|
||||
this.updateStatus(InstanceStatus.Ok)
|
||||
this.updateStatus(InstanceStatus.Connecting)
|
||||
this.vm = new VoiceMod()
|
||||
try {
|
||||
this.vm.init().then(
|
||||
async () => {
|
||||
this.updateStatus(InstanceStatus.Ok)
|
||||
this.updateActionsFeedbacksVariables()
|
||||
|
||||
this.updateActions() // export actions
|
||||
this.updateFeedbacks() // export feedbacks
|
||||
this.updateVariableDefinitions() // export variable definitions
|
||||
this.log('debug', 'connected to VM and ready')
|
||||
},
|
||||
(reason) => {
|
||||
this.log('debug', reason)
|
||||
this.updateStatus(InstanceStatus.ConnectionFailure)
|
||||
}
|
||||
)
|
||||
} catch (e) {
|
||||
this.log('debug', e)
|
||||
this.updateStatus(InstanceStatus.UnknownError)
|
||||
}
|
||||
}
|
||||
// When module gets deleted
|
||||
async destroy() {
|
||||
@@ -25,26 +44,21 @@ class ModuleInstance extends InstanceBase {
|
||||
|
||||
async configUpdated(config) {
|
||||
this.config = config
|
||||
this.log('debug', 'config updated')
|
||||
}
|
||||
|
||||
// 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,
|
||||
},
|
||||
]
|
||||
return []
|
||||
}
|
||||
|
||||
updateActionsFeedbacksVariables() {
|
||||
// this.organizeChoices()
|
||||
|
||||
this.updateActions() // export actions
|
||||
// this.updateFeedbacks() // export feedbacks
|
||||
// this.updateVariableDefinitions() // export variable definitions
|
||||
// this.checkFeedbacks()
|
||||
}
|
||||
|
||||
updateActions() {
|
||||
|
||||
Reference in New Issue
Block a user