1.4.0 • Published 4 years ago

telegram-bot-ts-types v1.4.0

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

Full Typescript classes for Telegram bot api

With serialization to and from json. With serialization to FormData. Only one dependency.

Auto generated by telegram-types-generator

David NPM npm GitHub top language CodeFactor Bot API

patreon Liberapay giving

Install

npm install telegram-bot-ts-types

or

yarn add telegram-bot-ts-types

Usage

import { User } from 'telegram-bot-ts-types';

new User({
    id: 0,
    isBot: false,
    firstName: 'firstName'
});

Example Serializer

import { ChatSerializer, Chat } from "telegram-bot-ts-types";

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.0

4 years ago

1.3.4

4 years ago

1.3.4-mp

4 years ago

1.3.3

4 years ago

1.3.2-mp

4 years ago

1.3.2

4 years ago

1.3.1-mp

4 years ago

1.3.1

4 years ago

1.3.0-mp

4 years ago

1.2.2

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.0.0

4 years ago