Created
October 2, 2018 22:01
-
-
Save drewxa/50b4ecda67b335c8475f7c0bcd60fc1b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
вот как должен выглядеть код первокурсника, который использует вашу библиотеку | |
*/ | |
void MainCallback(const Alice::Request& req, AliceResponse& res) { | |
/* | |
главвный Callback, вызывается каждый раз когда приходит запрос и не поподает под другой Callback | |
*/ | |
// пока напишу выдуманный интерфейс, но не обращайте внимание будет ваш | |
res.SetText("Привет, я навык выполненный в качестве домашнего задания"); | |
res.Buttons().push_back(Alice::Button("first button")); | |
res.Buttons().push_back(Alice::Button("second button")); | |
res.SetImage(Alice::BigImage(/* Какие-то аргументы */)); | |
return; | |
} | |
void ButtonHandler1(const Alice::Request& req, AliceResponse& res) { | |
/* | |
тут код, который надо вызвать когда наживается первая кнопка | |
*/ | |
res.SetText("Кнопка 1 была нажата"); | |
} | |
void ButtonHandler2(const Alice::Request& req, AliceResponse& res) { | |
/* | |
тут код, который надо вызвать когда наживается вторая кнопка | |
*/ | |
res.SetText("Кнопка 2 была нажата"); | |
} | |
int main() { | |
Alice::Skill app(/* тут аргументы для инициализации */); | |
app.SetCallback(MainCallback); | |
app.AddButtonHandler("first button", ButtonHandler1); | |
app.AddButtonHandler("second button", ButtonHandler2); | |
app.run(); // Выше мы проинициализировали навык Алисы, а тут запускает навык и с этого момента он работает пока не завершится работа приложнеия | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment