mirror of
https://github.com/zoriya/Aeris.git
synced 2026-05-30 09:50:49 +00:00
Handling multiple sumbstitutions on worker patterns
This commit is contained in:
@@ -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": []
|
||||
|
||||
@@ -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]
|
||||
|
||||
@@ -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 {};
|
||||
|
||||
Reference in New Issue
Block a user