From 91ede6188ee4ca64f1d2d4491d3413133765831f Mon Sep 17 00:00:00 2001 From: axfree Date: Wed, 16 Mar 2016 20:54:15 +0900 Subject: [PATCH] Add html and markdown formatting for messages. --- lib/types/Message.js | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/lib/types/Message.js b/lib/types/Message.js index ff55df4..ab3299a 100644 --- a/lib/types/Message.js +++ b/lib/types/Message.js @@ -35,6 +35,32 @@ export default class Message extends Base { return this; } + /** + * Set text of the message in HTML format + * @param {string} text Message's content in HTML format + * @return {object} returns the message object + */ + html(text) { + this.properties.parse_mode = 'HTML'; + if (text) { + this.properties.text = text; + } + return this; + } + + /** + * Set text of the message in Markdown format + * @param {string} text Message's content in Markdown format + * @return {object} returns the message object + */ + markdown(text) { + this.properties.parse_mode = 'Markdown'; + if (text) { + this.properties.text = text; + } + return this; + } + /** * Set reply_to_message_id of the message * @param {number} id message_id of the message to reply to