MCPcopy Index your code
hub / github.com/AstrBotDevs/AstrBot / _process_quote_message

Function _process_quote_message

astrbot/core/astr_main_agent.py:800–898  ·  view source on GitHub ↗
(
    event: AstrMessageEvent,
    req: ProviderRequest,
    img_cap_prov_id: str,
    plugin_context: Context,
    quoted_message_settings: QuotedMessageParserSettings = DEFAULT_QUOTED_MESSAGE_SETTINGS,
    config: MainAgentBuildConfig | None = None,
    main_provider_supports_image: bool = False,
    skip_quote_image_caption: bool = False,
)

Source from the content-addressed store, hash-verified

798
799
800async def _process_quote_message(
801 event: AstrMessageEvent,
802 req: ProviderRequest,
803 img_cap_prov_id: str,
804 plugin_context: Context,
805 quoted_message_settings: QuotedMessageParserSettings = DEFAULT_QUOTED_MESSAGE_SETTINGS,
806 config: MainAgentBuildConfig | None = None,
807 main_provider_supports_image: bool = False,
808 skip_quote_image_caption: bool = False,
809) -> None:
810 quote = None
811 for comp in event.message_obj.message:
812 if isinstance(comp, Reply):
813 quote = comp
814 break
815 if not quote:
816 return
817
818 content_parts = []
819 sender_info = f"({quote.sender_nickname}): " if quote.sender_nickname else ""
820 message_str = (
821 await extract_quoted_message_text(
822 event,
823 quote,
824 settings=quoted_message_settings,
825 )
826 or quote.message_str
827 or "[Empty Text]"
828 )
829 content_parts.append(f"{sender_info}{message_str}")
830
831 image_seg = None
832 if quote.chain:
833 for comp in quote.chain:
834 if isinstance(comp, Image):
835 image_seg = comp
836 break
837
838 if image_seg:
839 if skip_quote_image_caption:
840 logger.debug(
841 "Skipping quote image captioning because image captioning already handled this request."
842 )
843 elif main_provider_supports_image:
844 logger.debug(
845 "Skipping quote image captioning because the main provider supports image input."
846 )
847 elif not img_cap_prov_id:
848 logger.debug(
849 "No dedicated image caption provider configured. "
850 "Skipping quote image captioning."
851 )
852 else:
853 try:
854 prov = None
855 path = None
856 compress_path = None
857 prov = plugin_context.get_provider_by_id(img_cap_prov_id)

Callers 1

_decorate_llm_requestFunction · 0.85

Calls 12

TextPartClass · 0.90
appendMethod · 0.45
get_provider_by_idMethod · 0.45
get_using_providerMethod · 0.45
convert_to_file_pathMethod · 0.45
text_chatMethod · 0.45
errorMethod · 0.45
removeMethod · 0.45

Tested by

no test coverage detected