Merge remote-tracking branch 'origin/dev-1.x' into dev-1.x

This commit is contained in:
Alex Root Junior 2018-02-14 14:48:58 +02:00
commit 34c5ecd904
8 changed files with 21 additions and 22 deletions

View file

@ -1,13 +1,12 @@
import asyncio
import logging
import os import os
import logging
from http import HTTPStatus from http import HTTPStatus
import aiohttp import aiohttp
from .. import types from .. import types
from ..utils import exceptions
from ..utils import json from ..utils import json
from ..utils import exceptions
from ..utils.helper import Helper, HelperMode, Item from ..utils.helper import Helper, HelperMode, Item
# Main aiogram logger # Main aiogram logger

View file

@ -60,7 +60,7 @@ class Bot(BaseBot):
typing.Union[typing.List[base.String], None] = None) -> typing.List[types.Update]: typing.Union[typing.List[base.String], None] = None) -> typing.List[types.Update]:
""" """
Use this method to receive incoming updates using long polling (wiki). Use this method to receive incoming updates using long polling (wiki).
Notes Notes
1. This method will not work if an outgoing webhook is set up. 1. This method will not work if an outgoing webhook is set up.
2. In order to avoid getting duplicate updates, recalculate offset after each server response. 2. In order to avoid getting duplicate updates, recalculate offset after each server response.
@ -132,7 +132,7 @@ class Bot(BaseBot):
async def get_webhook_info(self) -> types.WebhookInfo: async def get_webhook_info(self) -> types.WebhookInfo:
""" """
Use this method to get current webhook status. Requires no parameters. Use this method to get current webhook status. Requires no parameters.
If the bot is using getUpdates, will return an object with the url field empty. If the bot is using getUpdates, will return an object with the url field empty.
Source: https://core.telegram.org/bots/api#getwebhookinfo Source: https://core.telegram.org/bots/api#getwebhookinfo
@ -180,7 +180,7 @@ class Bot(BaseBot):
:type chat_id: :obj:`typing.Union[base.Integer, base.String]` :type chat_id: :obj:`typing.Union[base.Integer, base.String]`
:param text: Text of the message to be sent :param text: Text of the message to be sent
:type text: :obj:`base.String` :type text: :obj:`base.String`
:param parse_mode: Send Markdown or HTML, if you want Telegram apps to show bold, italic, :param parse_mode: Send Markdown or HTML, if you want Telegram apps to show bold, italic,
fixed-width text or inline URLs in your bot's message. fixed-width text or inline URLs in your bot's message.
:type parse_mode: :obj:`typing.Union[base.String, None]` :type parse_mode: :obj:`typing.Union[base.String, None]`
:param disable_web_page_preview: Disables link previews for links in this message :param disable_web_page_preview: Disables link previews for links in this message
@ -190,7 +190,7 @@ class Bot(BaseBot):
:param reply_to_message_id: If the message is a reply, ID of the original message :param reply_to_message_id: If the message is a reply, ID of the original message
:type reply_to_message_id: :obj:`typing.Union[base.Integer, None]` :type reply_to_message_id: :obj:`typing.Union[base.Integer, None]`
:param reply_markup: Additional interface options. :param reply_markup: Additional interface options.
:type reply_markup: :obj:`typing.Union[types.InlineKeyboardMarkup, :type reply_markup: :obj:`typing.Union[types.InlineKeyboardMarkup,
types.ReplyKeyboardMarkup, types.ReplyKeyboardRemove, types.ForceReply, None]` types.ReplyKeyboardMarkup, types.ReplyKeyboardRemove, types.ForceReply, None]`
:return: On success, the sent Message is returned. :return: On success, the sent Message is returned.
:rtype: :obj:`types.Message` :rtype: :obj:`types.Message`

View file

@ -18,8 +18,8 @@ class Audio(base.TelegramObject, mixins.Downloadable):
def __hash__(self): def __hash__(self):
return hash(self.file_id) + \ return hash(self.file_id) + \
self.duration + \ self.duration + \
hash(self.performer) + \ hash(self.performer) + \
hash(self.title) + \ hash(self.title) + \
hash(self.mime_type) + \ hash(self.mime_type) + \
self.file_size self.file_size

View file

@ -40,7 +40,7 @@ class Chat(base.TelegramObject):
@property @property
def mention(self): def mention(self):
""" """
Get mention if dialog have username or full name if this is Private dialog otherwise None Get mention if a Chat has a username, or get full name if this is a Private Chat, otherwise None is returned
""" """
if self.username: if self.username:
return '@' + self.username return '@' + self.username
@ -51,7 +51,7 @@ class Chat(base.TelegramObject):
@property @property
def user_url(self): def user_url(self):
if self.type != ChatType.PRIVATE: if self.type != ChatType.PRIVATE:
raise TypeError('This property available only in private chats.') raise TypeError('`user_url` property is only available in private chats!')
return f"tg://user?id={self.id}" return f"tg://user?id={self.id}"

View file

@ -15,8 +15,8 @@ class BaseField(metaclass=abc.ABCMeta):
:param base: class for child element :param base: class for child element
:param default: default value :param default: default value
:param alias: alias name (for e.g. field named 'from' must be has name 'from_user' :param alias: alias name (for e.g. field 'from' has to be named 'from_user'
('from' is builtin Python keyword) as 'from' is a builtin Python keyword
""" """
self.base_object = base self.base_object = base
self.default = default self.default = default
@ -34,7 +34,7 @@ class BaseField(metaclass=abc.ABCMeta):
def get_value(self, instance): def get_value(self, instance):
""" """
Get value for current object instance Get value for the current object instance
:param instance: :param instance:
:return: :return:

View file

@ -18,8 +18,8 @@ class MessageEntity(base.TelegramObject):
def _apply(self, text, func): def _apply(self, text, func):
return text[:self.offset] + \ return text[:self.offset] + \
func(text[self.offset:self.offset + self.length]) + \ func(text[self.offset:self.offset + self.length]) + \
text[self.offset + self.length:] text[self.offset + self.length:]
def apply_md(self, text): def apply_md(self, text):
""" """

View file

@ -67,7 +67,7 @@ class ReplyKeyboardMarkup(base.TelegramObject):
:param button: :param button:
""" """
if self.keyboard and len(self.keyboard[-1] < self.row_width): if self.keyboard and len(self.keyboard[-1]) < self.row_width:
self.keyboard[-1].append(button) self.keyboard[-1].append(button)
else: else:
self.add(button) self.add(button)

View file

@ -14,13 +14,13 @@ dp = Dispatcher(bot)
@dp.message_handler(commands=['start']) @dp.message_handler(commands=['start'])
async def send_welcome(message: types.Message): async def send_welcome(message: types.Message):
# So... By first i want to send something like that: # So... At first I want to send something like this:
await message.reply("Do you want to see many pussies? Are you ready?") await message.reply("Do you want to see many pussies? Are you ready?")
# And wait few seconds... # And wait few seconds...
await asyncio.sleep(1) await asyncio.sleep(1)
# Good bots always must be send chat actions. Or not. # Good bots should send chat actions. Or not.
await ChatActions.upload_photo() await ChatActions.upload_photo()
# Create media group # Create media group