warp-beacon 2.3.5__tar.gz → 2.3.6__tar.gz
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.
- {warp_beacon-2.3.5/warp_beacon.egg-info → warp_beacon-2.3.6}/PKG-INFO +1 -1
- warp_beacon-2.3.6/warp_beacon/__version__.py +2 -0
- {warp_beacon-2.3.5 → warp_beacon-2.3.6}/warp_beacon/telegram/bot.py +4 -2
- {warp_beacon-2.3.5 → warp_beacon-2.3.6}/warp_beacon/telegram/handlers.py +1 -0
- {warp_beacon-2.3.5 → warp_beacon-2.3.6}/warp_beacon/telegram/utils.py +42 -5
- {warp_beacon-2.3.5 → warp_beacon-2.3.6/warp_beacon.egg-info}/PKG-INFO +1 -1
- warp_beacon-2.3.5/warp_beacon/__version__.py +0 -2
- {warp_beacon-2.3.5 → warp_beacon-2.3.6}/LICENSE +0 -0
- {warp_beacon-2.3.5 → warp_beacon-2.3.6}/MANIFEST.in +0 -0
- {warp_beacon-2.3.5 → warp_beacon-2.3.6}/README.md +0 -0
- {warp_beacon-2.3.5 → warp_beacon-2.3.6}/assets/placeholder.gif +0 -0
- {warp_beacon-2.3.5 → warp_beacon-2.3.6}/etc/.gitignore +0 -0
- {warp_beacon-2.3.5 → warp_beacon-2.3.6}/etc/accounts.json +0 -0
- {warp_beacon-2.3.5 → warp_beacon-2.3.6}/etc/proxies.json +0 -0
- {warp_beacon-2.3.5 → warp_beacon-2.3.6}/etc/warp_beacon.conf +0 -0
- {warp_beacon-2.3.5 → warp_beacon-2.3.6}/etc/warp_beacon.service +0 -0
- {warp_beacon-2.3.5 → warp_beacon-2.3.6}/pyproject.toml +0 -0
- {warp_beacon-2.3.5 → warp_beacon-2.3.6}/setup.cfg +0 -0
- {warp_beacon-2.3.5 → warp_beacon-2.3.6}/setup.py +0 -0
- {warp_beacon-2.3.5 → warp_beacon-2.3.6}/warp_beacon/__init__.py +0 -0
- {warp_beacon-2.3.5 → warp_beacon-2.3.6}/warp_beacon/compress/__init__.py +0 -0
- {warp_beacon-2.3.5 → warp_beacon-2.3.6}/warp_beacon/compress/video.py +0 -0
- {warp_beacon-2.3.5 → warp_beacon-2.3.6}/warp_beacon/jobs/__init__.py +0 -0
- {warp_beacon-2.3.5 → warp_beacon-2.3.6}/warp_beacon/jobs/abstract.py +0 -0
- {warp_beacon-2.3.5 → warp_beacon-2.3.6}/warp_beacon/jobs/download_job.py +0 -0
- {warp_beacon-2.3.5 → warp_beacon-2.3.6}/warp_beacon/jobs/types.py +0 -0
- {warp_beacon-2.3.5 → warp_beacon-2.3.6}/warp_beacon/jobs/upload_job.py +0 -0
- {warp_beacon-2.3.5 → warp_beacon-2.3.6}/warp_beacon/mediainfo/__init__.py +0 -0
- {warp_beacon-2.3.5 → warp_beacon-2.3.6}/warp_beacon/mediainfo/abstract.py +0 -0
- {warp_beacon-2.3.5 → warp_beacon-2.3.6}/warp_beacon/mediainfo/audio.py +0 -0
- {warp_beacon-2.3.5 → warp_beacon-2.3.6}/warp_beacon/mediainfo/silencer.py +0 -0
- {warp_beacon-2.3.5 → warp_beacon-2.3.6}/warp_beacon/mediainfo/video.py +0 -0
- {warp_beacon-2.3.5 → warp_beacon-2.3.6}/warp_beacon/scheduler/__init__.py +0 -0
- {warp_beacon-2.3.5 → warp_beacon-2.3.6}/warp_beacon/scheduler/scheduler.py +0 -0
- {warp_beacon-2.3.5 → warp_beacon-2.3.6}/warp_beacon/scraper/__init__.py +0 -0
- {warp_beacon-2.3.5 → warp_beacon-2.3.6}/warp_beacon/scraper/abstract.py +0 -0
- {warp_beacon-2.3.5 → warp_beacon-2.3.6}/warp_beacon/scraper/account_selector.py +0 -0
- {warp_beacon-2.3.5 → warp_beacon-2.3.6}/warp_beacon/scraper/exceptions.py +0 -0
- {warp_beacon-2.3.5 → warp_beacon-2.3.6}/warp_beacon/scraper/fail_handler.py +0 -0
- {warp_beacon-2.3.5 → warp_beacon-2.3.6}/warp_beacon/scraper/instagram/__init__.py +0 -0
- {warp_beacon-2.3.5 → warp_beacon-2.3.6}/warp_beacon/scraper/instagram/instagram.py +0 -0
- {warp_beacon-2.3.5 → warp_beacon-2.3.6}/warp_beacon/scraper/link_resolver.py +0 -0
- {warp_beacon-2.3.5 → warp_beacon-2.3.6}/warp_beacon/scraper/youtube/__init__.py +0 -0
- {warp_beacon-2.3.5 → warp_beacon-2.3.6}/warp_beacon/scraper/youtube/abstract.py +0 -0
- {warp_beacon-2.3.5 → warp_beacon-2.3.6}/warp_beacon/scraper/youtube/music.py +0 -0
- {warp_beacon-2.3.5 → warp_beacon-2.3.6}/warp_beacon/scraper/youtube/shorts.py +0 -0
- {warp_beacon-2.3.5 → warp_beacon-2.3.6}/warp_beacon/scraper/youtube/youtube.py +0 -0
- {warp_beacon-2.3.5 → warp_beacon-2.3.6}/warp_beacon/storage/__init__.py +0 -0
- {warp_beacon-2.3.5 → warp_beacon-2.3.6}/warp_beacon/storage/mongo.py +0 -0
- {warp_beacon-2.3.5 → warp_beacon-2.3.6}/warp_beacon/telegram/__init__.py +0 -0
- {warp_beacon-2.3.5 → warp_beacon-2.3.6}/warp_beacon/telegram/placeholder_message.py +0 -0
- {warp_beacon-2.3.5 → warp_beacon-2.3.6}/warp_beacon/uploader/__init__.py +0 -0
- {warp_beacon-2.3.5 → warp_beacon-2.3.6}/warp_beacon/warp_beacon.py +0 -0
- {warp_beacon-2.3.5 → warp_beacon-2.3.6}/warp_beacon.egg-info/SOURCES.txt +0 -0
- {warp_beacon-2.3.5 → warp_beacon-2.3.6}/warp_beacon.egg-info/dependency_links.txt +0 -0
- {warp_beacon-2.3.5 → warp_beacon-2.3.6}/warp_beacon.egg-info/entry_points.txt +0 -0
- {warp_beacon-2.3.5 → warp_beacon-2.3.6}/warp_beacon.egg-info/requires.txt +0 -0
- {warp_beacon-2.3.5 → warp_beacon-2.3.6}/warp_beacon.egg-info/top_level.txt +0 -0
@@ -167,7 +167,10 @@ class Bot(object):
|
|
167
167
|
caption += job.message_leftover
|
168
168
|
caption += "\n—\n"
|
169
169
|
if job.source_username:
|
170
|
-
|
170
|
+
if job.source_username.startswith("<a href="):
|
171
|
+
caption += f"Requested by <b>{job.source_username}</b>"
|
172
|
+
else:
|
173
|
+
caption += f"Requested by <b>@{job.source_username}</b>"
|
171
174
|
if job.source_username and job.url:
|
172
175
|
caption += " | "
|
173
176
|
if job.url:
|
@@ -333,7 +336,6 @@ class Bot(object):
|
|
333
336
|
else:
|
334
337
|
args["disable_notification"] = True
|
335
338
|
args["reply_to_message_id"] = job.message_id
|
336
|
-
#args["reply_to_message_id"] = None
|
337
339
|
|
338
340
|
if os.environ.get("ENABLE_DONATES", None) == "true" and job.media_type is not JobType.COLLECTION:
|
339
341
|
args["reply_markup"] = InlineKeyboardMarkup([[InlineKeyboardButton("❤ Donate", url=os.environ.get("DONATE_LINK", "https://pay.cryptocloud.plus/pos/W5BMtNQt5bJFoW2E"))]])
|
@@ -138,6 +138,7 @@ class Handlers(object):
|
|
138
138
|
urls, msg_leftover = [], ''
|
139
139
|
if urls_raw:
|
140
140
|
msg_leftover = Utils.compute_leftover(urls_raw, message_text)
|
141
|
+
msg_leftover = Utils.handle_mentions(chat.id, client, msg_leftover)
|
141
142
|
# remove duplicates
|
142
143
|
urls = list(set(urls_raw))
|
143
144
|
|
@@ -1,8 +1,11 @@
|
|
1
|
-
from typing import Union
|
1
|
+
from typing import Union, Optional
|
2
2
|
|
3
3
|
import re
|
4
4
|
|
5
|
+
from pyrogram import Client
|
5
6
|
from pyrogram.types import Message
|
7
|
+
from pyrogram.types import ChatMember
|
8
|
+
from pyrogram import enums
|
6
9
|
|
7
10
|
from warp_beacon.jobs import Origin
|
8
11
|
from warp_beacon.jobs.types import JobType
|
@@ -11,9 +14,10 @@ import logging
|
|
11
14
|
|
12
15
|
class Utils(object):
|
13
16
|
expected_patronum_compiled_re = re.compile(r'Expected ([A-Z]+), got ([A-Z]+) file id instead')
|
17
|
+
mention_re = re.compile(r'@[A-Za-z0-9_.]{4,}')
|
14
18
|
|
15
19
|
@staticmethod
|
16
|
-
def extract_file_id(message: Message) ->
|
20
|
+
def extract_file_id(message: Message) -> Optional[str]:
|
17
21
|
possible_attrs = ("video", "photo", "audio", "animation", "document")
|
18
22
|
for attr in possible_attrs:
|
19
23
|
if hasattr(message, attr):
|
@@ -67,19 +71,21 @@ class Utils(object):
|
|
67
71
|
return ''
|
68
72
|
|
69
73
|
@staticmethod
|
70
|
-
def extract_message_author(message: Message) -> str:
|
74
|
+
async def extract_message_author(message: Message) -> str:
|
71
75
|
if message.from_user:
|
72
76
|
if message.from_user.username:
|
73
77
|
return message.from_user.username
|
78
|
+
if message.from_user.first_name:
|
79
|
+
return message.from_user.first_name
|
74
80
|
if message.from_user.id:
|
75
|
-
return str(message.from_user.
|
81
|
+
return str(message.from_user.mention(style=enums.ParseMode.HTML))
|
76
82
|
if message.sender_chat:
|
77
83
|
if message.sender_chat.username:
|
78
84
|
return message.sender_chat.username
|
79
85
|
if message.sender_chat.title:
|
80
86
|
return message.sender_chat.title
|
81
87
|
return ''
|
82
|
-
|
88
|
+
|
83
89
|
@staticmethod
|
84
90
|
def compute_leftover(urls: list, message: str) -> str:
|
85
91
|
msg_leftover = ""
|
@@ -88,3 +94,34 @@ class Utils(object):
|
|
88
94
|
for u in urls:
|
89
95
|
msg_leftover = msg_leftover.replace(u, '')
|
90
96
|
return msg_leftover.strip()
|
97
|
+
|
98
|
+
@staticmethod
|
99
|
+
async def find_chat_user_by_id(client: Client, chat_id: int, user_id: int) -> Optional[ChatMember]:
|
100
|
+
ret = None
|
101
|
+
async for member in client.get_chat_members(chat_id):
|
102
|
+
user_id = 0
|
103
|
+
if member.user.id == user_id:
|
104
|
+
ret = member.user
|
105
|
+
break
|
106
|
+
return ret
|
107
|
+
|
108
|
+
@staticmethod
|
109
|
+
def handle_mentions(chat_id: int, client: Client, message: str) -> str:
|
110
|
+
try:
|
111
|
+
username = ''
|
112
|
+
members = client.get_chat_members(chat_id)
|
113
|
+
mentions = Utils.mention_re.findall(message)
|
114
|
+
for mention in mentions:
|
115
|
+
username = mention[1:].strip()
|
116
|
+
if username:
|
117
|
+
user_id = 0
|
118
|
+
for member in members:
|
119
|
+
if member.user.username == username:
|
120
|
+
user_id = member.user.id
|
121
|
+
break
|
122
|
+
if user_id:
|
123
|
+
message.replace(f"@{username}", f'<a href="tg://user?id={user_id}">{username}</a>')
|
124
|
+
except Exception as e:
|
125
|
+
logging.warning("Exception occurred while handling TG mentions!")
|
126
|
+
logging.exception(e)
|
127
|
+
return message
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|