def send_text_message(self, recipient_id, message): # type: (Text, Text) -> None """Send a message through this channel.""" print('sed text') logger.info("Sending message: " + message) self.send(recipient_id, elements.Text(text=message))
def send_quote_to_user(user_id, quote_text, quote_id): actions.mark_quote_as_seen(user_id, quote_id) quick_replies = QuickReplies([ QuickReply( content_type="text", title='Good one', payload=f"like {quote_id}", ), QuickReply( content_type="text", title='Not my taste', payload=f"dislike {quote_id}", ), ]) msg = elements.Text(text=quote_text, quick_replies=quick_replies) return messenger.send_msg(msg, user_id)
def test_text_with_quick_replies(self): qr = quick_replies.QuickReply(title='QR', payload='QR payload') qrs = quick_replies.QuickReplies(quick_replies=[qr] * 2) res = elements.Text(text='Test Message', quick_replies=qrs) expected = { 'text': 'Test Message', 'quick_replies': [{ 'content_type': 'text', 'title': 'QR', 'payload': 'QR payload' }, { 'content_type': 'text', 'title': 'QR', 'payload': 'QR payload' }] } assert expected == res.to_dict()
def test_text(self): res = elements.Text('Test Message') expected = {'text': 'Test Message'} assert expected == res.to_dict()