Giter Club home page Giter Club logo

baseskill's Introduction

BaseSkill

Фреймворк для разработки навыков Алисы на Python
❗️ Адаптирован под хостинг PythonAnyWhere ❗️

Мастер-класс

https://vk.com/video-181060886_456239027

А как он в плане...?

Примеры навыков, реализованных на данном фреймворке

Веселые минитесты

GitHub - https://github.com/itookyourboo/alice_minitest
Алиса - https://dialogs.yandex.ru/store/skills/79dc14f5-veselye-minitesty

Имя для питомца

GitHub - https://github.com/itookyourboo/animal-names
Алиса - https://dialogs.yandex.ru/store/skills/9a733c88-imya-dlya-pitom

Как использовать

Создаём папку test_skill, в которой будут храниться все файлы вашего навыка

states.py

Содержит enum-класс, в котором прописаны состояния/уровни/комнаты (как хотите, так и называйте)

strings.py

Содержит все строковые ресурсы, чтобы избавиться от хардкода в главном файле

main.py (пример):

Паспорт навыка

class TestSkill(BaseSkill):
    name = 'test_skill'
    command_handler = handler

Обработка команд

handler = CommandHandler()

# Приветственное сообщение
@handler.hello_command
def hello(req, res, session):
    res.text = 'Привет'
    session['state'] = State.MENU
    
# Обработка токенов
# Есть заготовленные команды
@handler.command(words=['да', 'ага'], states=State.MENU)
def yes(req, res, session):
    res.text = 'Вы ответили положительно'
    session['state'] = State.PLAY
    
# Обработка пользовательского ввода
# Когда нет заготовленных команд
@handler.undefined_command(states=State.PLAY)
def play(req, res, session):
    if YOUR_WORD in req.tokens:
        res.text = 'Молодец!'
    else:
        res.text = 'Подумай ещё'

flask_app.py

Здесь импортируем все наши навыки и кладём их в SKILLS

from test_skill import TestSkill
from another_skill import AnotherSkill
...

SKILLS = [TestSkill(), AnotherSkill(), ...]

baseskill's People

Contributors

itookyourboo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.