Socket
Book a DemoInstallSign in
Socket

telegraph-api

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

telegraph-api

API for Telegram's Telegraph

latest
Source
npmnpm
Version
1.1.0
Version published
Maintainers
1
Created
Source

Telegraph-API

Telegram's Telegraph doesn't have API. Package suggest some missed handles for publishing posts on Telegraph's platform.

Install

Terminal:

// npm
npm i telegraph-api --save

// yarn
yarn add telegraph-api

Usage

First of all you need to create new instance of telegraph-api.

const Post = require('telegraph-api');

// without params
const firstPost = new Post();

// or with params
const secondPost = new Post({
    header: 'Header',
    author: 'Author',
    paragraphs: ['Paragraph']
});

Then you can use public getters and setters methods that it provides:

  • getHeader() - returns String
  • setHeader({String})
  • getAuthor() - returns String
  • setAuthor({String})
  • getParagraphs() - returns String[]
  • setParagraphs({String[]})
  • setParagraph({String})
  • removeLastParagraph()
  • emptyHeader()
  • emptyAuthor()
  • emptyParagraphs()
  • publishPost({Function({Error}, {String})})

Examples

Filled constructor

const Post = require('telegraph-api');

const myPost = new Post({
    header: 'Telegraph-API',
    author: 'Roman Ponomarev',
    paragraphs: ['First post by Telegraph-API']
});

myPost.publishPost((err, link) => {
    if (err) {
        throw new Error(error);
    }

    console.log(`Link to Post: ${link}`); // => Link to Post: http://telegra.ph/Telegraph-API-11-28
});

Empty constructor

const Post = require('telegraph-api');

const myPost = new Post();

myPost.setHeader('Telegraph-API');
myPost.setAuthor('Roman Ponomarev');
myPost.setParagraph('Second post by Telegraph-API');

console.log(myPost.getHeader()); // => Telegraph-API
console.log(myPost.getAuthor()); // => Roman Ponomarev
console.log(myPost.getParagraphs()); // => ['Second post by Telegraph-API']

myPost.publishPost((err, link) => {
    if (err) {
        throw new Error(error);
    }

    console.log(`Link to Post: ${link}`); // => Link to Post: http://telegra.ph/Telegraph-API-11-28-2
});

Keywords

telegraph

FAQs

Package last updated on 28 Nov 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.