Skip to content

Commit

Permalink
fixed #264
Browse files Browse the repository at this point in the history
  • Loading branch information
windka committed Sep 1, 2022
1 parent 114df35 commit 353c3f0
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 3 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
# Changelog
All notable changes to this project will be documented in this file.

# [14.0.0] - 2022-29-08
# [14.1.0] - 2022-09-01
### Added web app data support - [#264](https://github.com/windkh/node-red-contrib-telegrambot/issues/264)

# [14.0.0] - 2022-08-29
### fixed version 12.0.0 where SOCKS was broken - [#263](https://github.com/windkh/node-red-contrib-telegrambot/issues/263)

# [13.2.0] - 2022-08-28
Expand Down
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ If you want to support this free project. Any help is welcome. You can donate by
- daredoes: for providing the webhook decumentation on Unraid/Docker with SWAG/NGINX/REVERSE-PROXY
- kickouille: for fixing the payment functions and providing the full payment example flow
- skrashevich: for providing approveChatJoinRequest, declineChatJoinRequest

- ShotokanZH: for providing the web app data example


# Installation
[![NPM](https://nodei.co/npm/node-red-contrib-telegrambot.png?downloads=true)](https://nodei.co/npm/node-red-contrib-telegrambot/)
Expand Down Expand Up @@ -1534,6 +1535,14 @@ See the example flow [**create poll**](examples/createpoll.json) in the examples
Use the event node 'Poll' for receiving the updated poll results.


## Web App Data
WebApps is a new feature described here: https://core.telegram.org/bots/webapps
You need to run your web app using a public web server. The url of this web page can be used to communicate with the bot.
Note that the communication must use the https protocol.

See the example flow [**web app data**](examples/webappdata.json) in the examples folder.


## Advanced options when sending messages
Text messages can be formatted as markdown, e.g. to support bold and italic style. To enable markdown format
set the *parse_mode* options property as follows:
Expand Down
1 change: 1 addition & 0 deletions examples/webappdata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[{"id":"75c35f9c5a3311e2","type":"telegram receiver","z":"ec1cf3fd9654e7e5","name":"","bot":"65ca12172854cc2d","saveDataDir":"","filterCommands":false,"x":190,"y":180,"wires":[["6dcc7cba5e039545"],[]]},{"id":"6dcc7cba5e039545","type":"debug","z":"ec1cf3fd9654e7e5","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":390,"y":180,"wires":[]},{"id":"e6c4ec0e9fed9c4a","type":"telegram sender","z":"ec1cf3fd9654e7e5","name":"","bot":"65ca12172854cc2d","haserroroutput":false,"outputs":1,"x":550,"y":240,"wires":[[]]},{"id":"6ec2de9f5dd9876a","type":"function","z":"ec1cf3fd9654e7e5","name":"","func":"var chatId = msg.payload.chatId;\n\nmsg.payload={\n reply_to_message_id: msg.payload.messageId,\n type: \"message\",\n content: \"Managing stuff..\",\n chatId: chatId,\n options: {\n reply_markup: JSON.stringify({\n keyboard:[\n [\n {\n \"text\": \"Managing stuff..\",\n \"web_app\": {\n \"url\":\"https://www.wind.li/test.html?\" + Math.random()\n }\n }\n ]\n ]\n })\n }\n };\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":340,"y":240,"wires":[["e6c4ec0e9fed9c4a"]]},{"id":"4d6829fc9dbe05ee","type":"telegram command","z":"ec1cf3fd9654e7e5","name":"","command":"/foo","description":"","registercommand":false,"language":"","scope":"default","bot":"65ca12172854cc2d","strict":false,"hasresponse":true,"useregex":false,"removeregexcommand":false,"outputs":2,"x":150,"y":240,"wires":[["6ec2de9f5dd9876a"],[]]},{"id":"6142734b9a08b890","type":"comment","z":"ec1cf3fd9654e7e5","name":"Example WebApp for your public web server","info":"<script src=\"https://telegram.org/js/telegram-web-app.js\"></script> \n<script>\nwindow.Telegram.WebApp.sendData(\"SNADO\"); \n</script>","x":270,"y":120,"wires":[]},{"id":"65ca12172854cc2d","type":"telegram bot","botname":"HeinzBot","usernames":"","chatids":"","baseapiurl":"","updatemode":"polling","pollinterval":"3000","usesocks":false,"sockshost":"","socksprotocol":"socks5","socksport":"","socksusername":"","sockspassword":"","bothost":"","botpath":"","localbotport":"8443","publicbotport":"8443","privatekey":"","certificate":"","useselfsignedcertificate":false,"sslterminated":false,"verboselogging":true}]
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "node-red-contrib-telegrambot",
"version": "14.0.0",
"version": "14.1.0",
"description": "Telegram bot nodes for Node-RED",
"dependencies": {
"bluebird": "^3.7.2",
Expand Down
9 changes: 9 additions & 0 deletions telegrambot/99-telegrambot.js
Original file line number Diff line number Diff line change
Expand Up @@ -1007,6 +1007,15 @@ module.exports = function (RED) {
chat: botMsg.chat,
date: botMsg.date,
};
} else if (botMsg.web_app_data) {
messageDetails = {
chatId: botMsg.chat.id,
messageId: botMsg.message_id,
type: 'web_app_data',
content: botMsg.web_app_data,
chat: botMsg.chat,
date: botMsg.date,
};
} else {
// unknown type --> no output
// TODO: connected_website, passport_data, proximity_alert_triggered, voice_chat_scheduled, voice_chat_started, voice_chat_ended, voice_chat_participants_invited, reply_markup
Expand Down

0 comments on commit 353c3f0

Please sign in to comment.