mirror of
https://github.com/civsocit/olgram.git
synced 2023-07-22 01:29:12 +03:00
рабочий ответ на info сообщение
This commit is contained in:
parent
afdb623358
commit
8efc40730f
@ -89,7 +89,7 @@ class ServerSettings(AbstractSettings):
|
|||||||
@classmethod
|
@classmethod
|
||||||
@lru_cache
|
@lru_cache
|
||||||
def redis_timeout_ms(cls) -> ty.Optional[int]:
|
def redis_timeout_ms(cls) -> ty.Optional[int]:
|
||||||
return int(timedelta(days=30).total_seconds() * 1000.0)
|
return int(timedelta(days=20).total_seconds() * 1000.0)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@lru_cache
|
@lru_cache
|
||||||
|
@ -45,10 +45,17 @@ async def send_user_message(message: types.Message, super_chat_id: int, bot):
|
|||||||
user_info += " | @" + message.from_user.username
|
user_info += " | @" + message.from_user.username
|
||||||
user_info += f" | #{message.from_user.id}"
|
user_info += f" | #{message.from_user.id}"
|
||||||
new_message = await message.bot.send_message(super_chat_id, text=user_info)
|
new_message = await message.bot.send_message(super_chat_id, text=user_info)
|
||||||
await message.copy_to(super_chat_id, reply_to_message_id=new_message.message_id)
|
await _redis.set(_message_unique_id(bot.pk, new_message.message_id), message.chat.id,
|
||||||
|
pexpire=ServerSettings.redis_timeout_ms())
|
||||||
|
new_message_2 = await message.copy_to(super_chat_id, reply_to_message_id=new_message.message_id)
|
||||||
|
await _redis.set(_message_unique_id(bot.pk, new_message_2.message_id), message.chat.id,
|
||||||
|
pexpire=ServerSettings.redis_timeout_ms())
|
||||||
return new_message
|
return new_message
|
||||||
else:
|
else:
|
||||||
return await message.forward(super_chat_id)
|
new_message = await message.forward(super_chat_id)
|
||||||
|
await _redis.set(_message_unique_id(bot.pk, new_message.message_id), message.chat.id,
|
||||||
|
pexpire=ServerSettings.redis_timeout_ms())
|
||||||
|
return new_message
|
||||||
|
|
||||||
|
|
||||||
async def handle_user_message(message: types.Message, super_chat_id: int, bot):
|
async def handle_user_message(message: types.Message, super_chat_id: int, bot):
|
||||||
@ -81,9 +88,6 @@ async def handle_user_message(message: types.Message, super_chat_id: int, bot):
|
|||||||
else: # личные сообщения не поддерживают потоки сообщений: простой forward
|
else: # личные сообщения не поддерживают потоки сообщений: простой forward
|
||||||
new_message = await send_user_message(message, super_chat_id, bot)
|
new_message = await send_user_message(message, super_chat_id, bot)
|
||||||
|
|
||||||
await _redis.set(_message_unique_id(bot.pk, new_message.message_id), message.chat.id,
|
|
||||||
pexpire=ServerSettings.redis_timeout_ms())
|
|
||||||
|
|
||||||
bot.incoming_messages_count = F("incoming_messages_count") + 1
|
bot.incoming_messages_count = F("incoming_messages_count") + 1
|
||||||
await bot.save(update_fields=["incoming_messages_count"])
|
await bot.save(update_fields=["incoming_messages_count"])
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user