Skip to content

Commit

Permalink
Increase logs timeout to prevent simplest spam-attack, None-safety fo…
Browse files Browse the repository at this point in the history
…r message.text
  • Loading branch information
SyberiaK committed Jan 19, 2024
1 parent 4c0fad8 commit e875202
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions bottypes/botclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class BotClient(Client):
Custom pyrogram.Client class to add custom properties and methods and stop PyCharm annoy me.
"""

LOGS_TIMEOUT = dt.timedelta(seconds=4) # define how often logs should be sent
LOGS_TIMEOUT = dt.timedelta(seconds=10) # define how often logs should be sent

WILDCARD = '_'

Expand Down Expand Up @@ -219,6 +219,9 @@ async def inner(client: BotClient, session: UserSession, bot_message: Message, u
async def handle_message(self, message: Message):
user = message.from_user

if message.text is None:
return

if message.chat.type != ChatType.PRIVATE:
if message.text.startswith(self.commands_prefix):
session = await self.register_session(user, message) # early command handling in group chats
Expand Down Expand Up @@ -494,7 +497,7 @@ async def _log_message(self, session: UserSession, message: Message):
f'ID: {message.from_user.id}\n'
f'Telegram language: {message.from_user.language_code}\n'
f'Chosen language: {session.locale.lang_code}\n'
f'Private message: "{message.text}"')
f'Private message: "{message.text if message.text is not None else ""}"')
await self.send_message(self.log_channel_id, text, disable_notification=True)

async def _log_callback(self, session: UserSession, callback_query: CallbackQuery):
Expand Down

0 comments on commit e875202

Please sign in to comment.