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

erl-tdlib's People

Contributors

lattenwald avatar

Stargazers

Stas Versilov avatar Stanislav Mekhonoshin avatar Alessandro Usseglio Viretta avatar Charles avatar  avatar Vladimir Drobyshevskiy avatar Sergiy Pash avatar Ricardo Lanziano avatar Leonardo Rossi avatar Conrad Steenberg avatar

Watchers

James Cloos avatar  avatar  avatar

Forkers

vheathen onnet

erl-tdlib's Issues

some problem with paths and names

===> Compiling tdlib cp: не удалось выполнить stat для 'priv/crates/tdlib_nif/0.2.0/release/libtdlib_nif.so': Нет такого файла или каталога ===> Hook for compile failed!
ls priv/crates/tdlib_nif/ tdlib_nif.so

tdlib does not compile

The tdlib would not compile.

The 'rebar3 compile' command returns:
===> Verifying dependencies...
===> Compiling tdlib
===> Unable to run post hooks for 'compile', command 'compile' in namespace 'rust' not found.

no compile

Erlang/OTP 25 [erts-13.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [jit:ns]
Cargo 1.70.0 (ec8a8a0ca 2023-04-25)
./rebar3 compile ===> Verifying dependencies... Compiling tdlib-nif v0.2.0 (/home/oper/Programs/tracker_rpc/_build/default/lib/tdlib/crates/tdlib-nif) error: could not compile tdlib-nif(lib) due to 2 previous errors; 18 warnings emitted ===> Uncaught error in rebar_core. Run with DIAGNOSTIC=1 to see stacktrace or consult rebar3.crashdump ===> When submitting a bug report, please include the output ofrebar3 report "your command" Error: {cargo_error,{101,
[#{<<"executable">> => null,
<<"features">> => [<<"default">>,<<"proc-macro">>],
<<"filenames">> =>
[<<"/home/oper/Programs/tracker_rpc/_build/default/lib/tdlib/target/debug/build/proc-macro2-0228cc05829635c7/build-script-build">>],
<<"fresh">> => true,
<<"manifest_path">> =>
<<"/home/oper/.cargo/registry/src/index.crates.io-6f17d22bba15001f/proc-macro2-1.0.36/Cargo.toml">>,
<<"package_id">> =>
<<"proc-macro2 1.0.36 (registry+https://github.com/rust-lang/crates.io-index)">>,
<<"profile">> =>
#{<<"debug_assertions">> => true,
<<"debuginfo">> => null,
<<"opt_level">> => <<"0">>,
<<"overflow_checks">> => true,
<<"test">> => false},
<<"reason">> => <<"compiler-artifact">>,
<<"target">> =>
#{<<"crate_types">> => [<<"bin">>],
<<"doc">> => false,<<"doctest">> => false,
<<"edition">> => <<"2018">>,
<<"kind">> => [<<"custom-build">>],
<<"name">> => <<"build-script-build">>,
<<"src_path">> =>
<<"/home/oper/.cargo/registry/src/index.crates.io-6f17d22bba15001f/proc-macro2-1.0.36/build.rs">>,
<<"test">> => false}},
#{<<"cfgs">> =>
[<<"use_proc_macro">>,<<"wrap_proc_macro">>],
<<"env">> => [],<<"linked_libs">> => [],
<<"linked_paths">> => [],
<<"out_dir">> =>
<<"/home/oper/Programs/tracker_rpc/_build/default/lib/tdlib/target/debug/build/proc-macro2-6f335e9bd6f698be/out">>,
<<"package_id">> =>
<<"proc-macro2 1.0.36 (registry+https://github.com/rust-lang/crates.io-index)">>,
<<"reason">> => <<"build-script-executed">>},
#{<<"executable">> => null,
<<"features">> => [<<"default">>],
<<"filenames">> =>
[<<"/home/oper/Programs/tracker_rpc/_build/default/lib/tdlib/target/debug/deps/libunicode_xid-bfeb5d092a72ddea.rlib">>,
<<"/home/oper/Programs/tracker_rpc/_build/default/lib/tdlib/target/debug/deps/libunicode_xid-bfeb5d092a72ddea.rmeta">>],
<<"fresh">> => true,
<<"manifest_path">> =>
<<"/home/oper/.cargo/registry/src/index.crates.io-6f17d22bba15001f/unicode-xid-0.2.2/Cargo.toml">>,
<<"package_id">> =>
<<"unicode-xid 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)">>,
<<"profile">> =>
#{<<"debug_assertions">> => true,
<<"debuginfo">> => null,
<<"opt_level">> => <<"0">>,
<<"overflow_checks">> => true,
<<"test">> => false},
<<"reason">> => <<"compiler-artifact">>,
<<"target">> =>
#{<<"crate_types">> => [<<"lib">>],
<<"doc">> => true,<<"doctest">> => true,
<<"edition">> => <<"2015">>,
<<"kind">> => [<<"lib">>],
<<"name">> => <<"unicode-xid">>,
<<"src_path">> =>
<<"/home/oper/.cargo/registry/src/index.crates.io-6f17d22bba15001f/unicode-xid-0.2.2/src/lib.rs">>,
<<"test">> => true}},
#{<<"executable">> => null,
<<"features">> => [<<"default">>,<<"proc-macro">>],
<<"filenames">> =>
[<<"/home/oper/Programs/tracker_rpc/_build/default/lib/tdlib/target/debug/deps/libproc_macro2-1845b056c836bec2.rlib">>,
<<"/home/oper/Programs/tracker_rpc/_build/default/lib/tdlib/target/debug/deps/libproc_macro2-1845b056c836bec2.rmeta">>],
<<"fresh">> => true,
<<"manifest_path">> =>
<<"/home/oper/.cargo/registry/src/index.crates.io-6f17d22bba15001f/proc-macro2-1.0.36/Cargo.toml">>,
<<"package_id">> =>
<<"proc-macro2 1.0.36 (registry+https://github.com/rust-lang/crates.io-index)">>,
<<"profile">> =>
#{<<"debug_assertions">> => true,
<<"debuginfo">> => null,
<<"opt_level">> => <<"0">>,
<<"overflow_checks">> => true,
<<"test">> => false},
<<"reason">> => <<"compiler-artifact">>,
<<"target">> =>
#{<<"crate_types">> => [<<"lib">>],
<<"doc">> => true,<<"doctest">> => true,
<<"edition">> => <<"2018">>,
<<"kind">> => [<<"lib">>],
<<"name">> => <<"proc-macro2">>,
<<"src_path">> =>
<<"/home/oper/.cargo/registry/src/index.crates.io-6f17d22bba15001f/proc-macro2-1.0.36/src/lib.rs">>,
<<"test">> => true}},
#{<<"executable">> => null,
<<"features">> =>
[<<"clone-impls">>,<<"default">>,<<"derive">>,
<<"extra-traits">>,<<"full">>,<<"parsing">>,
<<"printing">>,<<"proc-macro">>,<<"quote">>],
<<"filenames">> => `

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.