Code Monkey home page Code Monkey logo

erl-tdlib's Introduction

tdlib

Erlang library interfacing with tdlib, a telegram client library created by Telegram.

Build

Have libtdjson.so from tdlib installed in your library path.

Have Rust installed.

Have rebar3 installed.

Clone, cd to repository and compile:

$ rebar3 get-deps
$ rebar3 compile

Getting started

Fetch app_id and app_hash at https://my.telegram.org/apps

In this example we will use following placeholders:

  • app_id : 34567
  • app_hash : qwertyasdfgh123456qweytr
  • telegram account phone number: +1234567890
  • database directory (will be created by tdlib when needed) : tdlib_db
  • code Telegram sends you after sending them phone number : 23456
  • password : pAssWorD..1

Example session:

$ rebar3 shell

1> {ok, Pid} = tdlib:start_link().
2> tdlib:config(Pid, [{api_id, <<"34567">>}, {api_hash, <<"qwertyasdfgh123456qweytr">>}, {database_directory, <<"tdlib_db">>}]).
3> tdlib:phone_number(Pid, <<"+1234567890">>).
4> tdlib:auth_code(Pid, <<"23456">>).
5> tdlib:auth_password(Pid, <<"pAssWorD..1">>).

When authenticated, next run with same db directory will authenticate automatically, you don't need to enter phone, code or password.

Another example, with registering tdlib server (any valid ServerName from gen_server:start_link/4 specification will do: {local, Atom}, {global, Atom} or {via, Module, Term}). Here we suppose tdlib_db directory is already initialized with authenticated account

$ rebar3 shell

1> {ok, Pid} = tdlib:start_link({local, session1}, [{api_id, <<"34567">>}, {api_hash, <<"qwertyasdfgh123456qweytr">>}, {database_directory, <<"tdlib_db">>}]).
2> whereis(session1).
<0.186.0>

Interface

See edoc documentation

Building docs

$ rebar3 edoc

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.