2
0
mirror of https://github.com/pyrogram/pyrogram synced 2025-09-08 18:25:16 +00:00

Merge branch 'develop' into session_storage

# Conflicts:
#	pyrogram/client/client.py
#	pyrogram/client/ext/base_client.py
#	pyrogram/client/ext/syncer.py
#	pyrogram/client/methods/contacts/get_contacts.py
This commit is contained in:
Dan
2019-06-15 23:52:34 +02:00
313 changed files with 9183 additions and 4943 deletions

View File

@@ -16,8 +16,11 @@
# You should have received a copy of the GNU Lesser General Public License
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
import os
import platform
import re
import sys
from pathlib import Path
from queue import Queue
from threading import Lock
@@ -31,7 +34,7 @@ class BaseClient:
class StopTransmission(StopIteration):
pass
APP_VERSION = "Pyrogram \U0001f525 {}".format(__version__)
APP_VERSION = "Pyrogram {}".format(__version__)
DEVICE_MODEL = "{} {}".format(
platform.python_implementation(),
@@ -45,18 +48,20 @@ class BaseClient:
LANG_CODE = "en"
PARENT_DIR = Path(sys.argv[0]).parent
INVITE_LINK_RE = re.compile(r"^(?:https?://)?(?:www\.)?(?:t(?:elegram)?\.(?:org|me|dog)/joinchat/)([\w-]+)$")
BOT_TOKEN_RE = re.compile(r"^\d+:[\w-]+$")
DIALOGS_AT_ONCE = 100
UPDATES_WORKERS = 1
DOWNLOAD_WORKERS = 1
OFFLINE_SLEEP = 300
OFFLINE_SLEEP = 900
WORKERS = 4
WORKDIR = "."
CONFIG_FILE = "./config.ini"
WORKDIR = PARENT_DIR
CONFIG_FILE = PARENT_DIR / "config.ini"
MEDIA_TYPE_ID = {
0: "thumbnail",
0: "photo_thumbnail",
1: "chat_photo",
2: "photo",
3: "voice",
@@ -65,14 +70,28 @@ class BaseClient:
8: "sticker",
9: "audio",
10: "animation",
13: "video_note"
13: "video_note",
14: "document_thumbnail"
}
mime_types_to_extensions = {}
extensions_to_mime_types = {}
with open("{}/mime.types".format(os.path.dirname(__file__)), "r", encoding="UTF-8") as f:
for match in re.finditer(r"^([^#\s]+)\s+(.+)$", f.read(), flags=re.M):
mime_type, extensions = match.groups()
extensions = [".{}".format(ext) for ext in extensions.split(" ")]
for ext in extensions:
extensions_to_mime_types[ext] = mime_type
mime_types_to_extensions[mime_type] = " ".join(extensions)
def __init__(self, session_storage: SessionStorage):
self.session_storage = session_storage
self.rnd_id = MsgId
self.channels_pts = {}
self.markdown = Markdown(self.session_storage, self)
self.html = HTML(self.session_storage, self)
@@ -125,3 +144,30 @@ class BaseClient:
def answer_inline_query(self, *args, **kwargs):
pass
def guess_mime_type(self, *args, **kwargs):
pass
def guess_extension(self, *args, **kwargs):
pass
def get_profile_photos(self, *args, **kwargs):
pass
def edit_message_text(self, *args, **kwargs):
pass
def edit_inline_text(self, *args, **kwargs):
pass
def edit_message_media(self, *args, **kwargs):
pass
def edit_inline_media(self, *args, **kwargs):
pass
def edit_message_reply_markup(self, *args, **kwargs):
pass
def edit_inline_reply_markup(self, *args, **kwargs):
pass