December 20, 2016 Telegram opened the API to the Telegraph . To work with it, I wrote a simple and functional JavaScript library.
Telegraph is a service of notes and stories made in a minimalist style, developed by the Telegram team. Also support Instant View when viewing from Telegram.
→ In more detail about Telegraph
npm install --save telegraph-node
const telegraph = require('telegraph-node') const ph = new telegraph()
Account creation:
ph.createAccount(short_name, options).then((resulr) => { console.log(result) })
Editing account:
ph.editAccountInfo(access_token, options).then((resulr) => { console.log(result) })
Getting account information:
ph.getAccountInfo(access_token, options).then((resulr) => { console.log(result) })
Token Re-issue:
ph.revokeAccessToken(access_token).then((resulr) => { console.log(result) })
Page creation:
ph.createPage(access_token, title, content, options).then((resulr) => { console.log(result) })
Editing page:
ph.editPage(access_token, path, title, content, options).then((resulr) => { console.log(result) })
Receiving page:
ph.getPage(path, options).then((resulr) => { console.log(result) })
Getting a list of pages:
ph.getPageList(access_token, options).then((resulr) => { console.log(result) })
Getting page view count:
ph.getViews(path, options).then((resulr) => { console.log(result) })
To process and send POST requests to the API, I used the Tiny Request framework
I will use it to create Telegram Bot. It often happens that you need to display a large amount of information with pictures and location, sending many messages solves the problem, but I believe that the Telegraph with its Instant View can do better.
Thanks to all those who mastered the article. Waiting for your feedback and suggestion!
Update: Support Promise
Source: https://habr.com/ru/post/318474/
All Articles