5 Commits

Author SHA1 Message Date
AlberLC
b54dd8d944 Update requirements.txt 2023-05-19 07:07:03 +02:00
AlberLC
376da6f072 Update requirements.txt 2023-05-19 06:56:18 +02:00
AlberLC
f396d2b232 Improve legibility 2023-05-19 06:47:16 +02:00
AlberLC
6c3a8e5e4a Fix fake instagram ban (restricted age) 2023-05-19 06:43:13 +02:00
AlberLC
d9eb01e5c0 Add minor changes 2023-05-09 05:32:59 +02:00
3 changed files with 33 additions and 21 deletions

View File

@@ -225,14 +225,13 @@ class FlanaBot(Connect4Bot, PenaltyBot, PollBot, ScraperBot, UberEatsBot, Weathe
@inline(False)
async def _on_delete(self, message: Message):
if message.replied_message:
if (
self.is_bot_mentioned(message)
and
(message.author.is_admin or message.replied_message.author.id == self.id)
):
if not self.is_bot_mentioned(message):
return
if message.author.is_admin or message.replied_message.author.id == self.id:
flanautils.do_later(flanautils.text_to_time(message.text).total_seconds(), self.delete_message, message.replied_message)
await self.delete_message(message)
elif message.chat.is_group and self.is_bot_mentioned(message):
elif message.chat.is_group:
await self.send_negative(message)
elif (
(message.chat.is_private or self.is_bot_mentioned(message))

View File

@@ -225,6 +225,7 @@ class ScraperBot(MultiBot, ABC):
)
instagram_results = []
instagram_restricted_age_ids = []
if instagram_ids:
can_instagram_v1 = not self.instagram_ban_date or datetime.datetime.now(datetime.timezone.utc) - self.instagram_ban_date >= constants.INSTAGRAM_BAN_SLEEP
if can_instagram_v1:
@@ -232,14 +233,24 @@ class ScraperBot(MultiBot, ABC):
instagram_results = await instagram.get_medias(instagram_ids, audio_only)
except InstagramMediaNotFoundError:
pass
else:
instagram_restricted_age_ids = [media.content for media in instagram_results if media.type_ is MediaType.ERROR]
if not instagram_results:
v2_ids = instagram_ids
elif instagram_restricted_age_ids:
v2_ids = instagram_restricted_age_ids
else:
v2_ids = []
if v2_ids:
try:
instagram_results = await instagram.get_medias_v2(instagram_ids, audio_only)
except InstagramMediaNotFoundError as e:
if not (instagram_results := await yt_dlp_wrapper.get_medias(instagram.make_urls(instagram_ids), 'h264', 'mp4', force, audio_only, timeout_for_media)):
exceptions.append(e)
if instagram_results and can_instagram_v1:
if instagram_results and can_instagram_v1 and not instagram_restricted_age_ids:
self.instagram_ban_date = datetime.datetime.now(datetime.timezone.utc)
await self.send('Límite de Instagram excedido.', await self.owner_chat)
@@ -377,20 +388,20 @@ class ScraperBot(MultiBot, ABC):
if message.chat.is_group:
sended_info_message = await self.send(f"{message.author.name.split('#')[0]} compartió{self._medias_sended_info(medias)}", message, reply_to=message.replied_message)
if (
send_user_context
and
(user_text := ' '.join(
[word for word in message.text.split()
if (
not any(await self._find_ids(word))
and
not flanautils.find_urls(word)
and
not flanautils.cartesian_product_string_matching(word, keywords, multibot_constants.PARSER_MIN_SCORE_DEFAULT)
and
flanautils.remove_symbols(word).lower() not in (str(self.id), self.name.lower())
)]
))
send_user_context
and
(user_text := ' '.join(
[word for word in message.text.split()
if (
not any(await self._find_ids(word))
and
not flanautils.find_urls(word)
and
not flanautils.cartesian_product_string_matching(word, keywords, multibot_constants.PARSER_MIN_SCORE_DEFAULT)
and
flanautils.remove_symbols(word).lower() not in (str(self.id), self.name.lower())
)]
))
):
user_text_bot_message = await self.send(user_text, message, reply_to=message.replied_message)

View File

@@ -5,6 +5,7 @@ async-timeout==4.0.2
attrs==22.2.0
beautifulsoup4==4.11.1
Brotli==1.0.9
browser_cookie3==0.18.1
certifi==2022.12.7
charset-normalizer==2.1.1
click==8.1.3
@@ -21,6 +22,7 @@ h11==0.14.0
hachoir==3.2.0
idna==3.4
iso8601==1.1.0
jeepney==0.8.0
jellyfish==0.9.0
kaleido==0.2.1
mpmath==1.2.1