@@ -572,3 +572,52 @@ def revoke_users_token(self, user_ids, before):
572572 {"id" : user_id , "set" : {"revoke_tokens_issued_before" : before }}
573573 )
574574 self .update_users_partial (updates )
575+
576+ def export_channel (self , channel_id : str , channel_type : str , messages_since : str = None ,
577+ messages_until = None ):
578+ """
579+ Requests a channel export
580+ :param channel_id: channel_id of channel which needs to be exported
581+ :param channel_type: channel_type of channel which needs to be exported
582+ :param messages_since: RFC-3339 string or datetime to filter messages since that time, optional
583+ :param messages_until: RFC-3339 string or datetime to filter messages until that time, optional
584+ :type channel_id: str
585+ :type channel_type: str
586+ :type messages_since: Union[str, datetime.datetime]
587+ :type messages_until: Union[str, datetime.datetime]
588+ """
589+ if isinstance (messages_since , datetime .datetime ):
590+ messages_since = messages_since .isoformat ()
591+ if isinstance (messages_until , datetime .datetime ):
592+ messages_until = messages_until .isoformat ()
593+
594+ return self .export_channels (
595+ [
596+ {
597+ "id" : channel_id ,
598+ "type" : channel_type ,
599+ "messages_since" : messages_since ,
600+ "messages_until" : messages_until
601+ }
602+ ]
603+ )
604+
605+ def export_channels (self , channels_data : list ):
606+ """
607+ Requests a channels export
608+ :param channels_data: list of channel's data which need to be exported with keys:
609+ - `channel_id`: str
610+ - `channel_type`: str
611+ - `messages_since` (optional, nullable): str
612+ - `messages_until` (optional, nullable): str
613+ :type channels_data: List[Dict[str, str]]
614+ """
615+ return self .post ("export_channels" , data = {"channels" : channels_data })
616+
617+ def get_export_channel_status (self , task_id : str ):
618+ """
619+ Retrieves status of export
620+ :param task_id: task_id of task which status needs to be retrieved
621+ :type task_id: str
622+ """
623+ return self .get (f"export_channels/{ task_id } " )
0 commit comments