mirror of
https://github.com/paul-nameless/tg
synced 2024-11-22 20:03:17 +00:00
Fix black formatting
This commit is contained in:
parent
7a3a0b9106
commit
d688f3b066
3 changed files with 11 additions and 19 deletions
|
@ -46,26 +46,18 @@ class Controller:
|
|||
def send_file(self, send_file_fun, *args, **kwargs):
|
||||
file_path = self.view.status.get_input()
|
||||
if file_path and os.path.isfile(file_path):
|
||||
chat_id = self.model.chats.id_by_index(
|
||||
self.model.current_chat
|
||||
)
|
||||
chat_id = self.model.chats.id_by_index(self.model.current_chat)
|
||||
send_file_fun(file_path, chat_id, *args, **kwargs)
|
||||
|
||||
def send_voice(self):
|
||||
file_path = f"/tmp/voice-{datetime.now()}.oga"
|
||||
with suspend(self.view) as s:
|
||||
s.call(
|
||||
config.record_cmd.format(file_path=file_path)
|
||||
)
|
||||
s.call(config.record_cmd.format(file_path=file_path))
|
||||
resp = self.view.status.get_input(
|
||||
f"Do you want to send recording: {file_path}? [Y/n]"
|
||||
)
|
||||
if (
|
||||
is_yes(resp) and os.path.isfile(file_path)
|
||||
):
|
||||
chat_id = self.model.chats.id_by_index(
|
||||
self.model.current_chat
|
||||
)
|
||||
if is_yes(resp) and os.path.isfile(file_path):
|
||||
chat_id = self.model.chats.id_by_index(self.model.current_chat)
|
||||
duration = get_duration(file_path)
|
||||
waveform = get_waveform(file_path)
|
||||
self.tg.send_voice(file_path, chat_id, duration, waveform)
|
||||
|
@ -168,7 +160,9 @@ class Controller:
|
|||
)
|
||||
width, height = get_video_resolution(file_path)
|
||||
duration = get_duration(file_path)
|
||||
self.tg.send_video(file_path, chat_id, width, height, duration)
|
||||
self.tg.send_video(
|
||||
file_path, chat_id, width, height, duration
|
||||
)
|
||||
|
||||
elif keys == "v":
|
||||
self.send_voice()
|
||||
|
|
|
@ -101,10 +101,7 @@ class TelegramApi(Telegram):
|
|||
"@type": "inputMessageVoiceNote",
|
||||
"duration": duration,
|
||||
"waveform": waveform,
|
||||
"voice_note": {
|
||||
"@type": "inputFileLocal",
|
||||
"path": file_path
|
||||
},
|
||||
"voice_note": {"@type": "inputFileLocal", "path": file_path},
|
||||
},
|
||||
}
|
||||
return self._send_data(data)
|
||||
|
@ -112,7 +109,8 @@ class TelegramApi(Telegram):
|
|||
|
||||
def main():
|
||||
def signal_handler(sig, frame):
|
||||
log.info('You pressed Ctrl+C!')
|
||||
log.info("You pressed Ctrl+C!")
|
||||
|
||||
signal.signal(signal.SIGINT, signal_handler)
|
||||
|
||||
cfg = config.get_cfg()["DEFAULT"]
|
||||
|
|
|
@ -105,7 +105,7 @@ class StatusView:
|
|||
elif chr(key).isprintable():
|
||||
buff += chr(key)
|
||||
self.win.erase()
|
||||
line = (msg + buff)[-(self.w-1):]
|
||||
line = (msg + buff)[-(self.w - 1) :]
|
||||
self.win.addstr(0, 0, line)
|
||||
|
||||
self.win.clear()
|
||||
|
|
Loading…
Reference in a new issue