Skip to content

Commit

Permalink
Merge pull request #77 from southbridgeio/add-photo-attachment-to-cre…
Browse files Browse the repository at this point in the history
…ate-issue-from-telegram

add photo attachment to create issue from telegram
  • Loading branch information
nevrfl authored Oct 7, 2024
2 parents 638b5cd + cb97e5e commit bd7ff42
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# 0.5.5

* Add functionality for processing photos from telegram

# 0.5.4

* Fix set bot permissions
Expand Down
4 changes: 4 additions & 0 deletions lib/redmine_bots/telegram/bot.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ def promote_chat_member(chat_id:, **params)
handle_errors { throttle.apply(chat_id) { api.promote_chat_member(chat_id: chat_id, **params) } }
end

def get_file(chat_id:, file_id:)
handle_errors { throttle.apply(chat_id) { api.get_file(file_id: file_id) } }
end

def set_webhook
webhook_url = "https://#{Setting.host_name}/telegram/api/web_hook/#{webhook_secret}"
api.set_webhook(url: webhook_url)
Expand Down
18 changes: 17 additions & 1 deletion lib/redmine_bots/telegram/bot/user_action.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,23 @@ def callback_query?
end

def text
message? ? message.text.to_s : ''
if message? && !message.media_group_id
if has_photo?
message.caption.to_s
else
message.text.to_s
end
else
''
end
end

def photo
message.photo.max_by { |photo| photo.file_size }
end

def has_photo?
message.photo.present? && !message.media_group_id
end

def command?
Expand Down

0 comments on commit bd7ff42

Please sign in to comment.