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]
|
||||
#template = "SingsMic <%- stream.source %> <%- stream.city && stream.state ? `(${stream.city} ${stream.state})` : '' %> <%- stream.link %>"
|
||||
#interval = 60
|
||||
#delay = 30
|
||||
|
||||
[cert]
|
||||
# SSL certificates (optional)
|
||||
|
||||
@@ -20,6 +20,7 @@ export default class TwitchBot extends EventEmitter {
|
||||
|
||||
this.streams = null
|
||||
this.listeningURL = null
|
||||
this.dwellTimeout = null
|
||||
this.announceTimeouts = new Map()
|
||||
|
||||
client.on('ready', () => {
|
||||
@@ -70,10 +71,14 @@ export default class TwitchBot extends EventEmitter {
|
||||
this.onListeningURLChange(listeningURL)
|
||||
}
|
||||
|
||||
async onListeningURLChange(listeningURL) {
|
||||
if (!this.announceTimeouts.has(listeningURL)) {
|
||||
await this.announce()
|
||||
}
|
||||
onListeningURLChange(listeningURL) {
|
||||
const { announce } = this.config
|
||||
clearTimeout(this.dwellTimeout)
|
||||
this.dwellTimeout = setTimeout(() => {
|
||||
if (!this.announceTimeouts.has(listeningURL)) {
|
||||
this.announce()
|
||||
}
|
||||
}, announce.delay * 1000)
|
||||
}
|
||||
|
||||
async announce() {
|
||||
|
||||
@@ -110,6 +110,11 @@ function parseArgs() {
|
||||
number: true,
|
||||
default: 60,
|
||||
})
|
||||
.option('twitch.announce.delay', {
|
||||
describe: 'Time to dwell on a stream before its details are announced',
|
||||
number: true,
|
||||
default: 30,
|
||||
})
|
||||
.group(
|
||||
[
|
||||
'control.username',
|
||||
|
||||
Reference in New Issue
Block a user