
    Chg                     J    d Z ddlmZ d Zd Zd ZddZddZdd	Zd
 Zd Z	y)z
    Bot functions to generate and post a comments.

    Instructions to file with comments:
        one line - one comment.

    Example:
        lol
        kek

    )tqdmc                    | j                  |      ry| j                  d      s| j                  d   r| j                  j	                  d       | j
                  rdddlm} | j                  j                          |d      z   j                  d      }| j                  j	                  d	j                  |             y
| j                  d       | j                  j                  ||      }|dk(  r| j                  j                  d       y
|r| j                   dxx   dz  cc<   yy
| j                  j#                  d       y
)NTcomments YOUR `COMMENT` ACTION IS BLOCKEDr   )	timedelta   )daysz%Y-%m-%d %H:%M:%SzPblocked_actions_protection ACTIVE. Skipping `comment` action till, at least, {}.Fcommentfeedback_required'`Comment` action has been BLOCKED...!!!Out of comments for today.)is_commentedreached_limitblocked_actionsloggerwarningblocked_actions_protectiondatetimer   
start_timedatestrftimeformatdelayapir
   errortotalinfo)selfmedia_idcomment_textr   
next_reset_rs         c/var/www/html/Telegram-Engagement-Pod-/env/lib/python3.12/site-packages/instabot/bot/bot_comment.pyr
   r
      s   "j)
+KK BC..."oo224ya7HHRR'
 ##HfZ(	 

9XXh5$$KKGHJJz"a'"  	56    c                    | j                  |      s| j                  j                  d       y| j                  d      s| j                  d   rC| j                  j                  d       | j                  r| j                  j                  d       y| j                  d       | j                  |      }|j                  d| j                  |            }|d   d	k7  rd
}| j                  j                  |       y|j                  d      d   dd  | j                  | j                        k(  r| j                  j                  d       y| j                  j                  |||      }|dk(  r| j                  j                  d       y|rC| j                  j                  dj!                  ||             | j"                  dxx   dz  cc<   yy| j                  j                  d       y)Nz3Media is not commented yet, nothing to answer to...Fr   r   z=blocked_actions_protection ACTIVE. Skipping `comment` action.r
   z[[username]]r   @ziA reply must start with mention, so '@' must be the 1st char, followed by the username you're replying to r   zYou can't reply to yourselfr   r   z!Replied to comment {} of media {}Tr   )r   r   r   r   r   r   r   r   get_media_ownerreplaceget_username_from_user_idr   splituser_idr   reply_to_commentr   r   )r   r   r    parent_comment_idmedia_ownermsgr"   s          r#   r-   r-   /   s   X&NOj)
+KK BC..##V 

9**84#++D::;G
 ?c!H  KKc"c"1%ab)T-K-KLL.
 
 KK;<XX&&x?PQ$$KKGHKK3::;LhW JJz"a'"  	56r$   c                    g }| j                   j                  dt        |      z         t        |      D ]  }| j	                  |      s| j                  |      r'| j                         }| j                   j                  d|z         | j                  ||      rh| j                  d       ||j                  |      d  } n | j                   j                  d| j                  d   z         |S )NzGoing to comment %d medias.zCommented with text: %sr
   z$DONE: Total commented on %d medias. r   )r   r   lenr   check_mediar   get_commentr
   r   indexr   )r   mediasbroken_itemsmediatexts        r#   comment_mediasr:   [   s    LKK2c&kBCf&  '##%DKK6=><<t,

9%%fll5&9&;<  	KK;djj>TTUr$   Nc                     | j                   j                  d|z         | j                  ||      }| j                  |      S )Nz%Going to comment medias by %s hashtag)r   r   get_total_hashtag_mediasr:   )r   hashtagamountr6   s       r#   comment_hashtagr?   l   s=    KK<wFG**7F;Fv&&r$   c                    | j                  |      sy| j                  j                  d|z         | j                  |      }| j	                  |d      }|s| j                  j                  d       y| j                  |d|       S )z  Comments last user_id's medias Fz Going to comment user_%s's feed:T)
is_commentzDNone medias received: account is closed ormedias have been filtered.N)
check_userr   r   convert_to_user_idget_user_mediasr:   )r   r,   r>   r6   s       r#   comment_userrE   r   s    ??7#KK7'AB%%g.G!!'d!;FU	
 vgv//r$   c                     |D ]C  }| j                  d      r| j                  j                  d        y | j                  ||       E y )Nr   r   )r>   )r   r   r   rE   )r   user_ids	ncommentsr,   s       r#   comment_usersrI      sC    j)KK9:')4	 r$   c                      y N )r   geotags     r#   comment_geotagrN      s    r$   c                 <    | j                   | j                  |      v S rK   )r,   get_media_commenters)r   r   s     r#   r   r      s    <<444X>>>r$   rK   )
__doc__r   r
   r-   r:   r?   rE   rI   rN   r   rL   r$   r#   <module>rR      s9   
 @)X"'05	
?r$   