Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7ad4c4052e | ||
|
|
641dc72738 | ||
|
|
cafa7ce1c5 | ||
|
|
c9a46b2b07 | ||
|
|
92ee0e405d |
@@ -1,3 +1,5 @@
|
|||||||
|
__all__ = ['FlanaBot']
|
||||||
|
|
||||||
import asyncio
|
import asyncio
|
||||||
import datetime
|
import datetime
|
||||||
import random
|
import random
|
||||||
@@ -10,6 +12,7 @@ import flanaapis.geolocation.functions
|
|||||||
import flanaapis.weather.functions
|
import flanaapis.weather.functions
|
||||||
import flanautils
|
import flanautils
|
||||||
import plotly.graph_objects
|
import plotly.graph_objects
|
||||||
|
import pymongo
|
||||||
from flanaapis import InstagramLoginError, MediaNotFoundError, Place, PlaceNotFoundError, WeatherEmoji, instagram, tiktok, twitter
|
from flanaapis import InstagramLoginError, MediaNotFoundError, Place, PlaceNotFoundError, WeatherEmoji, instagram, tiktok, twitter
|
||||||
from flanautils import Media, MediaType, NotFoundError, OrderedSet, Source, TimeUnits, TraceMetadata, return_if_first_empty
|
from flanautils import Media, MediaType, NotFoundError, OrderedSet, Source, TimeUnits, TraceMetadata, return_if_first_empty
|
||||||
from multibot import Action, BadRoleError, BotAction, MultiBot, SendError, User, admin, bot_mentioned, constants as multibot_constants, group, ignore_self_message, inline, reply
|
from multibot import Action, BadRoleError, BotAction, MultiBot, SendError, User, admin, bot_mentioned, constants as multibot_constants, group, ignore_self_message, inline, reply
|
||||||
@@ -184,6 +187,7 @@ class FlanaBot(MultiBot, ABC):
|
|||||||
config = message.chat.config
|
config = message.chat.config
|
||||||
|
|
||||||
buttons_texts = [f"{'✔' if v else '❌'} {k}" for k, v in config.items()]
|
buttons_texts = [f"{'✔' if v else '❌'} {k}" for k, v in config.items()]
|
||||||
|
# noinspection PyTypeChecker
|
||||||
return flanautils.chunks(buttons_texts, 3)
|
return flanautils.chunks(buttons_texts, 3)
|
||||||
|
|
||||||
@return_if_first_empty(exclude_self_types='FlanaBot', globals_=globals())
|
@return_if_first_empty(exclude_self_types='FlanaBot', globals_=globals())
|
||||||
@@ -460,14 +464,18 @@ class FlanaBot(MultiBot, ABC):
|
|||||||
@inline(False)
|
@inline(False)
|
||||||
async def _on_recover_message(self, message: Message):
|
async def _on_recover_message(self, message: Message):
|
||||||
if message.replied_message:
|
if message.replied_message:
|
||||||
message_deleted_bot_action = BotAction.find_one({'action': bytes(Action.MESSAGE_DELETED), 'chat': message.chat.object_id, 'affected_objects': message.replied_message.object_id})
|
message_deleted_bot_action = BotAction.find_one({'action': Action.MESSAGE_DELETED.value, 'chat': message.chat.object_id, 'affected_objects': message.replied_message.object_id})
|
||||||
elif self.is_bot_mentioned(message):
|
elif self.is_bot_mentioned(message):
|
||||||
message_deleted_bot_action = BotAction.find_one({'action': bytes(Action.MESSAGE_DELETED), 'chat': message.chat.object_id, 'date': {'$gt': datetime.datetime.now(datetime.timezone.utc) - constants.RECOVERY_DELETED_MESSAGE_BEFORE}})
|
message_deleted_bot_action = BotAction.find_one({
|
||||||
|
'action': Action.MESSAGE_DELETED.value,
|
||||||
|
'chat': message.chat.object_id,
|
||||||
|
'date': {'$gt': datetime.datetime.now(datetime.timezone.utc) - constants.RECOVERY_DELETED_MESSAGE_BEFORE}
|
||||||
|
}, sort_keys=(('date', pymongo.DESCENDING),))
|
||||||
else:
|
else:
|
||||||
return
|
return
|
||||||
|
|
||||||
if not message_deleted_bot_action:
|
if not message_deleted_bot_action:
|
||||||
await self.send_error(random.choice(constants.RECOVER_PHRASES), message)
|
await self.send_error('No hay nada que recuperar.', message)
|
||||||
return
|
return
|
||||||
|
|
||||||
affected_object_ids = [affected_message_object_id for affected_message_object_id in message_deleted_bot_action.affected_objects]
|
affected_object_ids = [affected_message_object_id for affected_message_object_id in message_deleted_bot_action.affected_objects]
|
||||||
@@ -475,8 +483,6 @@ class FlanaBot(MultiBot, ABC):
|
|||||||
for deleted_message in deleted_messages:
|
for deleted_message in deleted_messages:
|
||||||
await self.send(deleted_message.text, message)
|
await self.send(deleted_message.text, message)
|
||||||
|
|
||||||
message_deleted_bot_action.delete()
|
|
||||||
|
|
||||||
async def _on_scraping(self, message: Message, delete_original: bool = None) -> OrderedSet[Media]:
|
async def _on_scraping(self, message: Message, delete_original: bool = None) -> OrderedSet[Media]:
|
||||||
sended_media_messages = await self._search_and_send_medias(message.replied_message) if message.replied_message else OrderedSet()
|
sended_media_messages = await self._search_and_send_medias(message.replied_message) if message.replied_message else OrderedSet()
|
||||||
sended_media_messages += await self._search_and_send_medias(message)
|
sended_media_messages += await self._search_and_send_medias(message)
|
||||||
@@ -568,8 +574,9 @@ class FlanaBot(MultiBot, ABC):
|
|||||||
possible_mentioned_ids.append(user.name.split('#')[0].lower())
|
possible_mentioned_ids.append(user.name.split('#')[0].lower())
|
||||||
possible_mentioned_ids.append(f'@{user.id}')
|
possible_mentioned_ids.append(f'@{user.id}')
|
||||||
|
|
||||||
for role in await self.get_group_roles(message):
|
if roles := await self.get_group_roles(message):
|
||||||
possible_mentioned_ids.append(f'@{role.id}')
|
for role in roles:
|
||||||
|
possible_mentioned_ids.append(f'@{role.id}')
|
||||||
|
|
||||||
original_text_words = flanautils.remove_accents(message.text.lower())
|
original_text_words = flanautils.remove_accents(message.text.lower())
|
||||||
original_text_words = original_text_words.replace(',', ' ').replace(';', ' ').replace('-', ' -')
|
original_text_words = original_text_words.replace(',', ' ').replace(';', ' ').replace('-', ' -')
|
||||||
@@ -757,10 +764,7 @@ class FlanaBot(MultiBot, ABC):
|
|||||||
message.song_infos.add(media.song_info)
|
message.song_infos.add(media.song_info)
|
||||||
message.save()
|
message.save()
|
||||||
|
|
||||||
try:
|
if not (bot_message := await self.send(media, message)):
|
||||||
bot_message = await self.send(media, message)
|
|
||||||
except SendError as e:
|
|
||||||
await self._manage_exceptions(e, message)
|
|
||||||
fails += 1
|
fails += 1
|
||||||
else:
|
else:
|
||||||
sended_media_messages.append(bot_message)
|
sended_media_messages.append(bot_message)
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
__all__ = ['FlanaDiscBot']
|
||||||
|
|
||||||
import asyncio
|
import asyncio
|
||||||
import os
|
import os
|
||||||
|
|
||||||
@@ -29,7 +31,7 @@ HOT_CHANNEL_ID = 493530483045564417
|
|||||||
# ---------------------------------------------------------------------------------------------------- #
|
# ---------------------------------------------------------------------------------------------------- #
|
||||||
class FlanaDiscBot(DiscordBot, FlanaBot):
|
class FlanaDiscBot(DiscordBot, FlanaBot):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super().__init__(os.environ['DISCORD_BOT_TOKEN2'])
|
super().__init__(os.environ['DISCORD_BOT_TOKEN'])
|
||||||
self.heating = False
|
self.heating = False
|
||||||
self.heat_level = 0
|
self.heat_level = 0
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
from __future__ import annotations # todo0 remove in 3.11
|
from __future__ import annotations # todo0 remove in 3.11
|
||||||
|
|
||||||
|
__all__ = ['whitelisted_event', 'FlanaTeleBot']
|
||||||
|
|
||||||
import functools
|
import functools
|
||||||
import os
|
import os
|
||||||
from typing import Callable
|
from typing import Callable
|
||||||
@@ -36,7 +38,7 @@ class FlanaTeleBot(TelegramBot, FlanaBot):
|
|||||||
super().__init__(
|
super().__init__(
|
||||||
api_id=os.environ['TELEGRAM_API_ID'],
|
api_id=os.environ['TELEGRAM_API_ID'],
|
||||||
api_hash=os.environ['TELEGRAM_API_HASH'],
|
api_hash=os.environ['TELEGRAM_API_HASH'],
|
||||||
bot_session=os.environ['TELEGRAM_BOT_SESSION2'],
|
bot_session=os.environ['TELEGRAM_BOT_SESSION'],
|
||||||
user_session=os.environ['TELEGRAM_USER_SESSION']
|
user_session=os.environ['TELEGRAM_USER_SESSION']
|
||||||
)
|
)
|
||||||
self.whitelist_ids = []
|
self.whitelist_ids = []
|
||||||
|
|||||||
@@ -71,14 +71,5 @@ KEYWORDS = {
|
|||||||
'wetter')
|
'wetter')
|
||||||
}
|
}
|
||||||
|
|
||||||
RECOVER_PHRASES = (
|
|
||||||
'No hay nada que recuperar.',
|
|
||||||
'Ya lo he recuperado y enviado, así que callate ya.',
|
|
||||||
'Ya lo he recuperado y enviado, así que mejor estás antento antes de dar por culo.',
|
|
||||||
'Ya lo he recuperado y enviado, no lo voy a hacer dos veces.',
|
|
||||||
'Ya lo he recuperado y enviado. A ver si leemos más y jodemos menos.',
|
|
||||||
'Ya lo he reenviado.'
|
|
||||||
)
|
|
||||||
|
|
||||||
SCRAPING_PHRASES = ('Analizando...', 'Buscando...', 'Hackeando internet... 👀', 'Rebuscando en la web...',
|
SCRAPING_PHRASES = ('Analizando...', 'Buscando...', 'Hackeando internet... 👀', 'Rebuscando en la web...',
|
||||||
'Robando cosas...', 'Scrapeando...', 'Scraping...')
|
'Robando cosas...', 'Scrapeando...', 'Scraping...')
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import flanautils
|
|||||||
os.environ |= flanautils.find_environment_variables('../.env')
|
os.environ |= flanautils.find_environment_variables('../.env')
|
||||||
|
|
||||||
import asyncio
|
import asyncio
|
||||||
|
|
||||||
from flanabot.bots.flana_disc_bot import FlanaDiscBot
|
from flanabot.bots.flana_disc_bot import FlanaDiscBot
|
||||||
from flanabot.bots.flana_tele_bot import FlanaTeleBot
|
from flanabot.bots.flana_tele_bot import FlanaTeleBot
|
||||||
|
|
||||||
@@ -13,7 +12,6 @@ from flanabot.bots.flana_tele_bot import FlanaTeleBot
|
|||||||
async def main():
|
async def main():
|
||||||
flana_disc_bot = FlanaDiscBot()
|
flana_disc_bot = FlanaDiscBot()
|
||||||
flana_tele_bot = FlanaTeleBot()
|
flana_tele_bot = FlanaTeleBot()
|
||||||
|
|
||||||
await asyncio.gather(
|
await asyncio.gather(
|
||||||
flana_disc_bot.start(),
|
flana_disc_bot.start(),
|
||||||
flana_tele_bot.start()
|
flana_tele_bot.start()
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
__all__ = ['Chat']
|
||||||
|
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
|
|
||||||
from multibot.models import Chat as MultiBotChat
|
from multibot.models import Chat as MultiBotChat
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
__all__ = ['ButtonsMessageType']
|
||||||
|
|
||||||
from enum import auto
|
from enum import auto
|
||||||
|
|
||||||
from flanautils import FlanaEnum
|
from flanautils import FlanaEnum
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
from __future__ import annotations # todo0 remove in 3.11
|
from __future__ import annotations # todo0 remove in 3.11
|
||||||
|
|
||||||
|
__all__ = ['Message']
|
||||||
|
|
||||||
from dataclasses import dataclass, field
|
from dataclasses import dataclass, field
|
||||||
from typing import Iterable
|
from typing import Iterable
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
__all__ = ['Direction', 'WeatherChart']
|
||||||
|
|
||||||
import datetime
|
import datetime
|
||||||
from dataclasses import dataclass, field
|
from dataclasses import dataclass, field
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
aiohttp==3.7.4.post0
|
aiohttp==3.8.1
|
||||||
aiosignal==1.2.0
|
aiosignal==1.2.0
|
||||||
anyio==3.5.0
|
anyio==3.5.0
|
||||||
asgiref==3.4.1
|
asgiref==3.4.1
|
||||||
async-generator==1.10
|
async-generator==1.10
|
||||||
async-timeout==3.0.1
|
async-timeout==4.0.2
|
||||||
attrs==21.4.0
|
attrs==21.4.0
|
||||||
beautifulsoup4==4.10.0
|
beautifulsoup4==4.10.0
|
||||||
certifi==2021.10.8
|
certifi==2021.10.8
|
||||||
@@ -14,7 +14,7 @@ click==8.0.3
|
|||||||
colorama==0.4.4
|
colorama==0.4.4
|
||||||
cryptg==0.2.post4
|
cryptg==0.2.post4
|
||||||
cryptography==36.0.1
|
cryptography==36.0.1
|
||||||
discord.py==2.0.0a4269+gb7e25645
|
discord.py @ git+https://github.com/Rapptz/discord.py@b7e25645dc68bbb828bf1ede711d098c6b183237
|
||||||
fastapi==0.71.0
|
fastapi==0.71.0
|
||||||
flanaapis
|
flanaapis
|
||||||
flanautils
|
flanautils
|
||||||
@@ -47,6 +47,7 @@ selenium-stealth==1.0.6
|
|||||||
six==1.16.0
|
six==1.16.0
|
||||||
sniffio==1.2.0
|
sniffio==1.2.0
|
||||||
sortedcontainers==2.4.0
|
sortedcontainers==2.4.0
|
||||||
|
soupsieve==2.3.1
|
||||||
starlette==0.17.1
|
starlette==0.17.1
|
||||||
sympy==1.9
|
sympy==1.9
|
||||||
Telethon==1.24.0
|
Telethon==1.24.0
|
||||||
@@ -54,7 +55,7 @@ tenacity==8.0.1
|
|||||||
TikTokApi==4.1.0
|
TikTokApi==4.1.0
|
||||||
trio==0.19.0
|
trio==0.19.0
|
||||||
trio-websocket==0.9.2
|
trio-websocket==0.9.2
|
||||||
twitchio==2.1.4
|
twitchio==2.3.0
|
||||||
typing_extensions==4.0.1
|
typing_extensions==4.0.1
|
||||||
ujson==5.1.0
|
ujson==5.1.0
|
||||||
urllib3==1.26.8
|
urllib3==1.26.8
|
||||||
|
|||||||
Reference in New Issue
Block a user