@@ -44,22 +44,24 @@ def log_resource(bot: Bot, update: Update):
4444 entities = update .effective_message .parse_entities ()
4545 caption_entities = update .effective_message .parse_caption_entities ()
4646 chat = update .effective_chat # type: Optional[Chat]
47- if chat .type == chat .SUPERGROUP :
48- log_chat = sql .get_chat_log_channel (chat .id )
49- if log_chat :
50- for descriptor , entity in entities .items ():
51- result = f'<b>Risorsa inviata da @{ update .effective_user .username } :</b>\n '
52- if descriptor ['type' ] in ['url' , 'text_link' ]:
53- result += f'{ entity } '
54- LOGGER .debug (f"Found message entity: { descriptor ['type' ]} { entity } " )
55- send_log (bot , log_chat , chat .id , result )
56-
57- for descriptor , entity in caption_entities .items ():
58- result = '<b>Risorsa inviata da @{update.effective_user.username}:</b>\n '
59- if descriptor ['type' ] in ['url' , 'text_link' ]:
60- result += f'{ entity } '
61- LOGGER .debug (f"Found message entity: { descriptor ['type' ]} { entity } " )
62- send_log (bot , log_chat , chat .id , result )
47+ log_chat = sql .get_chat_log_channel (chat .id )
48+ if log_chat :
49+ result = f'<b>Risorsa inviata da @{ update .effective_user .username } :</b>\n '
50+ for descriptor , entity in entities .items ():
51+ result = f'<b>Risorsa inviata da @{ update .effective_user .username } :</b>\n '
52+ if descriptor ['type' ] in ['url' , 'text_link' ]:
53+ result += f'{ entity } '
54+ LOGGER .debug (f"Found message entity: { descriptor ['type' ]} { entity } " )
55+ send_log (bot , log_chat , chat .id , result )
56+
57+ for descriptor , entity in caption_entities .items ():
58+ result = '<b>Risorsa inviata da @{update.effective_user.username}:</b>\n '
59+ if descriptor ['type' ] in ['url' , 'text_link' ]:
60+ result += f'{ entity } '
61+ LOGGER .debug (f"Found message entity: { descriptor ['type' ]} { entity } " )
62+ send_log (bot , log_chat , chat .id , result )
63+ else :
64+ send_log (bot , log_chat , chat .id , result )
6365
6466
6567 def send_log (bot : Bot , log_chat_id : str , orig_chat_id : str , result : str ):
@@ -182,7 +184,7 @@ def __chat_settings__(chat_id, user_id):
182184 SET_LOG_HANDLER = CommandHandler ("setlog" , setlog )
183185 UNSET_LOG_HANDLER = CommandHandler ("unsetlog" , unsetlog )
184186
185- LOG_RESOURCES_HANDLER = MessageHandler (Filters .all & Filters .group , log_resource )
187+ LOG_RESOURCES_HANDLER = MessageHandler (( Filters .entity ( "url" ) | Filters .entity ( "text_link" )) , log_resource )
186188
187189 dispatcher .add_handler (LOG_HANDLER )
188190 dispatcher .add_handler (SET_LOG_HANDLER )
0 commit comments