Update BotAction
This commit is contained in:
@@ -246,9 +246,15 @@ class FlanaBot(Connect4Bot, PenaltyBot, PollBot, ScraperBot, WeatherBot, MultiBo
|
||||
@inline(False)
|
||||
async def _on_recover_message(self, message: Message):
|
||||
if message.replied_message and message.replied_message.author.id == self.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})
|
||||
message_deleted_bot_action = BotAction.find_one({
|
||||
'platform': self.platform.value,
|
||||
'action': Action.MESSAGE_DELETED.value,
|
||||
'chat': message.chat.object_id,
|
||||
'affected_objects': message.replied_message.object_id
|
||||
})
|
||||
elif self.is_bot_mentioned(message):
|
||||
message_deleted_bot_action = BotAction.find_one({
|
||||
'platform': self.platform.value,
|
||||
'action': Action.MESSAGE_DELETED.value,
|
||||
'chat': message.chat.object_id,
|
||||
'date': {'$gt': datetime.datetime.now(datetime.timezone.utc) - constants.RECOVERY_DELETED_MESSAGE_BEFORE}
|
||||
|
||||
@@ -174,7 +174,7 @@ class ScraperBot(MultiBot, ABC):
|
||||
message.chat.config['scraping_delete_original']
|
||||
):
|
||||
# noinspection PyTypeChecker
|
||||
BotAction(Action.MESSAGE_DELETED, message, affected_objects=[message, *sended_media_messages]).save()
|
||||
BotAction(self.platform.value, Action.MESSAGE_DELETED, message, affected_objects=[message, *sended_media_messages]).save()
|
||||
await self.delete_message(message)
|
||||
|
||||
return sended_media_messages
|
||||
|
||||
@@ -40,7 +40,7 @@ class WeatherBot(MultiBot, ABC):
|
||||
show_progress_state = False
|
||||
elif message.chat.is_group and not self.is_bot_mentioned(message):
|
||||
if message.chat.config['auto_weather_chart']:
|
||||
if BotAction.find_one({'action': Action.AUTO_WEATHER_CHART.value, 'chat': message.chat.object_id, 'date': {'$gt': datetime.datetime.now(datetime.timezone.utc) - constants.AUTO_WEATHER_EVERY}}):
|
||||
if BotAction.find_one({'platform': self.platform.value, 'action': Action.AUTO_WEATHER_CHART.value, 'chat': message.chat.object_id, 'date': {'$gt': datetime.datetime.now(datetime.timezone.utc) - constants.AUTO_WEATHER_EVERY}}):
|
||||
return
|
||||
show_progress_state = False
|
||||
else:
|
||||
@@ -161,7 +161,7 @@ class WeatherBot(MultiBot, ABC):
|
||||
|
||||
if bot_message and not self.is_bot_mentioned(message):
|
||||
# noinspection PyTypeChecker
|
||||
BotAction(Action.AUTO_WEATHER_CHART, message, affected_objects=[bot_message]).save()
|
||||
BotAction(self.platform.value, Action.AUTO_WEATHER_CHART, message, affected_objects=[bot_message]).save()
|
||||
|
||||
async def _on_weather_button_press(self, message: Message):
|
||||
await self.accept_button_event(message)
|
||||
|
||||
@@ -4,7 +4,7 @@ import datetime
|
||||
from dataclasses import dataclass, field
|
||||
|
||||
from flanautils import DCMongoBase, FlanaBase
|
||||
from multibot.models.user import User
|
||||
from multibot import Platform, User
|
||||
|
||||
from flanabot.models.chat import Chat
|
||||
from flanabot.models.enums import Action
|
||||
@@ -17,6 +17,7 @@ class BotAction(DCMongoBase, FlanaBase):
|
||||
unique_keys = 'message'
|
||||
nullable_unique_keys = 'message'
|
||||
|
||||
platform: Platform = None
|
||||
action: Action = None
|
||||
message: Message = None
|
||||
author: User = None
|
||||
|
||||
Reference in New Issue
Block a user