GithubHelp home page GithubHelp logo

thisisdevang / mtproto-js Goto Github PK

View Code? Open in Web Editor NEW

This project forked from spalt08/mtproto-js

0.0 0.0 0.0 995 KB

๐Ÿš€ Fastest ever MTProto JavaScript implementation

Home Page: https://core.telegram.org/mtproto/

License: GNU General Public License v3.0

JavaScript 0.21% TypeScript 99.79%

mtproto-js's Introduction

mtproto-js

Extremly fast and lightweight JavaScript MTProto 2.0 implementation. Current supported API layer is 113. Works both for browser and Node. Reference: https://core.telegram.org/mtproto

Created for Telegram JS Contest 2020: https://contest.com/javascript-web-3/entry1422

General Use

import { Client } from 'mtproto-js';

/** Client configuration */
type ClientConfig = {
  test: boolean,
  debug: boolean,
  ssl: boolean,
  dc: number,
  transport: 'websocket' | 'http',
  meta: Record<number, any>,

  APILayer: number,
  APIID?: string,
  APIHash?: string,

  deviceModel: string,
  systemVersion: string,
  appVersion: string,
  langCode: string,

  autoConnect: boolean,
};

const client = new Client(clientConfig);

client.on('metaChanged', (newMeta) => console.log(newMeta)); // save keys and authorization data
client.updates.on((update) => console.log(update));
client.updates.fetch();

client.call(
  'help.getNearestDc', // method name
  {}, // params
  { dc: 2, thread: 1, transport: 'websocket' }, // headers (optional)
  (err, result) => console.log(err, result),
);

Features

  • Unit tests
  • TL schema code generation
  • Typed
  • Multithreading
  • Supports both WebSockets and HTTP

Dependencies

Contributions

Thanks @misupov for schema code generation tool https://github.com/misupov/tg-schema-generator

mtproto-js's People

Contributors

spalt08 avatar misupov avatar finesse avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.