Skip to content

Commit

Permalink
Уточнение, что есть алисия.
Browse files Browse the repository at this point in the history
Ребрендинг тг чата.
  • Loading branch information
K1rL3s committed Feb 21, 2024
1 parent 6d74403 commit a883c9d
Show file tree
Hide file tree
Showing 12 changed files with 46 additions and 30 deletions.
4 changes: 2 additions & 2 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
blank_issues_enabled: true
contact_links:
- name: Связь по вопросам
url: https://t.me/aliceio_ru
- name: Связь по всем вопросам
url: https://t.me/aliceio_chat
about: ТГ Чат AliceIO
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@
<img alt="License" src="https://img.shields.io/pypi/l/aliceio.svg?style=flat-square">
<img alt="Status" src="https://img.shields.io/pypi/status/aliceio.svg?style=flat-square">
<img alt="PyPI" src="https://img.shields.io/pypi/v/aliceio?label=pypi&style=flat-square">
<img alt="Downloads" src="https://img.shields.io/pypi/dw/aliceio.svg?style=flat-square">
<img alt="Downloads" src="https://img.shields.io/pypi/dm/aliceio.svg?style=flat-square">
<img alt="Supported python versions" src="https://img.shields.io/pypi/pyversions/aliceio.svg?style=flat-square">
<img alt="Tests" src="https://img.shields.io/github/actions/workflow/status/K1rL3s/aliceio/tests.yml?style=flat-square">
</p>
<p align="center">
<b>
Асинхронный фреймворк для
Асинхронный фреймворк, упрощающий разработку
<a target="_blank" href="https://dialogs.yandex.ru/store">навыков Алисы</a>
из
<a target="_blank" href="https://dialogs.yandex.ru/development">Яндекс.Диалогов</a>
Expand All @@ -39,7 +39,7 @@


### Важно!
Настоятельно рекомендуется иметь опыт работы с [asyncio](https://docs.python.org/3/library/asyncio.html) перед использование **aliceio**
Настоятельно рекомендуется иметь опыт работы с [asyncio](https://docs.python.org/3/library/asyncio.html) перед использованием **aliceio**


## Быстрый старт
Expand Down Expand Up @@ -83,7 +83,7 @@ if __name__ == "__main__":

## Связь
Если у вас есть вопросы, вы можете посетить чат сообщества в Telegram
- 🇷🇺 [\@aliceio_ru](https://t.me/aliceio_ru)
- 🇷🇺 [\@aliceio_chat](https://t.me/aliceio_chat)


## Лицензия
Expand Down
7 changes: 5 additions & 2 deletions aliceio/dispatcher/dispatcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def __init__(
# экземпляров пользователя и сессиив контексте событий.
self.update.outer_middleware(UserContextMiddleware())

storage = self._init_storage(storage, disable_fsm, use_api_storage)
storage = self._create_storage(storage, disable_fsm, use_api_storage)
# FSMContextMiddleware всегда следует регистрировать после UserContextMiddleware
# поскольку здесь используется контекст из предыдущего шага.
self.fsm = FSMContextMiddleware(
Expand Down Expand Up @@ -126,8 +126,11 @@ def parent_router(self, value: Router) -> None:
"""
raise RuntimeError("Dispatcher can not be attached to another Router.")

# Правильнее всего будет оставить только одно условие `storage is not None`,
# а после возвращать MemoryStorage. Но что-то может произойти с ApiStorage'ом,
# поэтому пока так
@staticmethod
def _init_storage(
def _create_storage(
storage: Optional[BaseStorage],
disable_fsm: bool,
use_api_storage: bool,
Expand Down
13 changes: 6 additions & 7 deletions aliceio/fsm/middlewares/api_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,16 @@ async def pre_set_state(self, event: Update, fsm_context: FSMContext) -> None:

def resolve_state_data(self, state: Optional[ApiState]) -> ApiStorageRecord:
if state is None:
return self._data_to_record({})
return self.create_record_from_data({})
if self.strategy == FSMStrategy.USER:
return self._data_to_record(state.user)
return self.create_record_from_data(state.user)
if self.strategy == FSMStrategy.SESSION:
return self._data_to_record(state.session)
return self.create_record_from_data(state.session)
if self.strategy == FSMStrategy.APPLICATION:
return self._data_to_record(state.application)
return self._data_to_record(state.session)
return self.create_record_from_data(state.application)
return self.create_record_from_data(state.session)

@staticmethod
def _data_to_record(data: Dict[str, Any]) -> ApiStorageRecord:
def create_record_from_data(self, data: Dict[str, Any]) -> ApiStorageRecord:
return ApiStorageRecord(data=data.get("data", {}), state=data.get("state"))

async def post_update_state(
Expand Down
4 changes: 3 additions & 1 deletion aliceio/webhook/aiohttp_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,9 +179,11 @@ async def handle(self, request: web.Request) -> web.Response:
def _convert_show_pull_to_normal_request(update: Dict[str, Any]) -> Dict[str, Any]:
"""
При получении события запуска утреннего шоу вся информация
(мета, сессия, версия и реквест) находится по ключу body.
(мета, сессия, версия и реквест) вероятно находится по ключу body.
Эта функция выносит всю информацию за это поле.
https://yandex.ru/dev/dialogs/alice/doc/request-show-pull.html
:param update:
:return:
"""
Expand Down
2 changes: 1 addition & 1 deletion docs/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,4 +118,4 @@ mkdosc serve

## Связь

Заходите в наш [тг-чатик](https://t.me/aliceio_ru){:target="_blank"}, задавайте и отвечайте на вопросы
Заходите в наш [тг-чатик](https://t.me/aliceio_chat){:target="_blank"}, задавайте и отвечайте на вопросы
3 changes: 3 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Хаб

Добро пожаловать в документацию AliceIO!
Алисия - это асинхронный фреймворк на [python](https://www.python.org/){:target="_blank"},
упрощающий разработку [навыков Алисы](https://dialogs.yandex.ru/store){:target="_blank"}
из [Яндекс.Диалогов](https://dialogs.yandex.ru/development){:target="_blank"}.

Начинающим рекомендуется ознакомиться с [туториалом](tutorial/index.md).
Знание Python'а приветствуется и рекомендуется.
Expand Down
2 changes: 1 addition & 1 deletion docs/install.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Установка

## Через PyPI
## Через [PyPI](https://pypi.org/project/aliceio/){:target="_blank"}

```bash
pip install -U aliceio
Expand Down
9 changes: 9 additions & 0 deletions docs/tutorial/start.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,15 @@

## [Код](https://github.com/K1rL3s/aliceio/blob/master/examples/fast_start.py){:target="_blank"}

> Если вы ещё не установили библиотеку, то это можно сделать так:
> ```bash
> pip install -U aliceio
> ```
> Или:
> ```bash
> python -m pip install -U aliceio
> ```

Самый простой навык, который умеет только приветствовать пользователя. \
Скопируйте его, укажите айди вашего навыка и запустите скрипт.

Expand Down
6 changes: 3 additions & 3 deletions examples/fsm_form.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,9 @@ def show_summary(data: Dict[str, Any], positive: bool = True) -> str:


def main() -> None:
# use_api_storage можно и на False,
# тогда будет использоваться хранилище на текущей машине
dp = Dispatcher(use_api_storage=True, response_timeout=10**9)
# use_api_storage можно и на True,
# тогда будет использоваться хранилище на стороне Алисы
dp = Dispatcher(use_api_storage=False)
dp.include_router(form_router)

skill_id = os.environ["SKILL_ID"]
Expand Down
2 changes: 1 addition & 1 deletion mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ extra:
disqus: ""
social:
- icon: fontawesome/brands/telegram
link: https://t.me/aliceio_ru
link: https://t.me/aliceio_chat
name: Наш ТГ чат

nav:
Expand Down
16 changes: 8 additions & 8 deletions tests/test_dispatcher/test_dispatcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,35 +232,35 @@ class MyStorage(MemoryStorage):
my_storage = MyStorage()

assert (
dp._init_storage(my_storage, disable_fsm=False, use_api_storage=False)
dp._create_storage(my_storage, disable_fsm=False, use_api_storage=False)
== my_storage
)
assert (
dp._init_storage(my_storage, disable_fsm=False, use_api_storage=True)
dp._create_storage(my_storage, disable_fsm=False, use_api_storage=True)
== my_storage
)
assert (
dp._init_storage(my_storage, disable_fsm=True, use_api_storage=False)
dp._create_storage(my_storage, disable_fsm=True, use_api_storage=False)
== my_storage
)
assert (
dp._init_storage(my_storage, disable_fsm=True, use_api_storage=True)
dp._create_storage(my_storage, disable_fsm=True, use_api_storage=True)
== my_storage
)

assert isinstance(
dp._init_storage(None, disable_fsm=False, use_api_storage=False),
dp._create_storage(None, disable_fsm=False, use_api_storage=False),
MemoryStorage,
)
assert isinstance(
dp._init_storage(None, disable_fsm=False, use_api_storage=True),
dp._create_storage(None, disable_fsm=False, use_api_storage=True),
ApiStorage,
)
assert isinstance(
dp._init_storage(None, disable_fsm=True, use_api_storage=False),
dp._create_storage(None, disable_fsm=True, use_api_storage=False),
MemoryStorage,
)
assert isinstance(
dp._init_storage(None, disable_fsm=True, use_api_storage=True),
dp._create_storage(None, disable_fsm=True, use_api_storage=True),
MemoryStorage,
)

0 comments on commit a883c9d

Please sign in to comment.