
    Ch                     l    d dl Z d dlmZ d dlmZ ddZd ZddZd ZddZdd	Z	dd
Z
ddZd Zd Zy)    N)
guess_type)tqdmc                    t        | |      }t        |t              s2t        |t        t        f      r| j                  j                  d       y| j                  d      r| j                  j                  d       y| j                  d       | j                  |      }|rdnd}| j                  j                  |||||      r| j                  dxx   d	z  cc<   y
| j                  j                  dj                  |             y)z
    :param self: bot
    :param text: text of message
    :param user_ids: list of user_ids for creating group or
    one user_id for send to one person
    :param thread_id: thread_id
    :Text must be an string, user_ids must be an list or stringFmessagesOut of messages for today.messagelinktext)r   threadurls   T!Message to {user_ids} wasn't sentuser_ids)_get_user_ids
isinstancestrlistloggererrorreached_limitinfodelayextract_urlsapisend_direct_itemtotalformat)selfr   r   	thread_idr   	item_types         b/var/www/html/Telegram-Engagement-Pod-/env/lib/python3.12/site-packages/instabot/bot/bot_direct.pysend_messager$      s     T8,HdC Z4+%FVW*%56JJyT"DFIxx  8$yt !  	

:!#KK8???RS    c                 (   g }|s| j                   j                  d       |S | j                   j                  dt        |      z         t        |      D ];  }| j	                  ||      r| j                          ||j                  |      d  } |S  |S NzUser must be at least one.zGoing to send %d messages.)r   r   lenr   r$   error_delayindex)r    r   r   broken_itemsusers        r#   send_messagesr-   %   s    L56KK1S]CDX  t,#HNN4$8$:;L 
 r%   c           
      p   t        | |      }t        |t              s2t        |t        t        f      s| j                  j                  d       y| j                  d      r| j                  j                  d       y| j                  |      }t        |t              r|d   n|}| j                  d       | j                  j                  d||||j                  d      |j                  d	      
      r| j                  dxx   dz  cc<   y| j                  j                  dj                  |             y)z
    :param media_id:
    :param self: bot
    :param text: text of message
    :param user_ids: list of user_ids for creating group or one user_id
    for send to one person
    :param thread_id: thread_id
    r   Fr   r   r   r	   media_share
media_typeid)r   r   r0   media_idr   Tr   r   )r   r   r   r   r   r   r   r   get_media_infor   r   r   getr   r   )r    r2   r   r   r!   medias         r#   
send_mediar6   3   s    T8,HdC HtSk)JVW*%56)E"5$/E!HUEJJyxx  99\*4 !  	

:!#KK8???RSr%   c                 *   g }|s| j                   j                  d       |S | j                   j                  dt        |      z         t        |      D ]<  }| j	                  |||      r| j                          ||j                  |      d  } |S  |S r'   )r   r   r(   r   r6   r)   r*   )r    r2   r   r   r+   r,   s         r#   send_mediasr8   W   s    L56KK1S]CDXxt4#HNN4$8$:;L 
 r%   c                    t        | |      }t        |t              s2t        |t        t        f      s| j                  j                  d       y| j                  d      r| j                  j                  d       y| j                  d       | j                  j                  d||||      r| j                  dxx   dz  cc<   y	| j                  j                  d
j                  |             y)z
    :param hashtag: hashtag
    :param self: bot
    :param text: text of message
    :param user_ids: list of user_ids for creating group or one
    user_id for send to one person
    :param thread_id: thread_id
    r   Fr   r   r	   hashtag)r   r   r:   r   Tr   r   )r   r   r   r   r   r   r   r   r   r   r   r   r   )r    r:   r   r   r!   s        r#   send_hashtagr;   e   s     T8,HdC HtSk)JVW*%56JJyxx  8$y' !  	

:!#KK8???RSr%   c                    | j                  |      }t        | |      }t        |t              s2t        |t        t        f      s| j
                  j                  d       y| j                  d      r| j
                  j                  d       y| j                  d       | j                  j                  d||||      r| j                  dxx   dz  cc<   y	| j
                  j                  d
j                  |             y)z
    :param profile_user_id: profile_id
    :param self: bot
    :param text: text of message
    :param user_ids: list of user_ids for creating group or
    one user_id for send to one person
    :param thread_id: thread_id
    r   Fr   r   r	   profile)r   r   profile_user_idr   Tr   r   )convert_to_user_idr   r   r   r   r   r   r   r   r   r   r   r   r   )r    r>   r   r   r!   
profile_ids         r#   send_profilerA      s     ((9JT8,HdC HtSk)JVW*%56JJyxx  8$y* !  	

:!#KK8???RSr%   c                    t        | |      }t        |t        t        f      s| j                  j                  d       y| j                  d      r| j                  j                  d       y| j                  d       | j                  j                  d||      r| j                  dxx   dz  cc<   y	| j                  j                  d
j                  |             y)z
    :param self: bot
    :param user_ids: list of user_ids for creating group or
    one user_id for send to one person
    :param thread_id: thread_id
    r   Fr   r   r	   like)r   r   Tr   r   )r   r   r   r   r   r   r   r   r   r   r   r   r   )r    r   r!   s      r#   	send_likerD      s     T8,Hhs,VW*%56JJyxx  ) D

:!#KK8???RSr%   c                 x   t        | |      }t        |t        t        f      s| j                  j                  d       y| j                  d      r| j                  j                  d       yt        j                  j                  |      s| j                  j                  d|       yt        |      }|d   dk7  r| j                  j                  d       y| j                  d	       | j                  j                  d
|||      s| j                  j                  d|       y| j                  dxx   dz  cc<   y)z
    :param self: bot
    :param filepath: file path to send
    :param user_ids: list of user_ids for creating group or
    one user_id for send to one person
    :param thread_id: thread_id
    z!user_ids must be a list or stringFr   r   zFile %s is not foundr   z
image/jpegzOnly jpeg files are supportedr	   photo)filepathr   zMessage to %s wasn't sentr   T)r   r   r   r   r   r   r   r   ospathexistsr   r   r   r   r   )r    r   rG   r!   	mime_types        r#   
send_photorL      s	    T8,Hhs,=>*%5677>>(#0(;8$I||#9:JJy88$$HY %  	4h?JJzar%   c                     t        |t              r| j                  |      }|gS |D cg c]  }| j                  |       c}S c c}w N)r   r   r?   )r    r   r,   s      r#   r   r      sG    (C **84z6>?hdD##D)h???s   Ac                 h   | j                         }|r|D ]  }|d   }| j                  j                  |       | j                  j                  j                  dk(  r+| j
                  j                  dj                  |             q| j
                  j                  dj                  |              y y )Nr!      zApproved thread: {}zCould not approve thread {})	get_pending_thread_requestsr   approve_pending_threadlast_responsestatus_coder   r   r   r   )r    pendingr   r!   s       r#   approve_pending_thread_requestsrV      s    ..0GF{+IHH++I6xx%%11S8  !6!=!=i!HI!!"?"F"Fy"QR  r%   rN   ) N)rH   	mimetypesr   r   r$   r-   r6   r8   r;   rA   rD   rL   r   rV    r%   r#   <module>rZ      sD    	   <!H::0"J@	Sr%   