
    hj                         S r SSKrSSKrSSKJr  SSKrSSKrSSKJrJrJ	r	J
r
  SS jrS\S\S	\4S
 jrS r\
" SS9S 5       r\
" SS9S 5       rg)u   
**Get Weather Data using OpenWeatherMap API**
❍  Commands Available -

• `{i}weather` <city name>
    Shows the Weather of Cities

• `{i}air` <city name>
    Shows the Air Condition of Cities
    N)	timedelta   )async_searcher
get_stringudBultroid_cmdc                 n  #    [        U S9n[        UR                  S5      u  p4UR                  5       S:  a  SOSnU(       a  SOSnU(       ap  [        R
                   H[  n[        R                  " U5      n[        R                  R                  U5      n	U	R                  5       U:X  d  MN  U SU U US	 S
3s  $    g [        R
                   Hs  n[        R                  " U5      nUR                  S5      (       d  M1  [        R                  R                  U5      n	U	R                  5       U:X  d  Mf  U SU U US	 S
3s  $    [        R
                   H[  n[        R                  " U5      n[        R                  R                  U5      n	U	R                  5       U:X  d  MN  U SU U US	 S
3s  $    g7f)N)secondsi  r   +-UTCGMTz (02d)z
Australia/zTimezone not found)r   divmodr
   total_secondspytzall_timezonestimezonedatetimenow	utcoffset
startswith)
offset_secondsuse_utcoffsethours	remaindersignr   mtzr   s
             $/root/TeamUltroid/plugins/weather.pyget_timezoner#      sz    ~.Ffnnd3E&&(A-33DuUH##Aq!B##''+C}}&(BxjuSk;;	 $ ##Aq!B||L))''++B/==?f,S8*TF5+Q?? $ ##Aq!B##''+C}}&(BxjuSk;;	 $
 $s    B&F5,AF5?1F54A+F5#F5speeddegreereturnc                    #    / SQn[        US[        U5      -  -  5      n[        [        U 5      S-  5      S-   nSX#[        U5      -      SU 3$ 7f)N)NNEESESSWWNWg     v@g@z km/h[z] )roundlenstrfloat)r$   r%   dirsixkmphs        r"   getWindinfor8   6   sY     7D	v#d)+,	-BuU|c!"W,DtTN#$Btf--s   AAc                   #    SU  SU SU 3n[         R                  " 5        IS h  vN nUR                  U5       IS h  vN nUR                  5       I S h  vN nSU;   a,  US   S   nUsS S S 5      IS h  vN   sS S S 5      IS h  vN   $  S S S 5      IS h  vN   S S S 5      IS h  vN   g  N Nr N\ N> N/ N N! , IS h  vN  (       d  f       O= fS S S 5      IS h  vN    g ! , IS h  vN  (       d  f       g = f7f)Nz9http://api.openweathermap.org/data/2.5/air_pollution?lat=z&lon=z&appid=listr   )aiohttpClientSessiongetjson)latitude	longitudeapi_keyurlsessionresponsedataair_pollutions           r"   get_air_pollution_datarG   <   s     EhZuU^T__fgnfo
pC$$&&';;s##x!(D~ $VQ$	 $## '&&  $# '&&#( $ '# '### '&&&&&s   %DB2DC,B4C,C B6C -C,9B8:C,>D
B:DC C,B<C,!D,B>-D4C,6C 8C,:D<C,>D C	C	C	C,D%C(&D,D2C53D?Dzweather ?(.*))patternc                  6  #    U R                   (       a  g U R                  [        S5      5      I S h  vN n[        R                  " S5      nUc  U R                  SSS9I S h  vN   g U R
                  R                  S5      nU(       d  U R                  SSS9I S h  vN   g US	:X  a  U R                  S
SS9I S h  vN   SU SU S3n [        USS9I S h  vN nUS   S:X  Ga@  [        US   5      n[        U5      I S h  vN  n[        US   S   5      U-   n[        US   S   5      U-   n	UR                  US    SUS   S    SUS   S   S    SU S[        R                  " S[        R                  " U5      5       S [        R                  " S[        R                  " U	5      5       S![        US"   S#   US"   S$   5      I S h  vN  S%US&   S'    S(US&   S)    S*US&   S+    S,US&   S-    S.US&   S/    S0US&   S1    S2US3    S4US5   S6    S735      I S h  vN   g UR                  US8   5      I S h  vN   g  GN GN GN GN GNx GNP N N6 N! [         a/  n
U R                  S9[!        U
5       3SS9I S h  vN     S n
A
g S n
A
ff = f7f):Ncom_1OPENWEATHER_APIiNo API found. Get One from [Here](https://api.openweathermap.org)
And Add it in OPENWEATHER_API Redis Key   timer   zNo Location was Given...   butlerzsearch butler,au for australilaz2https://api.openweathermap.org/data/2.5/weather?q=z&APPID=z&units=metricTre_jsoncod   r   syssunrisesunsetname, countryub   

╭────────────────•
╰➢ **𝖶𝖾𝖺𝗍𝗁𝖾𝗋:** weatherr   descriptionu.   
╰➢ **𝖳𝗂𝗆𝖾𝗓𝗈𝗇𝖾:** u*   
╰➢ **𝖲𝗎𝗇𝗋𝗂𝗌𝖾:** z%Y-%m-%d %H:%M:%Su&   
╰➢ **𝖲𝗎𝗇𝗌𝖾𝗍:** u   
╰➢ **𝖶𝗂𝗇𝖽:** windr$   degu:   
╰➢ **𝖳𝖾𝗆𝗉𝖾𝗋𝖺𝗍𝗎𝗋𝖾:** maintempu6   °C
╰➢ **𝖥𝖾𝖾𝗅𝗌 𝗅𝗂𝗄𝖾:** 
feels_likeu-   °C
╰➢ **𝖬𝗂𝗇𝗂𝗆𝗎𝗆:** temp_minu-   °C
╰➢ **𝖬𝖺𝗑𝗂𝗆𝗎𝗆:** temp_maxu1   °C
╰➢ **𝖯𝗋𝖾𝗌𝗌𝗎𝗋𝖾:** pressureu2    hPa
╰➢ **𝖧𝗎𝗆𝗂𝖽𝗂𝗍𝗒:** humidityu7   %
╰➢ **𝖵𝗂𝗌𝗂𝖻𝗂𝗅𝗂𝗍𝗒:** 
visibilityu(    m
╰➢ **𝖢𝗅𝗈𝗎𝖽𝗌:** cloudsallu:   %
╰────────────────•

messagezAn unexpected error occurred: )fwd_fromeorr   r   get_keypattern_matchgroupr   intr#   editrO   strftimegmtimer8   	Exceptionr3   )eventmsgx	input_str
sample_urlresponse_apicountry_time_zoner!   sun_rise_timesun_set_timees              r"   r\   r\   H   sV    ~~		*W-.
.C%&Ayiix  
 	
 	
 	##))!,Iii2i;;;	h	ii9iBBBEi[PWXYWZZghJK+JEE#% #L$< =&'899:BU 3I >?BSSM|E28<=@QQL(('(<+>y+I*J K<<H<STU<VWd<e;f g@@Bt D<<@MMJ]_c_j_jkx_y<z;{ |88<FY[_[f[fgs[t8u7v w06A,vBVW^B_amntauv{a|6}0}/~ LLXY_L`agLhKi jEEQRXEYZfEgDh i<<H<PQ[<\;] ^<<H<PQ[<\;] ^@@LV@TU_@`?a b@@LV@TU_@`?a bHHTUaHbGc d88DX8Nu8U7V WMN  & ((<	2333S /	
 	< 	C F : 1~& 4 Kii8QAiJJJKs   0JI0J#I$:JIJ=I>JI I*I IC	I I AI "I#I 'J(I ?I I JJJJI I I I I 
J'JJ	JJJJz	air ?(.*)c                 \  #    U R                   (       a  g U R                  [        S5      5      I S h  vN n[        R                  " S5      nUc  U R                  SSS9I S h  vN   g U R
                  R                  S5      nU(       d  U R                  SSS9I S h  vN   g UR                  5       S	:X  a  S
nOSU S3n[        USS9I S h  vN n US   nUS   n US   S   n	US   S   n
[        XvU5      I S h  vN nUc  U R                  SSS9I S h  vN   g UR                  U	 SU
 SUS   S    SUS   S    SUS   S    S US   S!    S"US   S#    S$US   S%    S&US   S'    S(US   S)    S*US   S+    S,35      I S h  vN   g  GN^ GN0 N N! [         a8  n[        R                  U5        U R                  SSS9I S h  vN     S nAg S nAff = f! [         a8  n[        R                  U5        U R                  SSS9I S h  vN     S nAg S nAff = f GN& GN N7f)-NrJ   rK   rL   rM   rN   r   z`No Location was Given...`rP   perthz%https://geocode.xyz/perth%20au?json=1zhttps://geocode.xyz/z?json=1TrR   longtlattz4`Unable to find coordinates for the given location.`standardcityprovz0`Unable to find city for the given coordinates.`z<`Unable to fetch air pollution data for the given location.`rZ   uR   

╭────────────────•
╰➢ **𝖠𝖰𝖨:** r`   aqiuG   
╰➢ **𝖢𝖺𝗋𝖻𝗈𝗇 𝖬𝗈𝗇𝗈𝗑𝗂𝖽𝖾:** 
componentscouZ   µg/m³
╰➢ **𝖭𝗈𝗂𝗍𝗋𝗈𝗀𝖾𝗇 𝖬𝗈𝗇𝗈𝗑𝗂𝖽𝖾:** nouR   µg/m³
╰➢ **𝖭𝗂𝗍𝗋𝗈𝗀𝖾𝗇 𝖣𝗂𝗈𝗑𝗂𝖽𝖾:** no2u)   µg/m³
╰➢ **𝖮𝗓𝗈𝗇𝖾:** o3uN   µg/m³
╰➢ **𝖲𝗎𝗅𝗉𝗁𝗎𝗋 𝖣𝗂𝗈𝗑𝗂𝖽𝖾:** so2u1   µg/m³
╰➢ **𝖠𝗆𝗆𝗈𝗇𝗂𝖺:** nh3uV   µg/m³
╰➢ **𝖥𝗂𝗇𝖾 𝖯𝖺𝗋𝗍𝗂𝖼𝗅𝖾𝗌 (PM₂.₅):** pm2_5uV   
╰➢ **𝖢𝗈𝖺𝗋𝗌𝖾 𝖯𝖺𝗋𝗍𝗂𝖼𝗅𝖾𝗌 (PM₁₀):** pm10u9   
╰────────────────•

)rk   rl   r   r   rm   rn   ro   lowerr   KeyErrorLOGSinforG   rq   )ru   rv   rw   rx   geo_urlgeo_datar@   r?   r~   r   r   air_pollution_datas               r"   rF   rF   z   s    ~~		*W-.
.C%&Ayiix  
 	
 	
 	##))!,Iii41i===G#9(7;#GT::HW%	F#

#F+
#F+
  6h1MM!iiJQR  
 	
 	
 	
((&4& $$6v$>u$E#F GQQcdpQqrvQwPx y]]op|]}  C  ^D  ]E EUUghtUuv{U|T} ~,,>|,LT,R+S TQQcdpQqrwQxPy z44F|4TUZ4[3\ ]YYklxYy  {B  ZC  YD D``rs  aA  BH  aI  `J JE	F  K /	
 	> ;  		!iiNUViWWW  		!iiJQRiSSS N	
s   0H,F0H,#F$:H,F/H,FH,
F G /H,>H$?H,H'A0H,
H*H,H,H,H,
G$(GGGH,GH,
H!)(HHHH,H!!H,'H,*H,)F)__doc__r   rO   r   r;   r    r   r   r   r   r#   r3   r8   rG   r\   rF        r"   <module>r      sz   	      : :$2.S .# .# .	 _%.K &.Kb [!5 "5r   