Module: Whatsapp::Concerns::MessageSending
- Included in:
- AccountProxy, Session
- Defined in:
- lib/whatsapp/concerns/message_sending.rb
Overview
Shared media/rich message helpers.
The includer must define +send_message+ with the standard signature (+to:, text:, media:, location:, contact:, react:, quoted_message_id:+).
Instance Method Summary collapse
-
#react(to:, message_id:, emoji:) ⇒ Message
React to a message with an emoji.
-
#reply(to:, quoted_message_id:, text: nil, media: nil) ⇒ Message
Reply to a message (quoted reply).
-
#send_audio(to:, file:) ⇒ Message
Send an audio file.
-
#send_contact(to:, name:, phone:) ⇒ Message
Send a contact card.
-
#send_document(to:, file:, filename: nil, caption: nil) ⇒ Message
Send a document.
-
#send_image(to:, file:, caption: nil) ⇒ Message
Send an image.
-
#send_location(to:, latitude:, longitude:, name: nil, address: nil) ⇒ Message
Send a location.
-
#send_poll(to:, question:, options:, selectable_count: 1) ⇒ Message
Send a poll (single or multi-choice).
-
#send_sticker(to:, file:) ⇒ Message
Send a sticker.
-
#send_video(to:, file:, caption: nil) ⇒ Message
Send a video.
Instance Method Details
#react(to:, message_id:, emoji:) ⇒ Message
React to a message with an emoji.
85 86 87 |
# File 'lib/whatsapp/concerns/message_sending.rb', line 85 def react(to:, message_id:, emoji:) (to: to, react: {emoji: emoji, message_id: }) end |
#reply(to:, quoted_message_id:, text: nil, media: nil) ⇒ Message
Reply to a message (quoted reply).
96 97 98 |
# File 'lib/whatsapp/concerns/message_sending.rb', line 96 def reply(to:, quoted_message_id:, text: nil, media: nil) (to: to, text: text, media: media, quoted_message_id: ) end |
#send_audio(to:, file:) ⇒ Message
Send an audio file.
44 45 46 |
# File 'lib/whatsapp/concerns/message_sending.rb', line 44 def send_audio(to:, file:) (to: to, media: {type: "audio", file: file}) end |
#send_contact(to:, name:, phone:) ⇒ Message
Send a contact card.
75 76 77 |
# File 'lib/whatsapp/concerns/message_sending.rb', line 75 def send_contact(to:, name:, phone:) (to: to, contact: {name: name, phone: phone}) end |
#send_document(to:, file:, filename: nil, caption: nil) ⇒ Message
Send a document.
25 26 27 |
# File 'lib/whatsapp/concerns/message_sending.rb', line 25 def send_document(to:, file:, filename: nil, caption: nil) (to: to, media: {type: "document", file: file, filename: filename, caption: caption}) end |
#send_image(to:, file:, caption: nil) ⇒ Message
Send an image.
14 15 16 |
# File 'lib/whatsapp/concerns/message_sending.rb', line 14 def send_image(to:, file:, caption: nil) (to: to, media: {type: "image", file: file, caption: caption}) end |
#send_location(to:, latitude:, longitude:, name: nil, address: nil) ⇒ Message
Send a location.
65 66 67 |
# File 'lib/whatsapp/concerns/message_sending.rb', line 65 def send_location(to:, latitude:, longitude:, name: nil, address: nil) (to: to, location: {latitude: latitude, longitude: longitude, name: name, address: address}) end |
#send_poll(to:, question:, options:, selectable_count: 1) ⇒ Message
Send a poll (single or multi-choice).
107 108 109 |
# File 'lib/whatsapp/concerns/message_sending.rb', line 107 def send_poll(to:, question:, options:, selectable_count: 1) (to: to, poll: {question: question, options: , selectable_count: selectable_count}) end |
#send_sticker(to:, file:) ⇒ Message
Send a sticker.
53 54 55 |
# File 'lib/whatsapp/concerns/message_sending.rb', line 53 def send_sticker(to:, file:) (to: to, media: {type: "sticker", file: file}) end |
#send_video(to:, file:, caption: nil) ⇒ Message
Send a video.
35 36 37 |
# File 'lib/whatsapp/concerns/message_sending.rb', line 35 def send_video(to:, file:, caption: nil) (to: to, media: {type: "video", file: file, caption: caption}) end |