Unverified Commit 29cfeab8 authored by Tiago Epifânio's avatar Tiago Epifânio Committed by GitHub
Browse files

Adding quoted message (#1818)

When the telegram message is a reply to a previous message, add the quoted message and its username to the rocket.chat message.
That way users on rocket.chat can see the context in which a message is sent.
parent cd1b34d7
......@@ -24,6 +24,17 @@ _follow these instructions to get a simple Telegram Bot setup_
```javascript
class Script {
addQuotePrefix(str) {
let tmp = str.split('\n'),
res = [];
for (const frag of tmp) {
res.push(`> ${frag}`);
}
return res.join('\n');
}
process_incoming_request({ request }) {
// UNCOMMENT THE BELOW LINE TO DEBUG IF NEEDED.
// console.log(request.content);
......@@ -54,6 +65,17 @@ class Script {
}
}
if(request.content.message.reply_to_message) {
var quotedMessage =
"*" +
request.content.message.reply_to_message.from.username +
"*\n" +
request.content.message.reply_to_message.text;
quotedMessage = this.addQuotePrefix(quotedMessage);
body = quotedMessage + '\n' + body;
}
return {
content: {
username: who,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment