Comments (4)
if you need to show random hint to every user, you can use ctx.state
inside the command body to generate hint.
game.command('подскажи', ctx => {
ctx.hint = getMyAwesomeHint()
ctx.reply( hint );
});
In that case ctx.hint
would be unique for each user.
from yandex-dialogs-sdk.
В моём примере мне нужно для игры в песни, получить случайную песню. Могу ли я сделать это и записать в контекст или объект игры?
По завершению игры, взять новую песню и так далее?
Грубо говоря песня это уже объект с набором своих правил. Идеальный сценарий это:
- Получил песню.
- Прикрепил к игре.
- Отыграл с юзером.
- Открепил.
from yandex-dialogs-sdk.
yep, you can do this because ctx.state
is attached to user id.
you can store js object here, but I advise you to store just songId
instead of full object.
- Create a collection with songs
const songs = { [songId]: [song] }
2. store `songId` in `ctx.state` after initialization.
3. flush `ctx.state.songId` after end of the game
from yandex-dialogs-sdk.
@fletcherist спасибо! Я так и сделаю!
from yandex-dialogs-sdk.
Related Issues (20)
- Alice is not a constructor HOT 2
- Unhandled promise rejection, on short commands.
- ctx.userId - inconsistent interaction issue HOT 1
- Scene.any (no such command) HOT 1
- TypeError: Cannot read property 'session' of undefined HOT 2
- Добавить событие response HOT 12
- ctx.enter into non existent scene doesn't throw an error
- Incorrect check of initial command HOT 3
- API хранение состояния в навыке
- Prettier Integration HOT 2
- Welcome работает неправильно HOT 1
- Figure doesnt work HOT 2
- Почему reply сам не может вызвать get у builder-а? HOT 1
- Более плавный переход от reply('текст') к reply с указанием tts. HOT 4
- Поддержка вариантивности в ответах на уровне SDK HOT 2
- Version 2.0 READ PLEASE HOT 2
- Программный выход из сцены HOT 3
- Непонятки с матчами команд HOT 10
- Не совсем понятно, как работают команды HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from yandex-dialogs-sdk.