Beispiel #1
0
    def record_voice(self):
        file_path = f"/tmp/voice-{datetime.now()}.oga"
        with suspend(self.view) as s:
            s.call(
                config.VOICE_RECORD_CMD.format(
                    file_path=shlex.quote(file_path)
                )
            )
        resp = self.view.status.get_input(
            f"Do you want to send recording: {file_path}? [Y/n]"
        )
        if not is_yes(resp):
            self.present_info("Voice message discarded")
            return

        if not os.path.isfile(file_path):
            self.present_info(f"Can't load recording file {file_path}")
            return

        chat_id = self.model.chats.id_by_index(self.model.current_chat)
        if not chat_id:
            return
        duration = get_duration(file_path)
        waveform = get_waveform(file_path)
        self.tg.send_voice(file_path, chat_id, duration, waveform)
        self.present_info(f"Sent voice msg: {file_path}")
Beispiel #2
0
 def send_video(self):
     file_path = self.view.status.get_input()
     if not file_path or not os.path.isfile(file_path):
         return
     chat_id = self.model.chats.id_by_index(self.model.current_chat)
     if not chat_id:
         return
     width, height = get_video_resolution(file_path)
     duration = get_duration(file_path)
     self.tg.send_video(file_path, chat_id, width, height, duration)
Beispiel #3
0
 def _send_video(self, file_path: str, chat_id: int) -> None:
     width, height = get_video_resolution(file_path)
     duration = get_duration(file_path)
     self.tg.send_video(file_path, chat_id, width, height, duration)