
    Zhk                     $   d dl Z d dlmZ d dlZd dlmZ d dlmZ d dlZd dl	m
Z
  e              e ej        d                    Ze ej        d                   Ze ej        d                   Ze ej        d	                   Zd
 Zd ZdS )    N)MongoClient)scrape)load_dotenv)amazon_url_patterns	MONGO_URIDATABASE
COLLECTIONPRODUCTSc                   K   t          d           t                                          D ]}|d         t          fdt          D                       rdnd}t          |           d {V \  }}t          j        d           |d||d         k    rXt                              d|d         id	||d         ||d
         k     r|n|d
         ||d         k    r|n|d         di           t          d           t                       d {V }|D ]}t                              d|i          }t          |          }|D ]}	t                              d|	                    d          i          }|d         |d         z
  |d         z  dz  }
d|d          d|d         dd|d         dd|
dd|d          d}|                     |	                    d          |d           d {V  d S )NzChecking Price for Products...urlc              3   B   K   | ]}t          j        |          V  d S )N)rematch).0patternr   s     +F:\Savad\Price\PriceTrackerBot\scheduler.py	<genexpr>zcheck_prices.<locals>.<genexpr>   s/      "]"]g28GS#9#9"]"]"]"]"]"]    amazonflipkart   price_idz$setlowerupper)r   previous_pricer   r   	Completed
product_idr   d   u   🎉 Good news! The price of product_nameu&    has changed.
   - Previous Price: ₹z.2fu   
   - Current Price: ₹z
   - Percentage Change: z%
   - [Check it out here]()user_idT)chat_idtextdisable_web_page_preview)printr
   findanyr   r   timesleep
update_onecompare_prices
collectionlistfind_onegetsend_message)appproductplatform_current_pricechanged_productschanged_productcursorusersuserpercentage_changer$   r   s               @r   check_pricesr=      s     	
*+++==??  en""]"]"]"]I\"]"]"]]]m88cm!'X!6!6666666=
1$ 000##GEN+%2.5g.>,ww/??? &3]!(!1,ww/??? &3]!(!1	! 	!   
++--------+  ,!@AAV 	 	D''0F0F(GHHG!G,<$==*+,!
>0G > >+23C+DL> >*1'*:B> > ,=E> > -4EN	> > >  ""++$QU #          	 r   c                    K   t          d           g } t                                          D ]Z}|                    d          }|                    d          }||k    r(|                     |                    d                     [| S )NzComparing Prices...r   r   r   )r&   r
   r'   r0   append)product_with_changesr3   r6   r   s       r   r,   r,   B   s      	
   ==?? < <G,, %566N** ''E(:(:;;;r   )r)   pymongor   osscraperr   dotenvr   r   regex_patternsr   getenvdbclientdatabaser-   r
   r=   r,    r   r   <module>rJ      s           				             				 . . . . . .  ;yry--..IBIj))*ibi--.
IBIj))*- - -`	  	  	  	  	 r   