Module: Rubydium::Mixins::OtherActions
- Defined in:
- lib/rubydium/mixins/other_actions.rb
Instance Method Summary collapse
- #definitely_message(maybe_message) ⇒ Object
- #safe_delete(maybe_message, only_bot_or_owner: true) ⇒ Object
- #safe_delete_by_id(id, from_bot: false) ⇒ Object
Instance Method Details
#definitely_message(maybe_message) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/rubydium/mixins/other_actions.rb', line 23 def () return if .is_a? Telegram::Bot::Types::Message if ['message_id'] Telegram::Bot::Types::Message.new() elsif ['result']['message_id'] Telegram::Bot::Types::Message.new(['result']) end rescue StandardError nil end |
#safe_delete(maybe_message, only_bot_or_owner: true) ⇒ Object
6 7 8 9 10 11 12 13 |
# File 'lib/rubydium/mixins/other_actions.rb', line 6 def safe_delete(, only_bot_or_owner: true) = () from_owner = &.from&.username == config.owner_username from_bot = &.from&.id == config.bot_id return false unless only_bot_or_owner || from_bot || from_owner safe_delete_by_id(., from_bot: true) end |
#safe_delete_by_id(id, from_bot: false) ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/rubydium/mixins/other_actions.rb', line 15 def safe_delete_by_id(id, from_bot: false) return false unless || from_bot @api.(chat_id: @chat.id, message_id: id) rescue Telegram::Bot::Exceptions::ResponseError false end |