-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
reworked environments; updated docs; added features; changed version;
- Loading branch information
1 parent
0ce9441
commit 607ed9a
Showing
43 changed files
with
835 additions
and
651 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
{ | ||
"token": "" | ||
"vk_token": "" | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
{ | ||
"token": "", | ||
"utoken": "" | ||
} | ||
"vk_token": "", | ||
"vk_utoken": "" | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
Controller | ||
========== | ||
|
||
Description | ||
^^^^^^^^^^^ | ||
|
||
Controllers are responsible for receiving updates and sending responses. | ||
Often adding new source (like vk.com) requires creation of two things: | ||
controller and normalizer. | ||
|
||
- Controller just exchanges messages, oversees over this exchange and | ||
provides means to interact with service to callbacks throught environment. | ||
- Normalizer turns updates from raw data to instances of classes | ||
:class:`.Message` and :class:`.Attachment` if possible. These objects are | ||
then passed to plugins. They should only create instances of messages | ||
without editing environment. | ||
|
||
These files are placed in folders "kutana/controllers" and | ||
"kutana/plugins/converters". | ||
|
||
Custom controller | ||
^^^^^^^^^^^^^^^^^ | ||
|
||
You can simply fill required methods from :class:`kutana.BasicController`. | ||
Use :class:`.DumpingController` as example and it's files in folders | ||
"controllers" and "converters" with its names. | ||
|
||
.. autoclass:: kutana.BasicController | ||
:members: | ||
|
||
.. note:: | ||
You don't have to create your own controllers if you don't want to. |
This file was deleted.
Oops, something went wrong.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
Executor | ||
======== | ||
|
||
Description | ||
^^^^^^^^^^^ | ||
|
||
This class collects coroutines for updates processing and calls | ||
them with the appropriate data. These coroutines receive the update itself | ||
and the dictionary-like environment with data that could be written | ||
there by previous and read by next coroutine calls. You can register | ||
These callbacks with executor's :func:`subscribe` as method or decorator. | ||
Environment has "ctrl_type" set to the type of update's controller | ||
(VKontakte, Telegram, etc.). | ||
|
||
.. code-block:: python | ||
@kutana.executor.subscribe() | ||
async def prc(update, eenv): | ||
# eenv stands for "executor's environment" | ||
await eenv.reply("Ого, эхо!") | ||
Same as | ||
|
||
.. code-block:: python | ||
async def prc(update, eenv): | ||
await env.reply("Ого, эхо!") | ||
kutana.executor.subscribe(prc) | ||
All coroutine callbacks will be called in order they were added until | ||
one of the coroutines returns **"DONE"** or none coroutines left. | ||
|
||
You can register callbacks on exceptions in normal callbacks like that. | ||
Exception accesible from eenv.exception in error callbacks. | ||
|
||
.. code-block:: python | ||
async def prc(update, eenv): | ||
await env.reply("Error happened c:") | ||
kutana.executor.subscribe(prc, error=True) | ||
.. note:: | ||
You can't and shouldn't create or use your own executors. It's just | ||
convenient collector and executor of callbacks. |
This file was deleted.
Oops, something went wrong.
This file contains 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
Oops, something went wrong.