fletcherist / yandex-dialogs-sdk

☂️Build your skill for Yandex.Alice with ease. (nodejs/typescript)
MIT License
122 stars 16 forks source link

Incorrect check of initial command #117

Closed nordluf closed 4 years ago

nordluf commented 5 years ago

Main app:

'use strict';

const { reply } = require('alice-renderer');
const { Alice } = require('yandex-dialogs-sdk');

const alice = new Alice();

alice.command('команда', () => reply`команда `);
alice.command('длинная команда', () => reply`длинная команда`);
alice.command('', () => reply`команда приветствие`);

alice.listen(8000, '/');

$ node testapp.js

Test app:

$ cat testtest.js 
'use strict';

const User = require('alice-tester');
const user = new User('http://localhost:8000/');
user.enter().then(() => {
  console.log(user.response);
});

$ node testtest.js
{ text: 'длинная команда',
  tts: 'длинная команда',
  end_session: false }
nordluf commented 5 years ago

Probably that happens because of this check: https://github.com/fletcherist/yandex-dialogs-sdk/blob/master/src/utils/textRelevance.ts#L14 As initial command is empty, relevance calculates as the length of a command

fletcherist commented 5 years ago

thanks. created a fix at https://github.com/fletcherist/yandex-dialogs-sdk/commit/ccf2cb294e02ef08824a726b3d229f0b9c54982a

fletcherist commented 4 years ago

@vanyaklimenko are u alive?