Skip to content

Commit

Permalink
fix(telegram): add parse_mode to all media types
Browse files Browse the repository at this point in the history
  • Loading branch information
Massolari committed Jan 17, 2024
1 parent d245b45 commit be9c18c
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/telegram.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,18 @@ fn caption_json_field(post: reddit.Post, chat_id: String) {
#("caption", json.string(media_caption(post, chat_id)))
}

fn parse_mode_json_field() {
#("parse_mode", json.string("Markdown"))
}

fn chat_id_json_field(id: String) {
#("chat_id", json.string(id))
}

fn photo_encode(url: String, post: reddit.Post, chat_id: String) {
json.object([
#("photo", json.string(url)),
parse_mode_json_field(),
caption_json_field(post, chat_id),
chat_id_json_field(chat_id),
])
Expand All @@ -99,6 +104,7 @@ fn photo_encode(url: String, post: reddit.Post, chat_id: String) {
fn animation_encode(url: String, post: reddit.Post, chat_id: String) {
json.object([
#("animation", json.string(url)),
parse_mode_json_field(),
caption_json_field(post, chat_id),
chat_id_json_field(chat_id),
])
Expand All @@ -107,6 +113,7 @@ fn animation_encode(url: String, post: reddit.Post, chat_id: String) {
fn video_encode(url: String, post: reddit.Post, chat_id: String) {
json.object([
#("video", json.string(url)),
parse_mode_json_field(),
caption_json_field(post, chat_id),
chat_id_json_field(chat_id),
])
Expand All @@ -129,7 +136,7 @@ fn text_encode(post: reddit.Post, chat_id: String) {
<> chat_id_as_link(chat_id),
),
),
#("parse_mode", json.string("Markdown")),
parse_mode_json_field(),
chat_id_json_field(chat_id),
])
}

0 comments on commit be9c18c

Please sign in to comment.