1.4.2 • Published 4 years ago

telegram-types-generator v1.4.2

Weekly downloads
1
License
MIT
Repository
github
Last release
4 years ago

Typescript classes code generator for Telegram types

David NPM npm GitHub top language CodeFactor Bot API

patreon Liberapay giving

Default output dirs:

./etities/ for Classes

./serialize/ for Serialize

./method_params/ for Method Params

Install

    npm install -g telegram-types-generator

or

    yarn global add telegram-types-generator

Usage

Run telegram-types-generator in directory where you want to generate classes

Run telegram-types-generator --mp to generate with methods params

Run telegram-types-generator --fd to generate with serialize to FormData using formdata-node

Example Serializer

import ChatSerializer from "./serialize/chat_serializer";
import Chat from "./entities/chat";

let json = '{"id":123,"type":"private","username":"username","first_name":"Name"}';

let chat = ChatSerializer.fromJson(JSON.parse(json));

console.log(chat); /* Will print
Chat {
  _id: 123,
  _type: 'private',
  _title: null,
  _username: 'username',
  _firstName: 'Name',
  _lastName: null,
  _photo: null,
  _description: null,
  _inviteLink: null,
  _pinnedMessage: null,
  _permissions: null,
  _slowModeDelay: null,
  _stickerSetName: null,
  _canSetStickerSet: null
}*/

console.log(chat instanceof Chat); // Will print true

let jsonChat = ChatSerializer.toJsonString(chat);
console.log(jsonChat); // Will print {"id":123,"type":"private","username":"username","first_name":"Name"}
1.4.2

4 years ago

1.4.1

4 years ago

1.4.0

4 years ago

1.3.6

4 years ago

1.3.5

4 years ago

1.3.4

4 years ago

1.3.3

4 years ago

1.3.2

4 years ago

1.3.1

4 years ago

1.3.0

4 years ago

1.2.1

4 years ago

1.2.0

4 years ago

1.1.1

4 years ago

1.1.0

4 years ago

1.1.2

4 years ago

1.0.0

4 years ago