B
    f’»d£
  ã               @   s`   d dl Z d dlZd dlmZ d dlmZ d dlmZ d dlmZmZ e  	e
¡ZG dd„ dƒZdS )é    N)Úraw)Útypes)ÚUserMigrate)ÚSessionÚAuthc               @   s   e Zd Zdeddœdd„ZdS )Ú	SignInBotzpyrogram.Clientz
types.User)ÚselfÚ	bot_tokenÚreturnc          
   Ã   s6  x.y*|   tjjjd| j| j|d¡I dH }W nÆ tk
rô } z¨| j 	¡ I dH  | j
 |j¡I dH  | j
 t| | j
 ¡ I dH | j
 ¡ I dH ƒ ¡ I dH ¡I dH  t| | j
 ¡ I dH | j
 ¡ I dH | j
 ¡ I dH ƒ| _| j ¡ I dH  W dd}~X Y qX | j
 |jj¡I dH  | j
 d¡I dH  tj | |j¡S qW dS )aª  Authorize a bot using its bot token generated by BotFather.

        .. include:: /_includes/usable-by/bots.rst

        Parameters:
            bot_token (``str``):
                The bot token generated by BotFather

        Returns:
            :obj:`~pyrogram.types.User`: On success, the bot identity is return in form of a user object.

        Raises:
            BadRequest: In case the bot token is invalid.
        r   )ÚflagsÚapi_idÚapi_hashZbot_auth_tokenNT)Zinvoker   Z	functionsÚauthZImportBotAuthorizationr   r   r   ÚsessionÚstopZstorageZdc_idÚvalueZauth_keyr   Z	test_modeÚcreater   ÚstartZuser_idÚuserÚidZis_botr   ZUserÚ_parse)r   r	   ÚrÚe© r   úE/tmp/pip-unpacked-wheel-rcokkf2l/pyrogram/methods/auth/sign_in_bot.pyÚsign_in_bot   s,    $""zSignInBot.sign_in_botN)Ú__name__Ú
__module__Ú__qualname__Ústrr   r   r   r   r   r      s   r   )ÚloggingZpyrogramr   r   Zpyrogram.errorsr   Zpyrogram.sessionr   r   Ú	getLoggerr   Úlogr   r   r   r   r   Ú<module>   s   
