mirror of https://github.com/icedream/ts3bot.git
Implement "time" command.
Aliases: "seek", "pos", "position" This command sets the current position in the playing item, time can be given as an argument of any sensible form like "2m 3s", "2m03s", "2:03" or "2m". This command returns the current position in the playing item if given no arguments.develop
parent
a74b923de0
commit
592872f97d
15
app.iced
15
app.iced
|
@ -11,6 +11,8 @@ qs = require "querystring"
|
|||
temp = require("temp").track()
|
||||
youtubedl = require "youtube-dl"
|
||||
isValidUrl = (require "valid-url").isWebUri
|
||||
parseDuration = require "./parse_duration.iced"
|
||||
prettyMs = require "pretty-ms"
|
||||
|
||||
log = getLogger "Main"
|
||||
|
||||
|
@ -246,6 +248,19 @@ ts3clientService.on "started", (ts3proc) =>
|
|||
|
||||
# play it in VLC
|
||||
vlc.play info.url
|
||||
when "time", "seek", "pos", "position"
|
||||
inputBB = paramline.trim()
|
||||
input = (removeBB paramline).trim()
|
||||
|
||||
# we gonna interpret no argument as us needing to return the current position
|
||||
if input.length <= 0
|
||||
ts3query.sendtextmessage args.targetmode, invoker.id, "Currently position is #{prettyMs vlc.input.time}."
|
||||
return
|
||||
|
||||
ts3query.sendtextmessage args.targetmode, invoker.id, "Seeking to #{prettyMs vlc.input.time}."
|
||||
vlc.input.time = parseDuration input
|
||||
|
||||
return
|
||||
when "stop-after"
|
||||
vlc.playlist.mode = vlc.playlist.Single
|
||||
ts3query.sendtextmessage args.targetmode, invoker.id, "Playback will stop after the current playlist item."
|
||||
|
|
|
@ -31,9 +31,12 @@
|
|||
"iced-coffee-script": "^108.0.8",
|
||||
"merge": "^1.2.0",
|
||||
"mkdirp": "^0.5.1",
|
||||
"named-regexp": "^0.1.1",
|
||||
"nconf": "^0.7.2",
|
||||
"npm-which": "^2.0.0",
|
||||
"parse-duration": "^0.1.1",
|
||||
"password-generator": "^2.0.1",
|
||||
"pretty-ms": "^2.1.0",
|
||||
"querystring": "^0.2.0",
|
||||
"request": "^2.61.0",
|
||||
"simple-ini": "^1.0.3",
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
parseDuration = require "parse-duration"
|
||||
namedRegex = require("named-regexp").named
|
||||
|
||||
durationRegex = namedRegex /^(((:<h>[0-9]{0,2}):)?(:<m>[0-9]{0,2}):)?(:<s>[0-9]{0,2})(:<ms>\.[0-9]*)?$/
|
||||
|
||||
module.exports = (str) ->
|
||||
# check if this is in the colon-separated format
|
||||
if str.indexOf(":") > -1 and str.match durationRegex
|
||||
m = durationRegex.exec(str).matches
|
||||
return m["ms"] + m["s"]*60 + m["m"]*(60*60) + m["h"]*(60*60*60)
|
||||
|
||||
parseDuration str
|
Loading…
Reference in New Issue