add hacky fix for radio stopping
This commit is contained in:
parent
8048822859
commit
d67835be30
2
.gitignore
vendored
2
.gitignore
vendored
@ -2,3 +2,5 @@ node_modules
|
||||
old
|
||||
.env
|
||||
playlists/*
|
||||
|
||||
test
|
||||
|
@ -2,7 +2,7 @@ const IRC = require('irc-framework')
|
||||
const bot = new IRC.Client()
|
||||
|
||||
const { searchTrack, requestTrack, deleteTrack } = require('./spotify')
|
||||
const { getCurrentTrack, skipTrack, reset } = require('./mpc-commands')
|
||||
const { getCurrentTrack, skipTrack, reset, poll } = require('./mpc-commands')
|
||||
const { getMyPlaylist } = require('./linx-commands')
|
||||
const chalk = require('chalk')
|
||||
|
||||
@ -11,6 +11,7 @@ const helpers = ['notnull', 'rfa', 'substack']
|
||||
|
||||
const autojoin = ['#anarchybots']
|
||||
|
||||
setInterval(poll, 60000)
|
||||
const host = process.env.HOST || 'localhost'
|
||||
const port = process.env.PORT || 6667
|
||||
const nick = process.env.NICK || 'radiobot'
|
||||
|
@ -1,11 +1,22 @@
|
||||
const { spawnSync } = require('child_process')
|
||||
const fs = require('fs')
|
||||
|
||||
let playing = null
|
||||
|
||||
const getPlaylist = () => {
|
||||
const { stderr, stdout } = spawnSync('mpc', ['playlist'])
|
||||
return { error: stderr.toString(), playlist: stdout.toString() }
|
||||
}
|
||||
|
||||
const poll = () => {
|
||||
const { stdout } = spawnSync('mpc', ['status'])
|
||||
const nowPlaying = stdout.toString()
|
||||
if (playing === nowPlaying) {
|
||||
console.log('Song stopped playing. Skipping\n', nowPlaying)
|
||||
spawnSync('mpc', ['next'])
|
||||
} else playing = nowPlaying
|
||||
}
|
||||
|
||||
const getCurrentTrack = () => {
|
||||
const { stderr, stdout } = spawnSync('mpc', ['current'])
|
||||
return { error: stderr.toString(), track: stdout.toString() }
|
||||
@ -108,4 +119,5 @@ module.exports = {
|
||||
insertTrack,
|
||||
removeTrack,
|
||||
reset,
|
||||
poll,
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user