
    ChG                         d Z ddlZddlZddlmZ ej                  j                   ej                               Zedz   Z G d de	      Z
d Zd Zy)	z"
    Instabot Checkpoint methods.
    N)datetimez/config/{fname}.checkpointc                   (    e Zd ZdZd Zd Zd Zd Zy)
Checkpointa,  
        Checkpoint for instabot.Bot class which can store:
            .total[<name>] - all Bot's counters
            .blocked_actions[<name>] - Bot's blocked actions
            .following (list of user_ids)
            .followers (list of user_ids)
            .date (of checkpoint creation)
    c                 ^   i | _         |j                   D ]  }|j                   |   | j                   |<     i | _        |j                  D ]  }|j                  |   | j                  |<     |j                  | _        t        j                         | _        |j                  j                  | _        y N)totalblocked_actions
start_timer   nowdateapitotal_requests)selfbotks      f/var/www/html/Telegram-Engagement-Pod-/env/lib/python3.12/site-packages/instabot/bot/bot_checkpoint.py__init__zCheckpoint.__init__   s    
AIIaLDJJqM !$$A&)&9&9!&<D  # %..LLN	!gg44    c                 n    |j                   j                         D cg c]  }|d   	 c}| _        y c c}w Npk)r   get_total_self_followings
_followingr   r   items      r   fill_followingzCheckpoint.fill_following#   s.    25''2S2S2UV2U$4:2UVV   2c                 n    |j                   j                         D cg c]  }|d   	 c}| _        y c c}w r   )r   get_total_self_followers
_followersr   s      r   fill_followerszCheckpoint.fill_followers&   s.    25''2R2R2TU2T$4:2TUUr   c                 ^    | j                   | j                  | j                  | j                  fS r   )r   r	   r   r
   )r   s    r   dumpzCheckpoint.dump)   s%    

D00$2E2EtWWr   N)__name__
__module____qualname____doc__r   r   r!   r#    r   r   r   r      s    	5WVXr   r   c                    t        |       }t        j                  | j                  j                        }t
        j                  j                  | j                  |      }| j                  j                  dj                  |             t        |d      5 }t        j                  ||d       d d d        y# 1 sw Y   yxY w)NfnamezSaving Checkpoint file to: {}wbT)r   CHECKPOINT_PATHformatr   usernameospathjoin	base_pathloggerdebugopenpickler#   )r   
checkpointr+   fs       r   save_checkpointr;   -   s    D!J""):):";EGGLL/EKK5<<UCD	eT	aJ2& 
 
s   B77C c                    	 t         j                  | j                  j                        }t        j
                  j                  | j                  |      }| j                  j                  dj                  |             t        |d      5 }t        j                  |      }d d d        t        t              r|j                         S t	        j                   |       	 y # 1 sw Y   @xY w# t"        $ r Y y w xY w)Nr*   z Loading Checkpoint file from: {}rb)r.   r/   r   r0   r1   r2   r3   r4   r5   r6   r7   r8   load
isinstancer   r#   remove	Exception)r   r+   r:   r9   s       r   load_checkpointrB   7   s    &&TXX->->&?T^^U3<CCEJK%!QJ j*-??$$IIe    s0   B
C- C!"'C- 
C- !C*&C- -	C98C9)r'   r1   r8   r   r2   abspathgetcwdcurrent_pathr.   objectr   r;   rB   r(   r   r   <module>rG      sS    
  wwyryy{+!==X X@r   