lyrpy 2024.0.4__py3-none-any.whl → 2025.0.2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of lyrpy might be problematic. Click here for more details.
- SRC/LIB/__init__.py +21 -0
- SRC/LIB/lyrpy/LUConst.py +358 -0
- {lyrpy → SRC/LIB/lyrpy}/LUDateTime.py +2 -4
- {lyrpy → SRC/LIB/lyrpy}/LUDecotators.py +2 -3
- {lyrpy → SRC/LIB/lyrpy}/LUDict.py +0 -1
- {lyrpy → SRC/LIB/lyrpy}/LUDoc.py +4 -3
- {lyrpy → SRC/LIB/lyrpy}/LUErrors.py +0 -1
- {lyrpy → SRC/LIB/lyrpy}/LUFile.py +115 -61
- {lyrpy → SRC/LIB/lyrpy}/LUFileUtils.py +60 -45
- {lyrpy → SRC/LIB/lyrpy}/LULog.py +267 -191
- {lyrpy → SRC/LIB/lyrpy}/LUObjects.py +4 -4
- {lyrpy → SRC/LIB/lyrpy}/LUObjectsYT.py +39 -22
- {lyrpy → SRC/LIB/lyrpy}/LUParserARG.py +2 -3
- {lyrpy → SRC/LIB/lyrpy}/LUParserINI.py +8 -3
- {lyrpy → SRC/LIB/lyrpy}/LUParserREG.py +5 -1
- {lyrpy → SRC/LIB/lyrpy}/LUQThread.py +6 -4
- {lyrpy → SRC/LIB/lyrpy}/LUQTimer.py +5 -5
- {lyrpy → SRC/LIB/lyrpy}/LUSheduler.py +24 -23
- SRC/LIB/lyrpy/LUTelegram.py +428 -0
- {lyrpy → SRC/LIB/lyrpy}/LUThread.py +7 -6
- {lyrpy → SRC/LIB/lyrpy}/LUTimer.py +5 -3
- {lyrpy → SRC/LIB/lyrpy}/LUVersion.py +4 -1
- {lyrpy → SRC/LIB/lyrpy}/LUYouTube.py +6 -7
- {lyrpy → SRC/LIB/lyrpy}/LUos.py +13 -3
- SRC/LIB/lyrpy/__init__.py +21 -0
- {lyrpy → SRC/LIB/lyrpy}/__main__.py +20 -19
- SRC/__init__.py +0 -0
- SRC/lyrpy/LUConsole.py +402 -0
- SRC/lyrpy/LUConst.py +358 -0
- SRC/lyrpy/LUDateTime.py +205 -0
- SRC/lyrpy/LUDecotators.py +417 -0
- SRC/lyrpy/LUDict.py +116 -0
- SRC/lyrpy/LUDoc.py +62 -0
- SRC/lyrpy/LUErrors.py +79 -0
- SRC/lyrpy/LUFile.py +1228 -0
- SRC/lyrpy/LUFileUtils.py +501 -0
- SRC/lyrpy/LULog.py +2324 -0
- SRC/lyrpy/LUNetwork.py +277 -0
- SRC/lyrpy/LUNumUtils.py +305 -0
- SRC/lyrpy/LUObjects.py +208 -0
- SRC/lyrpy/LUObjectsYT.py +846 -0
- SRC/lyrpy/LUParserARG.py +364 -0
- SRC/lyrpy/LUParserINI.py +376 -0
- SRC/lyrpy/LUParserREG.py +514 -0
- SRC/lyrpy/LUProc.py +110 -0
- SRC/lyrpy/LUQThread.py +141 -0
- SRC/lyrpy/LUQTimer.py +197 -0
- SRC/lyrpy/LUSheduler.py +941 -0
- SRC/lyrpy/LUStrDecode.py +223 -0
- SRC/lyrpy/LUStrUtils.py +633 -0
- SRC/lyrpy/LUSupport.py +124 -0
- SRC/lyrpy/LUTelegram.py +428 -0
- SRC/lyrpy/LUThread.py +177 -0
- SRC/lyrpy/LUTimer.py +141 -0
- SRC/lyrpy/LUVersion.py +383 -0
- SRC/lyrpy/LUYouTube.py +203 -0
- SRC/lyrpy/LUos.py +807 -0
- lyrpy/LUConst.py → SRC/lyrpy/LUsys.py +12 -10
- SRC/lyrpy/__init__.py +21 -0
- lyrpy/__init__.py → SRC/lyrpy/__main__.py +2 -3
- TESTS/__init__.py +0 -0
- TESTS/test_lyrpy.py +4 -0
- TESTS/test_main.py +10 -0
- __SRC/LIB/__init__.py +0 -0
- __SRC/LIB/lyrpy/LUConsole.py +402 -0
- __SRC/LIB/lyrpy/LUConst.py +358 -0
- __SRC/LIB/lyrpy/LUDateTime.py +205 -0
- __SRC/LIB/lyrpy/LUDecotators.py +417 -0
- __SRC/LIB/lyrpy/LUDict.py +116 -0
- __SRC/LIB/lyrpy/LUDoc.py +62 -0
- __SRC/LIB/lyrpy/LUErrors.py +79 -0
- __SRC/LIB/lyrpy/LUFile.py +1228 -0
- __SRC/LIB/lyrpy/LUFileUtils.py +501 -0
- __SRC/LIB/lyrpy/LULog.py +2324 -0
- __SRC/LIB/lyrpy/LUNetwork.py +277 -0
- __SRC/LIB/lyrpy/LUNumUtils.py +305 -0
- __SRC/LIB/lyrpy/LUObjects.py +208 -0
- __SRC/LIB/lyrpy/LUObjectsYT.py +846 -0
- __SRC/LIB/lyrpy/LUParserARG.py +364 -0
- __SRC/LIB/lyrpy/LUParserINI.py +376 -0
- __SRC/LIB/lyrpy/LUParserREG.py +514 -0
- __SRC/LIB/lyrpy/LUProc.py +110 -0
- __SRC/LIB/lyrpy/LUQThread.py +141 -0
- __SRC/LIB/lyrpy/LUQTimer.py +197 -0
- __SRC/LIB/lyrpy/LUSheduler.py +941 -0
- __SRC/LIB/lyrpy/LUStrDecode.py +223 -0
- __SRC/LIB/lyrpy/LUStrUtils.py +633 -0
- __SRC/LIB/lyrpy/LUSupport.py +124 -0
- __SRC/LIB/lyrpy/LUTelegram.py +428 -0
- __SRC/LIB/lyrpy/LUThread.py +177 -0
- __SRC/LIB/lyrpy/LUTimer.py +141 -0
- __SRC/LIB/lyrpy/LUVersion.py +383 -0
- __SRC/LIB/lyrpy/LUYouTube.py +203 -0
- __SRC/LIB/lyrpy/LUos.py +807 -0
- __SRC/LIB/lyrpy/LUsys.py +47 -0
- __SRC/LIB/lyrpy/__init__.py +21 -0
- __SRC/LIB/lyrpy/__main__.py +20 -0
- __SRC/__init__.py +0 -0
- ____src/__init__.py +0 -0
- ____src/lyrpy/LUConsole.py +402 -0
- ____src/lyrpy/LUConst.py +358 -0
- ____src/lyrpy/LUDateTime.py +205 -0
- ____src/lyrpy/LUDecotators.py +417 -0
- ____src/lyrpy/LUDict.py +116 -0
- ____src/lyrpy/LUDoc.py +62 -0
- ____src/lyrpy/LUErrors.py +79 -0
- ____src/lyrpy/LUFile.py +1228 -0
- ____src/lyrpy/LUFileUtils.py +501 -0
- ____src/lyrpy/LULog.py +2324 -0
- ____src/lyrpy/LUNetwork.py +277 -0
- ____src/lyrpy/LUNumUtils.py +305 -0
- ____src/lyrpy/LUObjects.py +208 -0
- ____src/lyrpy/LUObjectsYT.py +846 -0
- ____src/lyrpy/LUParserARG.py +364 -0
- ____src/lyrpy/LUParserINI.py +376 -0
- ____src/lyrpy/LUParserREG.py +514 -0
- ____src/lyrpy/LUProc.py +110 -0
- ____src/lyrpy/LUQThread.py +141 -0
- ____src/lyrpy/LUQTimer.py +197 -0
- ____src/lyrpy/LUSheduler.py +941 -0
- ____src/lyrpy/LUStrDecode.py +223 -0
- ____src/lyrpy/LUStrUtils.py +633 -0
- ____src/lyrpy/LUSupport.py +124 -0
- ____src/lyrpy/LUTelegram.py +428 -0
- ____src/lyrpy/LUThread.py +177 -0
- ____src/lyrpy/LUTimer.py +141 -0
- ____src/lyrpy/LUVersion.py +383 -0
- ____src/lyrpy/LUYouTube.py +203 -0
- ____src/lyrpy/LUos.py +807 -0
- ____src/lyrpy/LUsys.py +47 -0
- ____src/lyrpy/__init__.py +21 -0
- ____src/lyrpy/__main__.py +20 -0
- lyrpy-2025.0.2.dist-info/METADATA +21 -0
- lyrpy-2025.0.2.dist-info/RECORD +145 -0
- {lyrpy-2024.0.4.dist-info → lyrpy-2025.0.2.dist-info}/WHEEL +1 -1
- lyrpy-2025.0.2.dist-info/top_level.txt +2 -0
- lyrpy-2024.0.4.data/data/data/text.txt +0 -1
- lyrpy-2024.0.4.dist-info/METADATA +0 -44
- lyrpy-2024.0.4.dist-info/RECORD +0 -38
- lyrpy-2024.0.4.dist-info/top_level.txt +0 -1
- {lyrpy → SRC/LIB/lyrpy}/LUConsole.py +0 -0
- {lyrpy → SRC/LIB/lyrpy}/LUNetwork.py +0 -0
- {lyrpy → SRC/LIB/lyrpy}/LUNumUtils.py +0 -0
- {lyrpy → SRC/LIB/lyrpy}/LUProc.py +0 -0
- {lyrpy → SRC/LIB/lyrpy}/LUStrDecode.py +0 -0
- {lyrpy → SRC/LIB/lyrpy}/LUStrUtils.py +0 -0
- {lyrpy → SRC/LIB/lyrpy}/LUSupport.py +0 -0
- {lyrpy → SRC/LIB/lyrpy}/LUsys.py +0 -0
- {lyrpy-2024.0.4.dist-info → lyrpy-2025.0.2.dist-info/licenses}/LICENSE +0 -0
|
@@ -0,0 +1,428 @@
|
|
|
1
|
+
"""LUTelegram.py"""
|
|
2
|
+
# -*- coding: UTF-8 -*-
|
|
3
|
+
__annotations__ = """
|
|
4
|
+
=======================================================
|
|
5
|
+
Copyright (c) 2025
|
|
6
|
+
Author:
|
|
7
|
+
Lisitsin Y.R.
|
|
8
|
+
Project:
|
|
9
|
+
lyrpy
|
|
10
|
+
|
|
11
|
+
Module:
|
|
12
|
+
LUTelegram.py
|
|
13
|
+
|
|
14
|
+
=======================================================
|
|
15
|
+
"""
|
|
16
|
+
|
|
17
|
+
from fontTools.misc.cython import returns
|
|
18
|
+
#------------------------------------------
|
|
19
|
+
# БИБЛИОТЕКИ python
|
|
20
|
+
#------------------------------------------
|
|
21
|
+
|
|
22
|
+
#------------------------------------------
|
|
23
|
+
# БИБЛИОТЕКИ сторонние
|
|
24
|
+
#------------------------------------------
|
|
25
|
+
|
|
26
|
+
#------------------------------------------
|
|
27
|
+
# БИБЛИОТЕКА telethon
|
|
28
|
+
#------------------------------------------
|
|
29
|
+
# import telethon
|
|
30
|
+
import telethon.sync
|
|
31
|
+
import telethon.tl.types
|
|
32
|
+
|
|
33
|
+
from telethon.sync import TelegramClient
|
|
34
|
+
from telethon.tl.types import PeerUser, PeerChat, PeerChannel
|
|
35
|
+
import re
|
|
36
|
+
import asyncio
|
|
37
|
+
|
|
38
|
+
# from telethon.tl.functions.messages import GetDialogsRequest
|
|
39
|
+
# from telethon.tl.types import InputPeerEmpty
|
|
40
|
+
# from telethon.tl.types import User
|
|
41
|
+
# # класс, позволяющий нам подключаться к клиенту мессенджера и работать с ним;
|
|
42
|
+
# from telethon.sync import TelegramClient
|
|
43
|
+
# # PeerChannel - специальный тип, определяющий объекты типа «канал/чат»,
|
|
44
|
+
# # с помощью которого можно обратиться к нужному каналу для парсинга сообщений.
|
|
45
|
+
# from telethon.tl.types import Channel, PeerChannel, PeerChat, PeerUser, Message, User, MessageMediaPhoto, MessageMediaDocument
|
|
46
|
+
# # конструктор для работы с InputPeer, который передаётся в качестве аргумента в GetDialogsRequest;
|
|
47
|
+
# from telethon.tl.types import InputMessagesFilterPhotos
|
|
48
|
+
# # функция, позволяющая работать с сообщениями в чате;
|
|
49
|
+
# # метод, позволяющий получить сообщения пользователей из чата и работать с ним;
|
|
50
|
+
# from telethon.tl.functions.messages import GetHistoryRequest
|
|
51
|
+
# from telethon import TelegramClient, events, sync
|
|
52
|
+
# import telethon.errors
|
|
53
|
+
# import telethon.client.messages as messages
|
|
54
|
+
#------------------------------------------
|
|
55
|
+
# БИБЛИОТЕКА pyrogram
|
|
56
|
+
#------------------------------------------
|
|
57
|
+
# from pyrogram import Client
|
|
58
|
+
import pyrogram
|
|
59
|
+
|
|
60
|
+
#------------------------------------------
|
|
61
|
+
# БИБЛИОТЕКИ LU
|
|
62
|
+
#------------------------------------------
|
|
63
|
+
|
|
64
|
+
LIB_name = ''
|
|
65
|
+
|
|
66
|
+
# ------------------------------------------
|
|
67
|
+
# Авторизация в Telegram
|
|
68
|
+
# get_telethon_client (session_name, api_id, api_hash, phone, password) -> telethon.sync.TelegramClient:
|
|
69
|
+
# ------------------------------------------
|
|
70
|
+
def get_telethon_client (session_name, api_id, api_hash, phone, password) -> telethon.sync.TelegramClient:
|
|
71
|
+
"""get_telethon_client"""
|
|
72
|
+
# beginfunction
|
|
73
|
+
result = telethon.sync.TelegramClient(session_name, api_id, api_hash, system_version="4.16.30-vxNAME ")
|
|
74
|
+
# Вместо NAME используйте любое сочетание букв на английском КАПСОМ Пример: vxXYI, vxABC, vxMYNAME
|
|
75
|
+
# # (в папке с кодом нет файлика .session, клиент сам его создаст (в нашем случае 'my_session')
|
|
76
|
+
# # и будет с ним работать. Поэтому просто вставляем эти параметры в инициализацию и кайфуем:finger_up: )
|
|
77
|
+
|
|
78
|
+
# Tclient = TelegramClient (Gsession_name, Gapi_id, Gapi_hash,
|
|
79
|
+
# # device_model = "iPhone 13 Pro Max",
|
|
80
|
+
# # app_version = "8.4",
|
|
81
|
+
# # lang_code = "en",
|
|
82
|
+
# # system_lang_code = "en-US")
|
|
83
|
+
# system_version='4.16.30-vxABC')
|
|
84
|
+
# Tclient.start (phone=Gphone, password=Gpassword)
|
|
85
|
+
result.start (phone=phone, password=password)
|
|
86
|
+
result.connect ()
|
|
87
|
+
# print (f'{LIB_name}_user_authorized={result.is_user_authorized()}')
|
|
88
|
+
return result
|
|
89
|
+
# endfunction
|
|
90
|
+
|
|
91
|
+
# ------------------------------------------
|
|
92
|
+
# Получить the current User who is logged
|
|
93
|
+
# get_telethon_me (client:telethon.sync.TelegramClient) -> telethon.tl.types.User:
|
|
94
|
+
# ------------------------------------------
|
|
95
|
+
def get_telethon_me (client:telethon.sync.TelegramClient) -> telethon.tl.types.User:
|
|
96
|
+
"""get_telethon_me"""
|
|
97
|
+
# beginfunction
|
|
98
|
+
result:User = client.get_me ()
|
|
99
|
+
|
|
100
|
+
# print (f'{LIB_name}_username={result.username}')
|
|
101
|
+
# print (f'{LIB_name}_phone={result.phone}')
|
|
102
|
+
|
|
103
|
+
# print (f'{LIB_name}_stringify={result.stringify()}')
|
|
104
|
+
return result
|
|
105
|
+
# endfunction
|
|
106
|
+
|
|
107
|
+
# ------------------------------------------
|
|
108
|
+
# Получить channel
|
|
109
|
+
# get_telethon_channel (client:telethon.sync.TelegramClient, channel_name_id) -> telethon.tl.types.Channel:
|
|
110
|
+
# ------------------------------------------
|
|
111
|
+
def get_telethon_channel (client:telethon.sync.TelegramClient, channel_name_id) -> telethon.tl.types.Channel:
|
|
112
|
+
"""get_telethon_channel"""
|
|
113
|
+
# beginfunction
|
|
114
|
+
result = client.get_entity (channel_name_id)
|
|
115
|
+
# print (result)
|
|
116
|
+
# print(f'{LIB_name}_Channel.title={result.title}')
|
|
117
|
+
# print(f'{LIB_name}_Channel.id={result.id}')
|
|
118
|
+
# print(f'{LIB_name}_Channel.username={result.id}')
|
|
119
|
+
return result
|
|
120
|
+
# endfunction
|
|
121
|
+
|
|
122
|
+
# ------------------------------------------
|
|
123
|
+
# Получить message
|
|
124
|
+
# get_telethon_message (client:telethon.sync.TelegramClient, channel:telethon.tl.types.Channel, message_id) -> telethon.tl.types.Message:
|
|
125
|
+
# ------------------------------------------
|
|
126
|
+
def get_telethon_message (client:telethon.sync.TelegramClient, channel:telethon.tl.types.Channel, message_id) -> telethon.tl.types.Message:
|
|
127
|
+
"""get_telethon_message"""
|
|
128
|
+
# beginfunction
|
|
129
|
+
try:
|
|
130
|
+
result = client.get_messages (channel.id, ids=message_id)
|
|
131
|
+
# print(f'{LIB_name}_Message={result}')
|
|
132
|
+
except:
|
|
133
|
+
result = None
|
|
134
|
+
|
|
135
|
+
return result
|
|
136
|
+
# endfunction
|
|
137
|
+
|
|
138
|
+
#------------------------------------------
|
|
139
|
+
# Получить мои группы
|
|
140
|
+
# get_telethon_mygroups (client:TelegramClient):
|
|
141
|
+
#------------------------------------------
|
|
142
|
+
def get_telethon_mygroups (client:telethon.sync.TelegramClient):
|
|
143
|
+
"""get_telethon_mygroups"""
|
|
144
|
+
#beginfunction
|
|
145
|
+
# Получение списка диалогов
|
|
146
|
+
dialogs = client.get_dialogs()
|
|
147
|
+
# Отображение списка групп
|
|
148
|
+
for dialog in dialogs:
|
|
149
|
+
if dialog.is_group:
|
|
150
|
+
print(f"{LIB_name}_Группа: {dialog.title} (ID: {dialog.id})")
|
|
151
|
+
#endfunction
|
|
152
|
+
|
|
153
|
+
#------------------------------------------
|
|
154
|
+
# Получить список groups
|
|
155
|
+
#------------------------------------------
|
|
156
|
+
def get_telethon_groups (client:telethon.sync.TelegramClient) -> list:
|
|
157
|
+
"""get_telethon_groups"""
|
|
158
|
+
#beginfunction
|
|
159
|
+
chats = []
|
|
160
|
+
last_date = None
|
|
161
|
+
size_chats = 200
|
|
162
|
+
groups = []
|
|
163
|
+
|
|
164
|
+
# -----------------------------------------------
|
|
165
|
+
# Напишем запрос для получения списка групп
|
|
166
|
+
# -----------------------------------------------
|
|
167
|
+
# offset_date и offset_peer мы передаём с пустыми значениями.
|
|
168
|
+
# Обычно они используются для фильтрации полученных данных, но здесь мы
|
|
169
|
+
# хотим получить весь список. Лимит по количеству элементов в ответе задаём 200,
|
|
170
|
+
# передавая в параметр limit переменную size_chats.
|
|
171
|
+
result = client (telethon.tl.functions.messages.GetDialogsRequest (
|
|
172
|
+
offset_date=last_date,
|
|
173
|
+
offset_id=0,
|
|
174
|
+
offset_peer=telethon.tl.types.InputPeerEmpty (),
|
|
175
|
+
limit=size_chats,
|
|
176
|
+
hash=0
|
|
177
|
+
))
|
|
178
|
+
chats.extend (result.chats)
|
|
179
|
+
|
|
180
|
+
# -----------------------------------------------
|
|
181
|
+
#
|
|
182
|
+
# -----------------------------------------------
|
|
183
|
+
for chat in chats:
|
|
184
|
+
try:
|
|
185
|
+
# print (int(chat.megagroup), chat.title)
|
|
186
|
+
|
|
187
|
+
# Megagroup в библиотеке Telethon — это свойство объекта Channel,
|
|
188
|
+
# которое указывает, является ли он мегагруппой (большой группой).
|
|
189
|
+
# Мегагруппы — это каналы, для которых значение свойства channel.megagroup равно True.
|
|
190
|
+
# В официальных приложениях Telegram такие группы называются «супергруппами»
|
|
191
|
+
|
|
192
|
+
if chat.megagroup == True:
|
|
193
|
+
groups.append (chat)
|
|
194
|
+
except:
|
|
195
|
+
continue
|
|
196
|
+
return groups
|
|
197
|
+
|
|
198
|
+
#endfunction
|
|
199
|
+
|
|
200
|
+
#------------------------------------------
|
|
201
|
+
# Получить список groups
|
|
202
|
+
#------------------------------------------
|
|
203
|
+
def get_telethon_groups (client:telethon.sync.TelegramClient) -> list:
|
|
204
|
+
"""get_telethon_groups"""
|
|
205
|
+
#beginfunction
|
|
206
|
+
chats = []
|
|
207
|
+
last_date = None
|
|
208
|
+
size_chats = 200
|
|
209
|
+
groups = []
|
|
210
|
+
|
|
211
|
+
# -----------------------------------------------
|
|
212
|
+
# Напишем запрос для получения списка групп
|
|
213
|
+
# -----------------------------------------------
|
|
214
|
+
# offset_date и offset_peer мы передаём с пустыми значениями.
|
|
215
|
+
# Обычно они используются для фильтрации полученных данных, но здесь мы
|
|
216
|
+
# хотим получить весь список. Лимит по количеству элементов в ответе задаём 200,
|
|
217
|
+
# передавая в параметр limit переменную size_chats.
|
|
218
|
+
result = client (telethon.tl.functions.messages.GetDialogsRequest (
|
|
219
|
+
offset_date=last_date,
|
|
220
|
+
offset_id=0,
|
|
221
|
+
offset_peer=telethon.tl.types.InputPeerEmpty (),
|
|
222
|
+
limit=size_chats,
|
|
223
|
+
hash=0
|
|
224
|
+
))
|
|
225
|
+
chats.extend (result.chats)
|
|
226
|
+
# -----------------------------------------------
|
|
227
|
+
#
|
|
228
|
+
# -----------------------------------------------
|
|
229
|
+
for chat in chats:
|
|
230
|
+
try:
|
|
231
|
+
# print (int(chat.megagroup), chat.title)
|
|
232
|
+
# Megagroup в библиотеке Telethon — это свойство объекта Channel,
|
|
233
|
+
# которое указывает, является ли он мегагруппой (большой группой).
|
|
234
|
+
# Мегагруппы — это каналы, для которых значение свойства channel.megagroup равно True.
|
|
235
|
+
# В официальных приложениях Telegram такие группы называются «супергруппами»
|
|
236
|
+
if chat.megagroup == True:
|
|
237
|
+
groups.append (chat)
|
|
238
|
+
else:
|
|
239
|
+
# groups.append (chat)
|
|
240
|
+
pass
|
|
241
|
+
except:
|
|
242
|
+
continue
|
|
243
|
+
return groups
|
|
244
|
+
#endfunction
|
|
245
|
+
|
|
246
|
+
#------------------------------------------
|
|
247
|
+
# Получить список users group
|
|
248
|
+
#------------------------------------------
|
|
249
|
+
def get_telethon_users_group (client:telethon.sync.TelegramClient, group) -> list:
|
|
250
|
+
"""get_telethon_users_group"""
|
|
251
|
+
#beginfunction
|
|
252
|
+
#-----------------------------------------------
|
|
253
|
+
# Узнаём пользователей...
|
|
254
|
+
#-----------------------------------------------
|
|
255
|
+
all_participants = []
|
|
256
|
+
try:
|
|
257
|
+
all_participants = client.get_participants (group, limit=100000)
|
|
258
|
+
# print (group)
|
|
259
|
+
# for user in all_participants:
|
|
260
|
+
# if user.username:
|
|
261
|
+
# username = user.username
|
|
262
|
+
# else:
|
|
263
|
+
# username = ""
|
|
264
|
+
# if user.first_name:
|
|
265
|
+
# first_name = user.first_name
|
|
266
|
+
# else:
|
|
267
|
+
# first_name = ""
|
|
268
|
+
# if user.last_name:
|
|
269
|
+
# last_name = user.last_name
|
|
270
|
+
# else:
|
|
271
|
+
# last_name = ""
|
|
272
|
+
# name = (first_name + ' ' + last_name).strip ()
|
|
273
|
+
# print(f'{username=}, {name=}, {target_group.title=}')
|
|
274
|
+
except:
|
|
275
|
+
pass
|
|
276
|
+
return all_participants
|
|
277
|
+
#endfunction
|
|
278
|
+
|
|
279
|
+
#------------------------------------------
|
|
280
|
+
# Получить список CHATs
|
|
281
|
+
#------------------------------------------
|
|
282
|
+
def get_telethon_CHATs (client:telethon.sync.TelegramClient):
|
|
283
|
+
"""get_telethon_CHATs"""
|
|
284
|
+
#beginfunction
|
|
285
|
+
# понять, канал или чат, можно проверяя у диалога параметр "dialog.entity.megagroup
|
|
286
|
+
for dialog in client.iter_dialogs ():
|
|
287
|
+
if 'Channel' in str (type (dialog.entity)): # откидываем юзеров
|
|
288
|
+
if dialog.entity.megagroup:
|
|
289
|
+
print (dialog.entity.id, '//', dialog.entity.username,
|
|
290
|
+
' - ', dialog.name, ' is CHAT')
|
|
291
|
+
#endfunction
|
|
292
|
+
|
|
293
|
+
#------------------------------------------
|
|
294
|
+
# Получить список CHANNELs
|
|
295
|
+
#------------------------------------------
|
|
296
|
+
def get_telethon_CHANNELs (client:telethon.sync.TelegramClient):
|
|
297
|
+
"""get_telethon_CHANNELs"""
|
|
298
|
+
#beginfunction
|
|
299
|
+
# понять, канал или чат, можно проверяя у диалога параметр "dialog.entity.megagroup
|
|
300
|
+
for dialog in client.iter_dialogs ():
|
|
301
|
+
if 'Channel' in str (type (dialog.entity)): # откидываем юзеров
|
|
302
|
+
if not dialog.entity.megagroup:
|
|
303
|
+
print (dialog.entity.id, '//', dialog.entity.username,
|
|
304
|
+
' - ', dialog.name, ' is CHANNEL')
|
|
305
|
+
#endfunction
|
|
306
|
+
|
|
307
|
+
# ----------------------------------------------
|
|
308
|
+
# Получаем последние 10 сообщений из указанного чата
|
|
309
|
+
# ----------------------------------------------
|
|
310
|
+
def get_telethon_chat (client:telethon.sync.TelegramClient, chat_id):
|
|
311
|
+
"""get_telethon_chat"""
|
|
312
|
+
#beginfunction
|
|
313
|
+
# ID чата/канала/пользователя, откуда читать сообщения
|
|
314
|
+
# chat_id = '@GardeZ66' # или ID (число), или юзернейм (например, '@telegram')
|
|
315
|
+
for message in client.iter_messages (chat_id, limit=10):
|
|
316
|
+
print (f"{LIB_name}_message.sender_id:{message.sender_id}: {message.text}")
|
|
317
|
+
#endfunction
|
|
318
|
+
|
|
319
|
+
|
|
320
|
+
|
|
321
|
+
# ----------------------------------------------
|
|
322
|
+
# Функция для парсинга ссылки
|
|
323
|
+
# ----------------------------------------------
|
|
324
|
+
def parse_message_link (link):
|
|
325
|
+
"""parse_message_link"""
|
|
326
|
+
#beginfunction
|
|
327
|
+
pattern = r'https?://t\.me/([a-zA-Z0-9\_]+|c/(\d+))/(\d+)/(\d+)'
|
|
328
|
+
match = re.match (pattern, link)
|
|
329
|
+
if not match:
|
|
330
|
+
raise ValueError ("Invalid link")
|
|
331
|
+
|
|
332
|
+
# print(f'{match.group (1)=}')
|
|
333
|
+
# print(f'{match.group (2)=}')
|
|
334
|
+
# print(f'{match.group (3)=}')
|
|
335
|
+
# print(f'{match.group (4)=}')
|
|
336
|
+
|
|
337
|
+
if match.group (1).startswith ('c'):
|
|
338
|
+
channel_id = int (match.group (3))
|
|
339
|
+
msg_id = int (match.group (3))
|
|
340
|
+
return {'channel_id': channel_id, 'msg_id': msg_id}
|
|
341
|
+
else:
|
|
342
|
+
username = match.group (1)
|
|
343
|
+
msg_id = int (match.group (3))
|
|
344
|
+
return {'username': username, 'msg_id': msg_id}
|
|
345
|
+
#endfunction
|
|
346
|
+
|
|
347
|
+
# ----------------------------------------------
|
|
348
|
+
# async def get_channel_name (link, TelegramClient):
|
|
349
|
+
# ----------------------------------------------
|
|
350
|
+
def get_channel_name (link, session_name, api_id, api_hash, phone):
|
|
351
|
+
"""get_channel_name"""
|
|
352
|
+
#beginfunction
|
|
353
|
+
with TelegramClient (session_name, api_id, api_hash) as client:
|
|
354
|
+
client.start (phone)
|
|
355
|
+
# print (f'{link=}')
|
|
356
|
+
parsed = parse_message_link (link)
|
|
357
|
+
print (f'{parsed=}')
|
|
358
|
+
|
|
359
|
+
if 'username' in parsed:
|
|
360
|
+
entity = client.get_entity (parsed ['username'])
|
|
361
|
+
# entity = client.get_entity (parsed ['msg_id'])
|
|
362
|
+
elif 'channel_id' in parsed:
|
|
363
|
+
entity = client.get_entity (PeerChannel (parsed ['channel_id']))
|
|
364
|
+
else:
|
|
365
|
+
raise ValueError ("Could not resolve entity")
|
|
366
|
+
print (f"Название канала: {entity.title}")
|
|
367
|
+
|
|
368
|
+
# client.disconnect ()
|
|
369
|
+
|
|
370
|
+
return entity.title
|
|
371
|
+
#endfunction
|
|
372
|
+
|
|
373
|
+
|
|
374
|
+
|
|
375
|
+
|
|
376
|
+
|
|
377
|
+
|
|
378
|
+
|
|
379
|
+
|
|
380
|
+
# ------------------------------------------
|
|
381
|
+
# Авторизация в Telegram [pyrogram]
|
|
382
|
+
# ------------------------------------------
|
|
383
|
+
def get_pyrogram_client (api_id, api_hash, login, phone) -> pyrogram.Client:
|
|
384
|
+
"""get_pyrogram_client"""
|
|
385
|
+
# beginfunction
|
|
386
|
+
result = pyrogram.Client (login, api_id=api_id, api_hash=api_hash, phone_number=phone)
|
|
387
|
+
result.start ()
|
|
388
|
+
# result.connect ()
|
|
389
|
+
# print (f'{LIB_name}_is_connected={result.is_connected}')
|
|
390
|
+
|
|
391
|
+
# print(Tclient.export_session_string())
|
|
392
|
+
# print(result.workdir)
|
|
393
|
+
|
|
394
|
+
# result.run ()
|
|
395
|
+
return result
|
|
396
|
+
# endfunction
|
|
397
|
+
|
|
398
|
+
# ------------------------------------------
|
|
399
|
+
# Метод client.get_me() в библиотеке Pyrogram возвращает объект pyrogram.User
|
|
400
|
+
# с информацией о текущем зарегистрированном пользователе или боте.
|
|
401
|
+
# ------------------------------------------
|
|
402
|
+
def get_pyrogram_me (client:pyrogram.Client) -> pyrogram.types.User:
|
|
403
|
+
"""get_pyrogram_me"""
|
|
404
|
+
# beginfunction
|
|
405
|
+
result = client.get_me()
|
|
406
|
+
# print (f'{LIB_name}_username={result.username}')
|
|
407
|
+
# print (f'{LIB_name}_phone_number={result.phone_number}')
|
|
408
|
+
# print (f'pyrogram:stringify={result.stringify()}')
|
|
409
|
+
return result
|
|
410
|
+
# endfunction
|
|
411
|
+
|
|
412
|
+
#---------------------------------------------------------
|
|
413
|
+
# main
|
|
414
|
+
#---------------------------------------------------------
|
|
415
|
+
def main ():
|
|
416
|
+
#beginfunction
|
|
417
|
+
pass
|
|
418
|
+
#endfunction
|
|
419
|
+
|
|
420
|
+
#---------------------------------------------------------
|
|
421
|
+
#
|
|
422
|
+
#---------------------------------------------------------
|
|
423
|
+
#beginmodule
|
|
424
|
+
if __name__ == "__main__":
|
|
425
|
+
main()
|
|
426
|
+
#endif
|
|
427
|
+
|
|
428
|
+
#endmodule
|
|
@@ -18,6 +18,7 @@ __annotations__ = """
|
|
|
18
18
|
# БИБЛИОТЕКИ python
|
|
19
19
|
#------------------------------------------
|
|
20
20
|
import threading
|
|
21
|
+
import logging
|
|
21
22
|
|
|
22
23
|
#------------------------------------------
|
|
23
24
|
# БИБЛИОТЕКИ сторонние
|
|
@@ -26,7 +27,7 @@ import threading
|
|
|
26
27
|
#------------------------------------------
|
|
27
28
|
# БИБЛИОТЕКА LU
|
|
28
29
|
#------------------------------------------
|
|
29
|
-
import
|
|
30
|
+
import lyrpy.LULog as LULog
|
|
30
31
|
|
|
31
32
|
# class ScheduleThread (threading.Thread):
|
|
32
33
|
# @classmethod
|
|
@@ -90,7 +91,7 @@ class TThread (threading.Thread):
|
|
|
90
91
|
"""destructor"""
|
|
91
92
|
#beginfunction
|
|
92
93
|
LClassName = self.__class__.__name__
|
|
93
|
-
s = '{} уничтожен'.format (LClassName)
|
|
94
|
+
# s = '{} уничтожен'.format (LClassName)
|
|
94
95
|
# LULog.LoggerTOOLS_AddLevel (LULog.DEBUGTEXT, s)
|
|
95
96
|
#print (s)
|
|
96
97
|
#endfunction
|
|
@@ -124,10 +125,10 @@ class TThread (threading.Thread):
|
|
|
124
125
|
"""run - Запуск потока"""
|
|
125
126
|
#beginfunction
|
|
126
127
|
s = 'run - Запуск потока...'
|
|
127
|
-
LULog.
|
|
128
|
+
LULog.LoggerAdd (LULog.LoggerTOOLS, logging.DEBUG, s)
|
|
128
129
|
super ().run()
|
|
129
130
|
while not self.__FStopThread:
|
|
130
|
-
s = 'Выполнение потока...'
|
|
131
|
+
# s = 'Выполнение потока...'
|
|
131
132
|
# LULog.LoggerTOOLS_AddDebug (s)
|
|
132
133
|
continue
|
|
133
134
|
#endwhile
|
|
@@ -140,7 +141,7 @@ class TThread (threading.Thread):
|
|
|
140
141
|
"""StartThread"""
|
|
141
142
|
#beginfunction
|
|
142
143
|
s = 'StartThread...'
|
|
143
|
-
LULog.
|
|
144
|
+
LULog.LoggerAdd (LULog.LoggerTOOLS, logging.DEBUG, s)
|
|
144
145
|
self.__FStopThread = False
|
|
145
146
|
self.run()
|
|
146
147
|
#endfunction
|
|
@@ -151,7 +152,7 @@ class TThread (threading.Thread):
|
|
|
151
152
|
"""StopThread"""
|
|
152
153
|
#beginfunction
|
|
153
154
|
s = 'StopThread...'
|
|
154
|
-
LULog.
|
|
155
|
+
LULog.LoggerAdd (LULog.LoggerTOOLS, logging.DEBUG, s)
|
|
155
156
|
self.__FStopThread = True
|
|
156
157
|
#endfunction
|
|
157
158
|
|
|
@@ -18,6 +18,7 @@ __annotations__ = """
|
|
|
18
18
|
# БИБЛИОТЕКИ python
|
|
19
19
|
#------------------------------------------
|
|
20
20
|
import threading
|
|
21
|
+
import logging
|
|
21
22
|
|
|
22
23
|
#------------------------------------------
|
|
23
24
|
# БИБЛИОТЕКИ сторонние
|
|
@@ -26,6 +27,7 @@ import threading
|
|
|
26
27
|
#------------------------------------------
|
|
27
28
|
# БИБЛИОТЕКА LU
|
|
28
29
|
#------------------------------------------
|
|
30
|
+
import lyrpy.LULog as LULog
|
|
29
31
|
|
|
30
32
|
# Create the Worker Thread
|
|
31
33
|
class TTimer (threading.Timer):
|
|
@@ -60,7 +62,7 @@ class TTimer (threading.Timer):
|
|
|
60
62
|
"""destructor"""
|
|
61
63
|
#beginfunction
|
|
62
64
|
LClassName = self.__class__.__name__
|
|
63
|
-
s = '{} уничтожен'.format (LClassName)
|
|
65
|
+
# s = '{} уничтожен'.format (LClassName)
|
|
64
66
|
# LULog.LoggerTOOLS_AddLevel (LULog.DEBUGTEXT, s)
|
|
65
67
|
#print (s)
|
|
66
68
|
#endfunction
|
|
@@ -94,13 +96,13 @@ class TTimer (threading.Timer):
|
|
|
94
96
|
"""run - Запуск таймера"""
|
|
95
97
|
#beginfunction
|
|
96
98
|
s = 'run - Запуск таймера...'
|
|
97
|
-
LULog.
|
|
99
|
+
LULog.LoggerAdd (LULog.LoggerTOOLS, logging.DEBUG, s)
|
|
98
100
|
# super ().run()
|
|
99
101
|
|
|
100
102
|
# self.Function()
|
|
101
103
|
|
|
102
104
|
while not self.__FStopTimer:
|
|
103
|
-
s = 'Выполнение таймера...'
|
|
105
|
+
# s = 'Выполнение таймера...'
|
|
104
106
|
# LULog.LoggerTOOLS_AddDebug (s)
|
|
105
107
|
continue
|
|
106
108
|
#endwhile
|
|
@@ -24,6 +24,9 @@ import platform
|
|
|
24
24
|
#------------------------------------------
|
|
25
25
|
import datetime
|
|
26
26
|
|
|
27
|
+
import win32api
|
|
28
|
+
|
|
29
|
+
|
|
27
30
|
# if platform.system() == 'Windows':
|
|
28
31
|
# import win32api
|
|
29
32
|
# import win32con
|
|
@@ -71,7 +74,7 @@ class TVersionInfo:
|
|
|
71
74
|
def __del__(self):
|
|
72
75
|
#beginfunction
|
|
73
76
|
LClassName = self.__class__.__name__
|
|
74
|
-
s = '{} уничтожен'.format (LClassName)
|
|
77
|
+
# s = '{} уничтожен'.format (LClassName)
|
|
75
78
|
#print (s)
|
|
76
79
|
#endfunction
|
|
77
80
|
|
|
@@ -26,9 +26,8 @@ import sys
|
|
|
26
26
|
#------------------------------------------
|
|
27
27
|
# БИБЛИОТЕКИ LU
|
|
28
28
|
#------------------------------------------
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
import lyr
|
|
29
|
+
import lyrpy.LUObjectsYT as LUObjectsYT
|
|
30
|
+
import lyrpy.LUFile as LUFile
|
|
32
31
|
|
|
33
32
|
# --------------------------------------------
|
|
34
33
|
# TYouTubeObjectsItem
|
|
@@ -53,7 +52,7 @@ class TYouTubeObjectsItem (object):
|
|
|
53
52
|
# удалить объект
|
|
54
53
|
del self.__FYouTubeObject
|
|
55
54
|
LClassName = self.__class__.__name__
|
|
56
|
-
s = '{} уничтожен'.format (LClassName)
|
|
55
|
+
# s = '{} уничтожен'.format (LClassName)
|
|
57
56
|
# LULog.LoggerTOOLS_AddLevel (LULog.DEBUGTEXT, s)
|
|
58
57
|
#endfunction
|
|
59
58
|
|
|
@@ -67,7 +66,7 @@ class TYouTubeObjectsItem (object):
|
|
|
67
66
|
return self.__FYouTubeObject
|
|
68
67
|
#endfunction
|
|
69
68
|
@YouTubeObject.setter
|
|
70
|
-
def YouTubeObject(self, Value:
|
|
69
|
+
def YouTubeObject(self, Value: LUObjectsYT.TYouTubeObject):
|
|
71
70
|
#beginfunction
|
|
72
71
|
self.__FYouTubeObject = Value
|
|
73
72
|
#endfunction
|
|
@@ -98,7 +97,7 @@ class TYouTubeObjectsCollection (list):
|
|
|
98
97
|
#beginfunction
|
|
99
98
|
self.clear() # удалить все items
|
|
100
99
|
LClassName = self.__class__.__name__
|
|
101
|
-
s = '{} уничтожен'.format (LClassName)
|
|
100
|
+
# s = '{} уничтожен'.format (LClassName)
|
|
102
101
|
# LULog.LoggerTOOLS_AddLevel (LULog.DEBUGTEXT, s)
|
|
103
102
|
#endfunction
|
|
104
103
|
|
|
@@ -169,7 +168,7 @@ class TYouTube(object):
|
|
|
169
168
|
#beginfunction
|
|
170
169
|
del self.__FYouTubeObjectsCollection
|
|
171
170
|
LClassName = self.__class__.__name__
|
|
172
|
-
s = '{} уничтожен'.format (LClassName)
|
|
171
|
+
# s = '{} уничтожен'.format (LClassName)
|
|
173
172
|
# LULog.LoggerTOOLS_AddLevel (LULog.DEBUGTEXT, s)
|
|
174
173
|
#print (s)
|
|
175
174
|
#endfunction
|
{lyrpy → SRC/LIB/lyrpy}/LUos.py
RENAMED
|
@@ -22,7 +22,7 @@ import sys
|
|
|
22
22
|
import enum
|
|
23
23
|
import ctypes
|
|
24
24
|
import datetime
|
|
25
|
-
import
|
|
25
|
+
import subprocess
|
|
26
26
|
|
|
27
27
|
"""
|
|
28
28
|
Кроссплатформенные функции:
|
|
@@ -177,7 +177,7 @@ class TFolders (object):
|
|
|
177
177
|
""" destructor """
|
|
178
178
|
#beginfunction
|
|
179
179
|
LClassName = self.__class__.__name__
|
|
180
|
-
s = '{} уничтожен'.format(LClassName)
|
|
180
|
+
# s = '{} уничтожен'.format(LClassName)
|
|
181
181
|
# LULog.LoggerTOOLS_AddLevel (LULog.DEBUGTEXT, s)
|
|
182
182
|
#print (s)
|
|
183
183
|
#endfunction
|
|
@@ -420,7 +420,7 @@ class TOSInfo (object):
|
|
|
420
420
|
""" destructor """
|
|
421
421
|
#beginfunction
|
|
422
422
|
LClassName = self.__class__.__name__
|
|
423
|
-
s = '{} уничтожен'.format(LClassName)
|
|
423
|
+
# s = '{} уничтожен'.format(LClassName)
|
|
424
424
|
#LUConst.LULogger.log (LULog.DEBUGTEXT, s)
|
|
425
425
|
#endfunction
|
|
426
426
|
|
|
@@ -773,6 +773,16 @@ def PrintGeneralTitle ():
|
|
|
773
773
|
print ('===========================================')
|
|
774
774
|
#endfunction
|
|
775
775
|
|
|
776
|
+
#------------------------------------------
|
|
777
|
+
# Exec_dir ():
|
|
778
|
+
#------------------------------------------
|
|
779
|
+
def Exec_dir ():
|
|
780
|
+
#beginfunction
|
|
781
|
+
# Пример: Выполнение команды dir и получение вывода
|
|
782
|
+
result = subprocess.run(["dir"], shell=True, capture_output=True, text=True)
|
|
783
|
+
print(result.stdout) # Вывод команды
|
|
784
|
+
#endfunction
|
|
785
|
+
|
|
776
786
|
#------------------------------------------------------
|
|
777
787
|
# main
|
|
778
788
|
#------------------------------------------------------
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import os
|
|
2
|
+
|
|
3
|
+
print("import lyrpy")
|
|
4
|
+
|
|
5
|
+
#-------------------------------------------------------------------------------
|
|
6
|
+
#
|
|
7
|
+
#-------------------------------------------------------------------------------
|
|
8
|
+
def main ():
|
|
9
|
+
#beginfunction
|
|
10
|
+
print("Hello, **lyrpy**")
|
|
11
|
+
#endfunction
|
|
12
|
+
|
|
13
|
+
#------------------------------------------
|
|
14
|
+
#
|
|
15
|
+
#------------------------------------------
|
|
16
|
+
#beginmodule
|
|
17
|
+
if __name__ == "__main__":
|
|
18
|
+
main()
|
|
19
|
+
#endif
|
|
20
|
+
|
|
21
|
+
#endmodule
|