mirror of
https://github.com/TeamPGM/pyrogram.git
synced 2024-11-18 13:34:54 +00:00
Merge branch 'develop' into asyncio
# Conflicts: # pyrogram/connection/transport/tcp/tcp.py
This commit is contained in:
commit
41acdd4d63
@ -33,7 +33,7 @@ Examples (more on `GitHub <https://github.com/pyrogram/pyrogram/tree/develop/exa
|
||||
Raw Functions
|
||||
-------------
|
||||
|
||||
If you can't find a high-level method for your needs or if want complete, low-level access to the whole Telegram API,
|
||||
If you can't find a high-level method for your needs or if you want complete, low-level access to the whole Telegram API,
|
||||
you have to use the raw :mod:`functions <pyrogram.api.functions>` and :mod:`types <pyrogram.api.types>` exposed by the
|
||||
``pyrogram.api`` package and call any Telegram API method you wish using the :meth:`send() <pyrogram.Client.send>`
|
||||
method provided by the Client class.
|
||||
|
@ -90,6 +90,10 @@ class Client(Methods, BaseClient):
|
||||
Code of the language used on the client, in ISO 639-1 standard. Defaults to "en".
|
||||
This is an alternative way to set it if you don't want to use the *config.ini* file.
|
||||
|
||||
ipv6 (``bool``, *optional*):
|
||||
Pass True to connect to Telegram using IPv6.
|
||||
Defaults to False (IPv4).
|
||||
|
||||
proxy (``dict``, *optional*):
|
||||
Your SOCKS5 Proxy settings as dict,
|
||||
e.g.: *dict(hostname="11.22.33.44", port=1080, username="user", password="pass")*.
|
||||
|
@ -36,6 +36,28 @@ class EditMessageMedia(BaseClient):
|
||||
message_id: int,
|
||||
media,
|
||||
reply_markup=None):
|
||||
"""Use this method to edit audio, document, photo, or video messages.
|
||||
|
||||
If a message is a part of a message album, then it can be edited only to a photo or a video. Otherwise,
|
||||
message type can be changed arbitrarily. When inline message is edited, new file can't be uploaded.
|
||||
Use previously uploaded file via its file_id or specify a URL. On success, if the edited message was sent
|
||||
by the bot, the edited Message is returned, otherwise True is returned.
|
||||
|
||||
Args:
|
||||
chat_id (``int`` | ``str``):
|
||||
Unique identifier (int) or username (str) of the target chat.
|
||||
For your personal cloud (Saved Messages) you can simply use "me" or "self".
|
||||
For a contact that exists in your Telegram address book you can use his phone number (str).
|
||||
|
||||
message_id (``int``):
|
||||
Message identifier in the chat specified in chat_id.
|
||||
|
||||
media (:obj:`InputMediaAnimation` | :obj:`InputMediaAudio` | :obj:`InputMediaDocument` | :obj:`InputMediaPhoto` | :obj:`InputMediaVideo`)
|
||||
One of the InputMedia objects describing an animation, audio, document, photo or video.
|
||||
|
||||
reply_markup (:obj:`InlineKeyboardMarkup`, *optional*):
|
||||
An InlineKeyboardMarkup object.
|
||||
"""
|
||||
style = self.html if media.parse_mode.lower() == "html" else self.markdown
|
||||
caption = media.caption
|
||||
|
||||
|
@ -19,6 +19,7 @@
|
||||
import asyncio
|
||||
import logging
|
||||
import socket
|
||||
import ipaddress
|
||||
|
||||
try:
|
||||
import socks
|
||||
@ -37,31 +38,43 @@ class TCP:
|
||||
TIMEOUT = 10
|
||||
|
||||
def __init__(self, ipv6: bool, proxy: dict):
|
||||
self.proxy = proxy
|
||||
|
||||
self.lock = asyncio.Lock()
|
||||
|
||||
self.socket = socks.socksocket(family=socket.AF_INET6 if ipv6 else socket.AF_INET)
|
||||
|
||||
self.socket.settimeout(TCP.TIMEOUT)
|
||||
self.socket = None
|
||||
|
||||
self.reader = None # type: asyncio.StreamReader
|
||||
self.writer = None # type: asyncio.StreamWriter
|
||||
self.proxy_enabled = proxy.get("enabled", False)
|
||||
|
||||
if proxy and self.proxy_enabled:
|
||||
self.lock = asyncio.Lock()
|
||||
|
||||
if proxy.get("enabled", False):
|
||||
hostname = proxy.get("hostname", None)
|
||||
port = proxy.get("port", None)
|
||||
|
||||
try:
|
||||
ip_address = ipaddress.ip_address(hostname)
|
||||
except ValueError:
|
||||
self.socket = socks.socksocket(socket.AF_INET)
|
||||
else:
|
||||
if isinstance(ip_address, ipaddress.IPv6Address):
|
||||
self.socket = socks.socksocket(socket.AF_INET6)
|
||||
else:
|
||||
self.socket = socks.socksocket(socket.AF_INET)
|
||||
|
||||
self.socket.set_proxy(
|
||||
proxy_type=socks.SOCKS5,
|
||||
addr=proxy.get("hostname", None),
|
||||
port=proxy.get("port", None),
|
||||
addr=hostname,
|
||||
port=port,
|
||||
username=proxy.get("username", None),
|
||||
password=proxy.get("password", None)
|
||||
)
|
||||
|
||||
log.info("Using proxy {}:{}".format(
|
||||
proxy.get("hostname", None),
|
||||
proxy.get("port", None)
|
||||
))
|
||||
log.info("Using proxy {}:{}".format(hostname, port))
|
||||
else:
|
||||
super().__init__(
|
||||
socket.AF_INET6 if ipv6
|
||||
else socket.AF_INET
|
||||
)
|
||||
|
||||
self.socket.settimeout(TCP.TIMEOUT)
|
||||
|
||||
async def connect(self, address: tuple):
|
||||
self.socket.connect(address)
|
||||
|
Loading…
Reference in New Issue
Block a user