{"id":18284399,"url":"https://github.com/erickotato/tdlibnse","last_synced_at":"2025-04-09T05:46:16.771Z","repository":{"id":137821123,"uuid":"307507900","full_name":"EricKotato/TDLibNSE","owner":"EricKotato","description":"TDLib as native Sciter extension.","archived":false,"fork":false,"pushed_at":"2020-12-05T10:03:58.000Z","size":15,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-15T00:25:40.962Z","etag":null,"topics":["extension","sciter","sciter-library","tdlib"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsl-1.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/EricKotato.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-10-26T21:23:25.000Z","updated_at":"2020-12-04T18:21:45.000Z","dependencies_parsed_at":null,"dependency_job_id":"e8adeebe-a4f5-4e59-8eea-866bf13245c8","html_url":"https://github.com/EricKotato/TDLibNSE","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EricKotato%2FTDLibNSE","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EricKotato%2FTDLibNSE/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EricKotato%2FTDLibNSE/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EricKotato%2FTDLibNSE/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/EricKotato","download_url":"https://codeload.github.com/EricKotato/TDLibNSE/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247987107,"owners_count":21028891,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["extension","sciter","sciter-library","tdlib"],"created_at":"2024-11-05T13:13:24.838Z","updated_at":"2025-04-09T05:46:16.751Z","avatar_url":"https://github.com/EricKotato.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# TDLib Native Sciter Extension\n\nSimple [Sciter](https://sciter.com) native extension for TDLib's JSON interface. Tested on Windows with Visual Studio 2019, possible (but haven't tested yet) to work on Linux.\n\n## Prerequisites to build\n\n* CMake\n* Visual Studio (on Windows) or any other CMake supported compiler\n* TDLib (as CMake package)\n* Sciter SDK\n\n## Build process\n\nThis instruction assumes the following:\n* CMake is installed and added to your PATH environment variable\n* Commands are executed in \"x86 Native Tools Command Prompt for VS 2019\"\n* TDLib is installed in C:\\TDLib\n* Sciter SDK is unpacked at C:\\sciter\n* This repo is cloned to C:\\TDLibNSE\n* Build files will be located at C:\\TDLibNSE\\build\n\nGenerate build files (starting from C:\\TDLibNSE):\n```\nmkdir build\ncd build\ncmake -A Win32 -DTd_DIR=C:\\TDLib\\lib\\cmake\\Td -DSCITER_INCLUDE_DIR=C:\\sciter\\include ..\\TDLibNSE\n```\n\nOmit `-A Win32` to use your default system architecture.\n\nOmit any of `-DTD_DIR` and `-DSCITER_INCLUDE_DIR` (or all) to search packages in default paths.\n\nYou can also add `-DUSE_STATIC_TDJSON=ON` to `cmake` arguments if you want it to link extension against static library instead of dynamic.\n\n\nBuild (starting from C:\\TDLibNSE\\build):\n```\ncmake --build . --clean-first --config Release\n```\n\nOmit `--clean-first` if you don't want to clean project before building.\n\nOmit `--config Release` if you wan't to build default configuration `Debug`. You can also specify it explicitly: `--config Debug`.\n\n\n## Using the library\n\nOn Windows you need to following files to be put near scapp.exe or to be found in system paths:\n* TDLibNSE.dll (your built file, can be found in C:\\TDLibNSE\\build\\Release or C:\\TDLibNSE\\build\\Debug)\n* tdjson.dll (TDLib with JSON interface, can be found at C:\\TDLib\\bin)\n* libcrypto-1_1.dll (TDLib prereqisites)\n* libssl-1_1.dll (TDLib prereqisites)\n* zlib1.dll (TDLib prereqisites)\n\nIf you have installed TDLib prerequisites from vcpkg and installed vcpkg to C:\\vcpkg, these files can be found at C:\\vcpkg\\installed\\x86-windows\\bin (or vcpkg\\installed\\x64-windows\\bin for x64).\n\nAfter that, you can include it in your Sciter HTML file as:\n```\ninclude library \"TDLibNSE\";\n```\nor\n```\nconst Td = include library \"TDLibNSE\";\n```\nor even\n```\nnamespace Td {\n\tconst tdlib = include library \"TDLibNSE\";\n}\n```\n\n## API\n\nAPI in TDLibNSE is pretty much same as TDLib new JSON interface.\n\n* `int TDLib.createClient()` – creates new TDLib client and returns its ID.\n* `void TDLib.send(int client_id, string request)` – sends request JSON encoded string to specified client_id.\n* `string TDLib.receive(double timeout)` – polls for new updates from clients for timeout, returns JSON encoded string of response.\n* `void TDLib.startReceiveThread(double timeout, function callback)` – polls for new updates from clients for timeout in separate thread, calls `callback` with returns JSON encoded string of response.\n  * Callback signature is `int callback(string result)`.\n    * Return `-1` in callback to stop thread.\n    * Return `0` in callback to specify no delay.\n    * Return a positive number to specify a delay in milliseconds.\n  * When thread is started, first JSON received will be `{\"tdlibnse\":\"receive_thread_started\"}`.\n* `void TDLib.stopReceiveThread()` – stops polling for updates in thread.\n  * When thread is stopped, last JSON received will be `{\"tdlibnse\":\"receive_thread_stopped\"}`.\n* `bool TDLib.receiveThreadRunning()` – returns `true` if polling thread is running.\n* `string TDLib.execute(string request)` – sends request JSON encoded string to TDLib, returns JSON encoded string of response.\n\n## Recommendations\n* For some reason, if `setLogVerbosityLevel` is not set, TDLib may eat your CPU even if you specified a delay in receive thread.\n\n## Example usage\n\n```html\n\u003chtml\u003e\n\u003chead\u003e\n  \u003ctitle\u003eTDLib Test\u003c/title\u003e\n  \u003cstyle\u003e\n    #out {\n      font: monospace;\n    }\n  \u003c/style\u003e\n\u003c/head\u003e\n\u003cscript type=\"text/tiscript\"\u003e\n  include library \"TDLibNSE\";\n\n  var testRequest = {\n      \"@type\": \"getTextEntities\",\n      \"text\": \"@telegram /test_command https://telegram.org telegram.me\",\n      \"@extra\": [\"5\", 7.0]\n  };\n\n  event click $(#test) {\n    if (TDLib) {\n        var j = JSON.parse(TDLib.execute(JSON.stringify(testRequest)));\n        $(#out).text = JSON.stringify(j);\n    } else {\n        $(#out).text = \"Couldn't load TDLib.\";\n    }\n  }\n\u003c/script\u003e\n\u003cbody\u003e\n  \u003cbutton#test\u003eTest TDLib\u003c/button\u003e\n  \u003ctext#out /\u003e\n\u003c/body\u003e\n\u003c/html\u003e\n```\n\nRequest structure was taken from TDLib's [Python example](https://github.com/tdlib/td/blob/master/example/python/tdjson_example.py).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ferickotato%2Ftdlibnse","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ferickotato%2Ftdlibnse","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ferickotato%2Ftdlibnse/lists"}