Message reply and card support#56
Open
philipsd6 wants to merge 4 commits intoRidersDiscountCom:masterfrom
Open
Message reply and card support#56philipsd6 wants to merge 4 commits intoRidersDiscountCom:masterfrom
philipsd6 wants to merge 4 commits intoRidersDiscountCom:masterfrom
Conversation
- message id is required for /reply
|
nice |
hanks
reviewed
Dec 17, 2016
hypchat/restobject.py
Outdated
| else: | ||
| format = 'html' | ||
| data = {'message': message, 'notify': notify, 'message_format': format} | ||
| data = {'message': message, 'card': card, 'notify': notify, 'message_format': format, 'attach_to': attach_to} |
There was a problem hiding this comment.
I tried this code, and if attach_to is None, there will be error like below:
hypchat.requests.HttpBadRequest: {
"error": {
"code": 400,
"description": "Value {value!r} is not of type {expected_type!r}",
"expected_type": "string",
"field": "attach_to",
"message": "Value None for field 'attach_to' is not of type 'string'",
"type": "Bad Request",
"validation": "type",
"value": null
}
Seems to use None check will be better:
if card:
data['card'] = card
if attach_to:
data['attach_to'] = attach_to
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
With these changes, you can send a message to a room, get the message id from the response, and add a reply and attach a card, all nice and contained. For example:
The card will slide right on top of the reply, attached to the first message!
Constructing
my_fancy_card_dictis left as an exercise for the reader, but reading Sending Messages Using Cards should help.