feat: telegram voice transcription (#74)
This commit is contained in:
@@ -22,6 +22,7 @@ def test_parse_incoming_update_maps_fields() -> None:
|
||||
assert msg.reply_to_message_id == 5
|
||||
assert msg.reply_to_text == "prev"
|
||||
assert msg.sender_id == 99
|
||||
assert msg.voice is None
|
||||
assert msg.raw == update["message"]
|
||||
|
||||
|
||||
@@ -38,10 +39,36 @@ def test_parse_incoming_update_filters_non_matching_chat() -> None:
|
||||
assert parse_incoming_update(update, chat_id=999) is None
|
||||
|
||||
|
||||
def test_parse_incoming_update_filters_non_text() -> None:
|
||||
def test_parse_incoming_update_filters_non_text_and_non_voice() -> None:
|
||||
update = {
|
||||
"update_id": 1,
|
||||
"message": {"message_id": 10, "chat": {"id": 123}},
|
||||
"message": {"message_id": 10, "chat": {"id": 123}, "photo": []},
|
||||
}
|
||||
|
||||
assert parse_incoming_update(update, chat_id=123) is None
|
||||
|
||||
|
||||
def test_parse_incoming_update_voice_message() -> None:
|
||||
update = {
|
||||
"update_id": 1,
|
||||
"message": {
|
||||
"message_id": 10,
|
||||
"chat": {"id": 123},
|
||||
"voice": {
|
||||
"file_id": "voice-id",
|
||||
"file_unique_id": "uniq",
|
||||
"duration": 3,
|
||||
"mime_type": "audio/ogg",
|
||||
"file_size": 1234,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
msg = parse_incoming_update(update, chat_id=123)
|
||||
assert msg is not None
|
||||
assert msg.text == ""
|
||||
assert msg.voice is not None
|
||||
assert msg.voice.file_id == "voice-id"
|
||||
assert msg.voice.mime_type == "audio/ogg"
|
||||
assert msg.voice.file_size == 1234
|
||||
assert msg.voice.duration == 3
|
||||
|
||||
Reference in New Issue
Block a user