mirror of
				https://github.com/civsocit/olgram.git
				synced 2025-10-29 11:13:25 +00:00 
			
		
		
		
	Compare commits
	
		
			2 Commits
		
	
	
		
			82b68d1d9f
			...
			ae45374490
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
|  | ae45374490 | ||
|  | 0881c86349 | 
							
								
								
									
										25
									
								
								.readthedocs.yaml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										25
									
								
								.readthedocs.yaml
									
									
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,25 @@ | ||||||
|  | # Read the Docs configuration file for Sphinx projects | ||||||
|  | 
 | ||||||
|  | # See https://docs.readthedocs.io/en/stable/config-file/v2.html for details | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | # Required | ||||||
|  | 
 | ||||||
|  | version: 2 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | # Set the OS, Python version and other tools you might need | ||||||
|  | 
 | ||||||
|  | build: | ||||||
|  |   os: ubuntu-22.04 | ||||||
|  |   tools: | ||||||
|  |     python: "3.8" | ||||||
|  |   jobs: | ||||||
|  |     post_create_environment: | ||||||
|  |       - python -m pip install sphinx_rtd_theme | ||||||
|  | 
 | ||||||
|  | # Build documentation in the "docs/" directory with Sphinx | ||||||
|  | 
 | ||||||
|  | sphinx: | ||||||
|  | 
 | ||||||
|  |   configuration: docs/source/conf.py | ||||||
|  | @ -20,6 +20,7 @@ Litecoin: | ||||||
| История изменений | История изменений | ||||||
| ---------------- | ---------------- | ||||||
| 
 | 
 | ||||||
|  | - `2024-02-17` Опция смены режима работы автоответчика: автоответчик отвечает на КАЖДОЕ сообщение | ||||||
| - `2024-01-12` Мультиязычность (стартовое сообщение и автоответчик) | - `2024-01-12` Мультиязычность (стартовое сообщение и автоответчик) | ||||||
| - `2022-08-01` Защита от флуда | - `2022-08-01` Защита от флуда | ||||||
| - `2022-07-23` Автоответчик не пишет сообщение лишний раз | - `2022-07-23` Автоответчик не пишет сообщение лишний раз | ||||||
|  |  | ||||||
|  | @ -49,3 +49,12 @@ Olgram пересылает сообщения так, чтобы сообщен | ||||||
| 
 | 
 | ||||||
| При включении этой опции пользователю запрещается отправлять больше одного сообщения в минуту. Используйте её, если | При включении этой опции пользователю запрещается отправлять больше одного сообщения в минуту. Используйте её, если | ||||||
| не успеваете обрабатывать входящие сообщения. | не успеваете обрабатывать входящие сообщения. | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | .. _always_second_message: | ||||||
|  | 
 | ||||||
|  | Использовать автоответчик всегда | ||||||
|  | -------------------------------- | ||||||
|  | 
 | ||||||
|  | По-умолчанию автоответчик отвечает только на первое сообщение в диалоге с пользователем. Чтобы автоответчик отвечал на | ||||||
|  | КАЖДОЕ входящее сообщение, включите эту опцию. | ||||||
|  |  | ||||||
|  | @ -109,6 +109,11 @@ async def additional_info(bot: Bot, call: types.CallbackQuery): | ||||||
|     await bot.save(update_fields=["enable_additional_info"]) |     await bot.save(update_fields=["enable_additional_info"]) | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  | async def always_second_message(bot: Bot, call: types.CallbackQuery): | ||||||
|  |     bot.enable_always_second_message = not bot.enable_always_second_message | ||||||
|  |     await bot.save(update_fields=["enable_always_second_message"]) | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
| async def olgram_text(bot: Bot, call: types.CallbackQuery): | async def olgram_text(bot: Bot, call: types.CallbackQuery): | ||||||
|     if await bot.is_promo(): |     if await bot.is_promo(): | ||||||
|         bot.enable_olgram_text = not bot.enable_olgram_text |         bot.enable_olgram_text = not bot.enable_olgram_text | ||||||
|  |  | ||||||
|  | @ -172,6 +172,12 @@ async def send_bot_settings_menu(bot: Bot, call: types.CallbackQuery): | ||||||
|                                    callback_data=menu_callback.new(level=3, bot_id=bot.id, operation="antiflood", |                                    callback_data=menu_callback.new(level=3, bot_id=bot.id, operation="antiflood", | ||||||
|                                                                    chat=empty)) |                                                                    chat=empty)) | ||||||
|     ) |     ) | ||||||
|  |     keyboard.insert( | ||||||
|  |         types.InlineKeyboardButton(text=_("Автоответчик всегда"), | ||||||
|  |                                    callback_data=menu_callback.new(level=3, bot_id=bot.id, | ||||||
|  |                                                                    operation="always_second_message", | ||||||
|  |                                                                    chat=empty)) | ||||||
|  |     ) | ||||||
|     is_promo = await bot.is_promo() |     is_promo = await bot.is_promo() | ||||||
|     if is_promo: |     if is_promo: | ||||||
|         keyboard.insert( |         keyboard.insert( | ||||||
|  | @ -189,11 +195,14 @@ async def send_bot_settings_menu(bot: Bot, call: types.CallbackQuery): | ||||||
|     thread_turn = _("включены") if bot.enable_threads else _("выключены") |     thread_turn = _("включены") if bot.enable_threads else _("выключены") | ||||||
|     info_turn = _("включены") if bot.enable_additional_info else _("выключены") |     info_turn = _("включены") if bot.enable_additional_info else _("выключены") | ||||||
|     antiflood_turn = _("включен") if bot.enable_antiflood else _("выключен") |     antiflood_turn = _("включен") if bot.enable_antiflood else _("выключен") | ||||||
|  |     enable_always_second_message = _("включён") if bot.enable_always_second_message else _("выключен") | ||||||
|     text = dedent(_(""" |     text = dedent(_(""" | ||||||
|     <a href="https://olgram.readthedocs.io/ru/latest/options.html#threads">Потоки сообщений</a>: <b>{0}</b> |     <a href="https://olgram.readthedocs.io/ru/latest/options.html#threads">Потоки сообщений</a>: <b>{0}</b> | ||||||
|     <a href="https://olgram.readthedocs.io/ru/latest/options.html#user-info">Данные пользователя</a>: <b>{1}</b> |     <a href="https://olgram.readthedocs.io/ru/latest/options.html#user-info">Данные пользователя</a>: <b>{1}</b> | ||||||
|     <a href="https://olgram.readthedocs.io/ru/latest/options.html#antiflood">Антифлуд</a>: <b>{2}</b> |     <a href="https://olgram.readthedocs.io/ru/latest/options.html#antiflood">Антифлуд</a>: <b>{2}</b> | ||||||
|     """)).format(thread_turn, info_turn, antiflood_turn) |     <a href="https://olgram.readthedocs.io/ru/latest/options.html#always_second_message">Автоответчик всегда</a>: <b>{3} | ||||||
|  |     </b> | ||||||
|  |     """)).format(thread_turn, info_turn, antiflood_turn, enable_always_second_message) | ||||||
| 
 | 
 | ||||||
|     if is_promo: |     if is_promo: | ||||||
|         olgram_turn = _("включена") if bot.enable_olgram_text else _("выключена") |         olgram_turn = _("включена") if bot.enable_olgram_text else _("выключена") | ||||||
|  | @ -523,6 +532,9 @@ async def callback(call: types.CallbackQuery, callback_data: dict, state: FSMCon | ||||||
|         if operation == "additional_info": |         if operation == "additional_info": | ||||||
|             await bot_actions.additional_info(bot, call) |             await bot_actions.additional_info(bot, call) | ||||||
|             return await send_bot_settings_menu(bot, call) |             return await send_bot_settings_menu(bot, call) | ||||||
|  |         if operation == "always_second_message": | ||||||
|  |             await bot_actions.always_second_message(bot, call) | ||||||
|  |             return await send_bot_settings_menu(bot, call) | ||||||
|         if operation == "olgram_text": |         if operation == "olgram_text": | ||||||
|             await bot_actions.olgram_text(bot, call) |             await bot_actions.olgram_text(bot, call) | ||||||
|             return await send_bot_settings_menu(bot, call) |             return await send_bot_settings_menu(bot, call) | ||||||
|  |  | ||||||
							
								
								
									
										4
									
								
								olgram/migrations/models/18_20240217035146_update.sql
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										4
									
								
								olgram/migrations/models/18_20240217035146_update.sql
									
									
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,4 @@ | ||||||
|  | -- upgrade -- | ||||||
|  | ALTER TABLE "bot" ADD "enable_always_second_message" BOOL NOT NULL  DEFAULT False; | ||||||
|  | -- downgrade -- | ||||||
|  | ALTER TABLE "bot" DROP COLUMN "enable_always_second_message"; | ||||||
|  | @ -46,6 +46,7 @@ class Bot(Model): | ||||||
|     enable_additional_info = fields.BooleanField(default=False) |     enable_additional_info = fields.BooleanField(default=False) | ||||||
|     enable_olgram_text = fields.BooleanField(default=True) |     enable_olgram_text = fields.BooleanField(default=True) | ||||||
|     enable_antiflood = fields.BooleanField(default=False) |     enable_antiflood = fields.BooleanField(default=False) | ||||||
|  |     enable_always_second_message = fields.BooleanField(default=False) | ||||||
| 
 | 
 | ||||||
|     def decrypted_token(self): |     def decrypted_token(self): | ||||||
|         cryptor = DatabaseSettings.cryptor() |         cryptor = DatabaseSettings.cryptor() | ||||||
|  |  | ||||||
|  | @ -41,7 +41,7 @@ class OlgramSettings(AbstractSettings): | ||||||
| 
 | 
 | ||||||
|     @classmethod |     @classmethod | ||||||
|     def version(cls): |     def version(cls): | ||||||
|         return "0.6.1" |         return "0.7.0" | ||||||
| 
 | 
 | ||||||
|     @classmethod |     @classmethod | ||||||
|     @lru_cache |     @lru_cache | ||||||
|  |  | ||||||
|  | @ -160,7 +160,7 @@ async def handle_user_message(message: types.Message, super_chat_id: int, bot): | ||||||
|     if bot.second_text: |     if bot.second_text: | ||||||
|         send_auto = not await _redis.get(_last_message_uid(bot.pk, message.chat.id)) |         send_auto = not await _redis.get(_last_message_uid(bot.pk, message.chat.id)) | ||||||
|         await _redis.setex(_last_message_uid(bot.pk, message.chat.id), 60 * 60 * 3, 1) |         await _redis.setex(_last_message_uid(bot.pk, message.chat.id), 60 * 60 * 3, 1) | ||||||
|         if send_auto: |         if send_auto or bot.enable_always_second_message: | ||||||
|             text_obj = await BotSecondMessage.get_or_none(bot=bot, locale=str(message.from_user.locale)) |             text_obj = await BotSecondMessage.get_or_none(bot=bot, locale=str(message.from_user.locale)) | ||||||
|             return SendMessage(chat_id=message.chat.id, text=text_obj.text if text_obj else bot.second_text, |             return SendMessage(chat_id=message.chat.id, text=text_obj.text if text_obj else bot.second_text, | ||||||
|                                parse_mode="HTML") |                                parse_mode="HTML") | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue
	
	Block a user