Skip to content

Commit cb97e5e

Browse files
committed
add photo attachment to create issue from telegram
1 parent 638b5cd commit cb97e5e

File tree

3 files changed

+25
-1
lines changed

3 files changed

+25
-1
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# 0.5.5
2+
3+
* Add functionality for processing photos from telegram
4+
15
# 0.5.4
26

37
* Fix set bot permissions

lib/redmine_bots/telegram/bot.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@ def promote_chat_member(chat_id:, **params)
5656
handle_errors { throttle.apply(chat_id) { api.promote_chat_member(chat_id: chat_id, **params) } }
5757
end
5858

59+
def get_file(chat_id:, file_id:)
60+
handle_errors { throttle.apply(chat_id) { api.get_file(file_id: file_id) } }
61+
end
62+
5963
def set_webhook
6064
webhook_url = "https://#{Setting.host_name}/telegram/api/web_hook/#{webhook_secret}"
6165
api.set_webhook(url: webhook_url)

lib/redmine_bots/telegram/bot/user_action.rb

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,23 @@ def callback_query?
3939
end
4040

4141
def text
42-
message? ? message.text.to_s : ''
42+
if message? && !message.media_group_id
43+
if has_photo?
44+
message.caption.to_s
45+
else
46+
message.text.to_s
47+
end
48+
else
49+
''
50+
end
51+
end
52+
53+
def photo
54+
message.photo.max_by { |photo| photo.file_size }
55+
end
56+
57+
def has_photo?
58+
message.photo.present? && !message.media_group_id
4359
end
4460

4561
def command?

0 commit comments

Comments
 (0)