Merge pull request #6 from surik00/dev-1.x

Grammar.
This commit is contained in:
Alex Root Junior 2018-01-23 23:38:31 +02:00 committed by GitHub
commit 3cfc0e44d8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
17 changed files with 56 additions and 40 deletions

View file

@ -8,7 +8,7 @@
[![Github issues](https://img.shields.io/github/issues/aiogram/aiogram.svg?style=flat-square)](https://github.com/aiogram/aiogram/issues) [![Github issues](https://img.shields.io/github/issues/aiogram/aiogram.svg?style=flat-square)](https://github.com/aiogram/aiogram/issues)
[![MIT License](https://img.shields.io/pypi/l/aiogram.svg?style=flat-square)](https://opensource.org/licenses/MIT) [![MIT License](https://img.shields.io/pypi/l/aiogram.svg?style=flat-square)](https://opensource.org/licenses/MIT)
**aiogram** is are pretty simple and fully asynchronously library for [Telegram Bot API](https://core.telegram.org/bots/api) written in Python 3.6 with [asyncio](https://docs.python.org/3/library/asyncio.html) and [aiohttp](https://github.com/aio-libs/aiohttp). It helps to make your bots more faster and simpler. **aiogram** is a pretty simple and fully asynchronous library for [Telegram Bot API](https://core.telegram.org/bots/api) written in Python 3.6 with [asyncio](https://docs.python.org/3/library/asyncio.html) and [aiohttp](https://github.com/aio-libs/aiohttp). It helps you to make your bots faster and simpler.
You can [read the docs here](http://aiogram.readthedocs.io/en/latest/). You can [read the docs here](http://aiogram.readthedocs.io/en/latest/).

View file

@ -30,7 +30,7 @@ AIOGramBot
:alt: MIT License :alt: MIT License
**aiogram** is are pretty simple and fully asynchronously library for `Telegram Bot API <https://core.telegram.org/bots/api>`_ written in Python 3.6 with `asyncio <https://docs.python.org/3/library/asyncio.html>`_ and `aiohttp <https://github.com/aio-libs/aiohttp>`_. It helps to make your bots more faster and simpler. **aiogram** is a pretty simple and fully asynchronous library for `Telegram Bot API <https://core.telegram.org/bots/api>`_ written in Python 3.6 with `asyncio <https://docs.python.org/3/library/asyncio.html>`_ and `aiohttp <https://github.com/aio-libs/aiohttp>`_. It helps you to make your bots faster and simpler.
You can `read the docs here <http://aiogram.readthedocs.io/en/latest/>`_. You can `read the docs here <http://aiogram.readthedocs.io/en/latest/>`_.

View file

@ -4,7 +4,8 @@ try:
from .bot import Bot from .bot import Bot
except ImportError as e: except ImportError as e:
if e.name == 'aiohttp': if e.name == 'aiohttp':
warnings.warn('Dependencies is not installed!', category=ImportWarning) warnings.warn('Dependencies are not installed!',
category=ImportWarning)
else: else:
raise raise

View file

@ -1,5 +1,5 @@
""" """
Need setup task factory: You need to setup task factory:
>>> from aiogram.utils import context >>> from aiogram.utils import context
>>> loop = asyncio.get_event_loop() >>> loop = asyncio.get_event_loop()
>>> loop.set_task_factory(context.task_factory) >>> loop.set_task_factory(context.task_factory)

View file

@ -51,7 +51,8 @@ def start_pooling(*args, **kwargs):
return start_polling(*args, **kwargs) return start_polling(*args, **kwargs)
def start_polling(dispatcher, *, loop=None, skip_updates=False, on_startup=None, on_shutdown=None): def start_polling(dispatcher, *, loop=None, skip_updates=False,
on_startup=None, on_shutdown=None):
log.warning('Start bot with long-polling.') log.warning('Start bot with long-polling.')
if loop is None: if loop is None:
loop = dispatcher.loop loop = dispatcher.loop
@ -59,7 +60,7 @@ def start_polling(dispatcher, *, loop=None, skip_updates=False, on_startup=None,
loop.set_task_factory(context.task_factory) loop.set_task_factory(context.task_factory)
try: try:
loop.run_until_complete(_startup(dispatcher, skip_updates=skip_updates, callback=on_startup)) loop.run_until_complete(_startup(dispatcher, skip_updates, on_startup))
loop.create_task(dispatcher.start_polling(reset_webhook=True)) loop.create_task(dispatcher.start_polling(reset_webhook=True))
loop.run_forever() loop.run_forever()
except (KeyboardInterrupt, SystemExit): except (KeyboardInterrupt, SystemExit):
@ -69,8 +70,8 @@ def start_polling(dispatcher, *, loop=None, skip_updates=False, on_startup=None,
log.warning("Goodbye!") log.warning("Goodbye!")
def start_webhook(dispatcher, webhook_path, *, loop=None, skip_updates=None, on_startup=None, on_shutdown=None, def start_webhook(dispatcher, webhook_path, *, loop=None, skip_updates=None,
check_ip=False, **kwargs): on_startup=None, on_shutdown=None, check_ip=False, **kwargs):
log.warning('Start bot with webhook.') log.warning('Start bot with webhook.')
if loop is None: if loop is None:
loop = dispatcher.loop loop = dispatcher.loop

View file

@ -137,7 +137,8 @@ class Item:
""" """
Helper item Helper item
If value is not configured it will be generated automatically based on variable name If a value is not provided,
it will be automatically generated based on a variable's name
""" """
def __init__(self, value=None): def __init__(self, value=None):
@ -156,7 +157,7 @@ class Item:
class ListItem(Item): class ListItem(Item):
""" """
This item always is list This item is always a list
You can use &, | and + operators for that. You can use &, | and + operators for that.
""" """
@ -179,7 +180,7 @@ class ItemsList(list):
""" """
Patch for default list Patch for default list
This class provide +, &, |, +=, &=, |= operators for extending the list This class provides +, &, |, +=, &=, |= operators for extending the list
""" """
def __init__(self, *seq): def __init__(self, *seq):

View file

@ -18,6 +18,8 @@ HTML_QUOTES_MAP = {
'"': '&quot;' '"': '&quot;'
} }
_HQS = HTML_QUOTES_MAP.keys() # HQS for HTML QUOTES SYMBOLS
def _join(*content, sep=' '): def _join(*content, sep=' '):
return sep.join(map(str, content)) return sep.join(map(str, content))
@ -38,21 +40,22 @@ def quote_html(content):
""" """
Quote HTML symbols Quote HTML symbols
All <, > and & symbols that are not a part of a tag or an HTML entity All <, >, & and " symbols that are not a part of a tag or
must be replaced with the corresponding HTML entities (< with &lt;, > with &gt; and & with &amp;). an HTML entity must be replaced with the corresponding HTML entities
(< with &lt; > with &gt; & with &amp and " with &quot).
:param content: str :param content: str
:return: str :return: str
""" """
new_content = '' new_content = ''
for symbol in content: for symbol in content:
new_content += HTML_QUOTES_MAP[symbol] if symbol in '<>&"' else symbol new_content += HTML_QUOTES_MAP[symbol] if symbol in _HQS else symbol
return new_content return new_content
def text(*content, sep=' '): def text(*content, sep=' '):
""" """
Join all elements with separator Join all elements with a separator
:param content: :param content:
:param sep: :param sep:
@ -168,7 +171,7 @@ def hlink(title, url):
:param url: :param url:
:return: :return:
""" """
return "<a href=\"{0}\">{1}</a>".format(url, quote_html(title)) return '<a href="{0}">{1}</a>'.format(url, quote_html(title))
def escape_md(*content, sep=' '): def escape_md(*content, sep=' '):

View file

@ -9,7 +9,8 @@ from .helper import Helper, HelperMode, Item
class Version: class Version:
def __init__(self, major=0, minor=0, maintenance=0, stage='final', build=0): def __init__(self, major=0, minor=0,
maintenance=0, stage='final', build=0):
self.__raw_version = None self.__raw_version = None
self.__version = None self.__version = None
@ -86,7 +87,8 @@ class Version:
if git_changeset: if git_changeset:
sub = '.dev{0}'.format(git_changeset) sub = '.dev{0}'.format(git_changeset)
elif version[3] != Stage.FINAL: elif version[3] != Stage.FINAL:
mapping = {Stage.ALPHA: 'a', Stage.BETA: 'b', Stage.RC: 'rc', Stage.DEV: 'dev'} mapping = {Stage.ALPHA: 'a', Stage.BETA: 'b',
Stage.RC: 'rc', Stage.DEV: 'dev'}
sub = mapping[version[3]] + str(version[4]) sub = mapping[version[3]] + str(version[4])
return str(main + sub) return str(main + sub)

View file

@ -1,7 +1,7 @@
BaseBot BaseBot
======= =======
This class is base of bot. In BaseBot implemented only methods for interactions with Telegram Bot API. This class is the base class for bot. BaseBot implements only methods for interaction with Telegram Bot API.
.. autoclass:: aiogram.bot.base.BaseBot .. autoclass:: aiogram.bot.base.BaseBot
:members: :members:

View file

@ -1,8 +1,8 @@
Bot object Bot object
========== ==========
That is extended (and recommended for usage) bot class based on BaseBot class. This is extended (and recommended for use) bot class based on BaseBot class.
You can use instance of that bot in :obj:`aiogram.dispatcher.Dispatcher` You can use an instance of this bot in :obj:`aiogram.dispatcher.Dispatcher`
.. autoclass:: aiogram.bot.bot.Bot .. autoclass:: aiogram.bot.bot.Bot
:members: :members:

View file

@ -16,3 +16,10 @@ Redis storage
.. automodule:: aiogram.contrib.fsm_storage.redis .. automodule:: aiogram.contrib.fsm_storage.redis
:members: :members:
:show-inheritance: :show-inheritance:
RethinkDB storage
-----------------
.. automodule:: aiogram.contrib.fsm_storage.rethinkdb
:members:
:show-inheritance:

View file

@ -1,7 +1,7 @@
Filters Filters
------- -------
In this module stored builtin filters for dispatcher. This module stores builtin filters for dispatcher.
.. automodule:: aiogram.dispatcher.filters .. automodule:: aiogram.dispatcher.filters
:members: :members:

View file

@ -1,7 +1,7 @@
Storages Storages
-------- --------
In this module stored base of storage's for finite-state machine. This module stores storage base for finite-state machine.
.. automodule:: aiogram.dispatcher.storage .. automodule:: aiogram.dispatcher.storage
:members: :members:

View file

@ -27,7 +27,7 @@ Welcome to aiogram's documentation!
:alt: MIT License :alt: MIT License
**aiogram** is are pretty simple and fully asynchronously library for `Telegram Bot API <https://core.telegram.org/bots/api>`_ written in Python 3.6 with `asyncio <https://docs.python.org/3/library/asyncio.html>`_ and `aiohttp <https://github.com/aio-libs/aiohttp>`_. It helps to make your bots more faster and simpler. **aiogram** is a pretty simple and fully asynchronous library for `Telegram Bot API <https://core.telegram.org/bots/api>`_ written in Python 3.6 with `asyncio <https://docs.python.org/3/library/asyncio.html>`_ and `aiohttp <https://github.com/aio-libs/aiohttp>`_. It helps you to make your bots faster and simpler.
Official aiogram resources Official aiogram resources
@ -45,17 +45,17 @@ Features
-------- --------
- Asynchronous - Asynchronous
- Be awesome - Awesome
- Make things faster - Makes things faster
- Have `FSM <https://en.wikipedia.org/wiki/Finite-state_machine>`_ - Has `FSM <https://en.wikipedia.org/wiki/Finite-state_machine>`_
- Can reply into webhook - Can reply into webhook. (In other words `make requests in response to updates <https://core.telegram.org/bots/faq#how-can-i-make-requests-in-response-to-updates>`_)
Contribute Contribute
---------- ----------
- `Issue Tracker <https://bitbucket.org/illemius/aiogram/issues>`_ - `Issue Tracker <https://github.com/aiogram/aiogram/issues>`_
- `Source Code <https://bitbucket.org/illemius/aiogram.git>`_ - `Source Code <https://github.com/aiogram/aiogram.git>`_
Contents Contents

View file

@ -1,8 +1,8 @@
Installation Guide Installation Guide
================== ==================
From PIP Using PIP
-------- ---------
.. code-block:: bash .. code-block:: bash
$ pip install -U aiogram $ pip install -U aiogram
@ -11,5 +11,6 @@ From sources
------------ ------------
.. code-block:: bash .. code-block:: bash
$ git clone https://bitbucket.org/illemius/aiogram.git $ git clone https://github.com/aiogram/aiogram.git
$ cd aiogram
$ python setup.py install $ python setup.py install

View file

@ -4,15 +4,15 @@ Quick start
Simple template Simple template
--------------- ---------------
By first step you need import all modules At first you have to import all necessary modules
.. code-block:: python3 .. code-block:: python3
from aiogram import Bot from aiogram import Bot, types
from aiogram.dispatcher import Dispatcher from aiogram.dispatcher import Dispatcher
from aiogram.utils import executor from aiogram.utils import executor
In next step you you can initialize bot and dispatcher instances. Then you have to initialize bot and dispatcher instances.
Bot token you can get from `@BotFather <https://t.me/BotFather>`_ Bot token you can get from `@BotFather <https://t.me/BotFather>`_
@ -21,7 +21,7 @@ Bot token you can get from `@BotFather <https://t.me/BotFather>`_
bot = Bot(token='BOT TOKEN HERE') bot = Bot(token='BOT TOKEN HERE')
dp = Dispatcher(bot) dp = Dispatcher(bot)
And next: all bots is needed command for starting interaction with bot. Register first command handler: Next step: interaction with bots starts with one command. Register your first command handler:
.. code-block:: python3 .. code-block:: python3
@ -29,7 +29,7 @@ And next: all bots is needed command for starting interaction with bot. Registe
async def send_welcome(message: types.Message): async def send_welcome(message: types.Message):
await message.reply("Hi!\nI'm EchoBot!\nPowered by aiogram.") await message.reply("Hi!\nI'm EchoBot!\nPowered by aiogram.")
And last step - run long polling. Last step: run long polling.
.. code-block:: python3 .. code-block:: python3
@ -41,7 +41,7 @@ Summary
.. code-block:: python3 .. code-block:: python3
from aiogram import Bot from aiogram import Bot, types
from aiogram.dispatcher import Dispatcher from aiogram.dispatcher import Dispatcher
from aiogram.utils import executor from aiogram.utils import executor

View file

@ -44,7 +44,7 @@ setup(
license='MIT', license='MIT',
author='Alex Root Junior', author='Alex Root Junior',
author_email='jroot.junior@gmail.com', author_email='jroot.junior@gmail.com',
description='Is are pretty simple and fully asynchronously library for Telegram Bot API', description='Is a pretty simple and fully asynchronous library for Telegram Bot API',
long_description=get_description(), long_description=get_description(),
classifiers=[ classifiers=[
VERSION.pypi_development_status, # Automated change classifier by build stage VERSION.pypi_development_status, # Automated change classifier by build stage