Handling multiple sumbstitutions on worker patterns

This commit is contained in:
Zoe Roux
2022-03-05 01:30:45 +01:00
parent d7fe3ed98c
commit 3cb4896fb8
3 changed files with 11 additions and 7 deletions
+8
View File
@@ -143,6 +143,14 @@
"en": "Url of a track",
"fr": "Url d'une musique'"
}
},
{
"name": "playlistUri",
"type": "string",
"description": {
"en": "Id of the playlist",
"fr": "Id de la playlist dans laquelle ajouter la musique"
}
}
],
"returns": []
+1 -1
View File
@@ -27,7 +27,7 @@ export class Runner {
for (let [key, value] of Object.entries(params)) {
let newValue = value;
if (typeof value == "string") {
newValue = value.replace(/{(\w*)(?:@(\d))?}/, (_, name, index) => {
newValue = value.replace(/{(\w*)(?:@(\d))?}/g, (_, name, index) => {
if (index)
return this._history[parseInt(index)][name]
return this._history[this._history.length - 1][name]
+2 -6
View File
@@ -56,16 +56,12 @@ export class Spotify extends BaseService {
@reaction(ReactionType.PlayTrack, ['trackUri'])
async playTrack(params: any): Promise<PipelineEnv> {
await this._refreshIfNeeded();
// try {
await this._spotify.play({uris: [params.trackUri]});
// } catch (e) {
// throw new Error("Spotify premium is required.");
// }
await this._spotify.play({uris: [params.trackUri]});
return {};
}
@reaction(ReactionType.Pause, [])
async pause(params: any): Promise<PipelineEnv> {
async pause(_: any): Promise<PipelineEnv> {
await this._refreshIfNeeded();
await this._spotify.pause();
return {};