mirror of
https://github.com/streamwall/streamwall.git
synced 2025-12-06 01:45:37 -05:00
Add configurable dwell delay to Twitch bot
This commit is contained in:
@@ -46,6 +46,7 @@ json-url = ["https://woke.net/api/streams.json"]
|
|||||||
[twitch.announce]
|
[twitch.announce]
|
||||||
#template = "SingsMic <%- stream.source %> <%- stream.city && stream.state ? `(${stream.city} ${stream.state})` : '' %> <%- stream.link %>"
|
#template = "SingsMic <%- stream.source %> <%- stream.city && stream.state ? `(${stream.city} ${stream.state})` : '' %> <%- stream.link %>"
|
||||||
#interval = 60
|
#interval = 60
|
||||||
|
#delay = 30
|
||||||
|
|
||||||
[cert]
|
[cert]
|
||||||
# SSL certificates (optional)
|
# SSL certificates (optional)
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ export default class TwitchBot extends EventEmitter {
|
|||||||
|
|
||||||
this.streams = null
|
this.streams = null
|
||||||
this.listeningURL = null
|
this.listeningURL = null
|
||||||
|
this.dwellTimeout = null
|
||||||
this.announceTimeouts = new Map()
|
this.announceTimeouts = new Map()
|
||||||
|
|
||||||
client.on('ready', () => {
|
client.on('ready', () => {
|
||||||
@@ -70,10 +71,14 @@ export default class TwitchBot extends EventEmitter {
|
|||||||
this.onListeningURLChange(listeningURL)
|
this.onListeningURLChange(listeningURL)
|
||||||
}
|
}
|
||||||
|
|
||||||
async onListeningURLChange(listeningURL) {
|
onListeningURLChange(listeningURL) {
|
||||||
if (!this.announceTimeouts.has(listeningURL)) {
|
const { announce } = this.config
|
||||||
await this.announce()
|
clearTimeout(this.dwellTimeout)
|
||||||
}
|
this.dwellTimeout = setTimeout(() => {
|
||||||
|
if (!this.announceTimeouts.has(listeningURL)) {
|
||||||
|
this.announce()
|
||||||
|
}
|
||||||
|
}, announce.delay * 1000)
|
||||||
}
|
}
|
||||||
|
|
||||||
async announce() {
|
async announce() {
|
||||||
|
|||||||
@@ -110,6 +110,11 @@ function parseArgs() {
|
|||||||
number: true,
|
number: true,
|
||||||
default: 60,
|
default: 60,
|
||||||
})
|
})
|
||||||
|
.option('twitch.announce.delay', {
|
||||||
|
describe: 'Time to dwell on a stream before its details are announced',
|
||||||
|
number: true,
|
||||||
|
default: 30,
|
||||||
|
})
|
||||||
.group(
|
.group(
|
||||||
[
|
[
|
||||||
'control.username',
|
'control.username',
|
||||||
|
|||||||
Reference in New Issue
Block a user