@patricktobias86/node-red-telegram-account 1.1.1 → 1.1.3
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.
- package/examples/Example User Auth.json +104 -0
- package/nodes/auth.html +60 -59
- package/nodes/auth.js +41 -23
- package/nodes/command.html +6 -7
- package/nodes/config.html +1 -1
- package/nodes/config.js +32 -36
- package/nodes/delete-message.html +14 -13
- package/nodes/get-entity.html +4 -3
- package/nodes/icons/tg.png +0 -0
- package/nodes/iter-dialogs.html +6 -4
- package/nodes/iter-messages.html +5 -3
- package/nodes/promote-admin.html +4 -3
- package/nodes/receiver.html +14 -15
- package/nodes/send-file.html +6 -5
- package/nodes/send-message.html +4 -3
- package/package.json +1 -1
- package/patricktobias86-node-red-telegram-account-1.1.3.tgz +0 -0
- package/icons/tg.png +0 -0
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"id": "8a1d5a99e1018272",
|
|
4
|
+
"type": "tab",
|
|
5
|
+
"label": "Example User Auth",
|
|
6
|
+
"disabled": false,
|
|
7
|
+
"info": "",
|
|
8
|
+
"env": []
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
"id": "inject_credentials",
|
|
12
|
+
"type": "inject",
|
|
13
|
+
"z": "8a1d5a99e1018272",
|
|
14
|
+
"name": "Start Auth",
|
|
15
|
+
"props": [],
|
|
16
|
+
"repeat": "",
|
|
17
|
+
"crontab": "",
|
|
18
|
+
"once": false,
|
|
19
|
+
"onceDelay": 0.1,
|
|
20
|
+
"topic": "",
|
|
21
|
+
"x": 160,
|
|
22
|
+
"y": 100,
|
|
23
|
+
"wires": [
|
|
24
|
+
[
|
|
25
|
+
"ee6466b89cc7a43b"
|
|
26
|
+
]
|
|
27
|
+
]
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
"id": "debug_output",
|
|
31
|
+
"type": "debug",
|
|
32
|
+
"z": "8a1d5a99e1018272",
|
|
33
|
+
"name": "Session Output",
|
|
34
|
+
"active": true,
|
|
35
|
+
"tosidebar": true,
|
|
36
|
+
"console": false,
|
|
37
|
+
"tostatus": false,
|
|
38
|
+
"complete": "true",
|
|
39
|
+
"targetType": "full",
|
|
40
|
+
"statusVal": "",
|
|
41
|
+
"statusType": "auto",
|
|
42
|
+
"x": 560,
|
|
43
|
+
"y": 100,
|
|
44
|
+
"wires": []
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
"id": "inject_code",
|
|
48
|
+
"type": "inject",
|
|
49
|
+
"z": "8a1d5a99e1018272",
|
|
50
|
+
"name": "Send Code",
|
|
51
|
+
"props": [
|
|
52
|
+
{
|
|
53
|
+
"p": "payload"
|
|
54
|
+
}
|
|
55
|
+
],
|
|
56
|
+
"repeat": "",
|
|
57
|
+
"crontab": "",
|
|
58
|
+
"once": false,
|
|
59
|
+
"onceDelay": "",
|
|
60
|
+
"topic": "",
|
|
61
|
+
"payload": "{\"code\":\"00000\"}",
|
|
62
|
+
"payloadType": "json",
|
|
63
|
+
"x": 170,
|
|
64
|
+
"y": 180,
|
|
65
|
+
"wires": [
|
|
66
|
+
[
|
|
67
|
+
"function_send_code"
|
|
68
|
+
]
|
|
69
|
+
]
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
"id": "function_send_code",
|
|
73
|
+
"type": "function",
|
|
74
|
+
"z": "8a1d5a99e1018272",
|
|
75
|
+
"name": "Submit Code",
|
|
76
|
+
"func": "const code = msg.payload.code;\nconst wait = flow.get(\"waitForCode\");\nif (typeof wait === \"function\") {\n wait(code);\n flow.set(\"waitForCode\", null);\n node.status({fill:\"blue\",shape:\"ring\",text:\"Code sent!\"});\n} else {\n node.warn(\"No code listener available. Did you trigger auth first?\");\n}\nreturn null;",
|
|
77
|
+
"outputs": 0,
|
|
78
|
+
"timeout": "",
|
|
79
|
+
"noerr": 0,
|
|
80
|
+
"initialize": "",
|
|
81
|
+
"finalize": "",
|
|
82
|
+
"libs": [],
|
|
83
|
+
"x": 370,
|
|
84
|
+
"y": 180,
|
|
85
|
+
"wires": []
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
"id": "ee6466b89cc7a43b",
|
|
89
|
+
"type": "auth",
|
|
90
|
+
"z": "8a1d5a99e1018272",
|
|
91
|
+
"name": "",
|
|
92
|
+
"api_id": "",
|
|
93
|
+
"api_hash": "",
|
|
94
|
+
"phoneNumber": "",
|
|
95
|
+
"password": "",
|
|
96
|
+
"x": 350,
|
|
97
|
+
"y": 100,
|
|
98
|
+
"wires": [
|
|
99
|
+
[
|
|
100
|
+
"debug_output"
|
|
101
|
+
]
|
|
102
|
+
]
|
|
103
|
+
}
|
|
104
|
+
]
|
package/nodes/auth.html
CHANGED
|
@@ -3,26 +3,31 @@
|
|
|
3
3
|
category: 'telegram-account',
|
|
4
4
|
color: '#a6bbcf',
|
|
5
5
|
defaults: {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
name: { value: "" },
|
|
7
|
+
api_id: { value: "" },
|
|
8
|
+
api_hash: { value: "" },
|
|
9
|
+
phoneNumber: { value: "" },
|
|
10
|
+
password: { value: "" }
|
|
10
11
|
},
|
|
11
12
|
inputs: 1,
|
|
12
13
|
outputs: 1,
|
|
13
|
-
icon:
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
icon: 'tg.png',
|
|
15
|
+
align: 'right',
|
|
16
|
+
paletteLabel: 'user auth',
|
|
17
|
+
label: function() {
|
|
18
|
+
return this.name||'user auth';
|
|
16
19
|
},
|
|
17
20
|
oneditprepare: function () {
|
|
18
|
-
//
|
|
21
|
+
// Initialize values
|
|
22
|
+
$("#node-input-name").val(this.name || "");
|
|
19
23
|
$("#node-input-api_id").val(this.api_id || "");
|
|
20
24
|
$("#node-input-api_hash").val(this.api_hash || "");
|
|
21
25
|
$("#node-input-phoneNumber").val(this.phoneNumber || "");
|
|
22
26
|
$("#node-input-password").val(this.password || "");
|
|
23
27
|
},
|
|
24
28
|
oneditsave: function () {
|
|
25
|
-
//
|
|
29
|
+
// Save values
|
|
30
|
+
this.name = $("#node-input-name").val();
|
|
26
31
|
this.api_id = $("#node-input-api_id").val();
|
|
27
32
|
this.api_hash = $("#node-input-api_hash").val();
|
|
28
33
|
this.phoneNumber = $("#node-input-phoneNumber").val();
|
|
@@ -32,6 +37,12 @@
|
|
|
32
37
|
</script>
|
|
33
38
|
|
|
34
39
|
<script type="text/html" data-template-name="auth">
|
|
40
|
+
<div class="form-row">
|
|
41
|
+
<label for="node-input-name">
|
|
42
|
+
<i class="fa fa-tag"></i> Name
|
|
43
|
+
</label>
|
|
44
|
+
<input type="text" id="node-input-name" placeholder="Name">
|
|
45
|
+
</div>
|
|
35
46
|
<div class="form-row">
|
|
36
47
|
<label for="node-input-api_id">
|
|
37
48
|
<i class="fa fa-key"></i> API ID
|
|
@@ -61,78 +72,68 @@
|
|
|
61
72
|
</div>
|
|
62
73
|
|
|
63
74
|
<p>
|
|
64
|
-
<strong>Note:</strong>
|
|
75
|
+
<strong>Note:</strong> These values are used to create a Telegram session string.
|
|
65
76
|
</p>
|
|
66
77
|
</script>
|
|
67
78
|
|
|
68
|
-
|
|
69
79
|
<script type="text/html" data-help-name="auth">
|
|
70
|
-
<p>The <b>auth</b> node facilitates Telegram API authentication using the <code>telegram</code> library. It allows users to authenticate a session and retrieve a stringSession for
|
|
80
|
+
<p>The <b>auth</b> node facilitates Telegram API authentication using the <code>telegram</code> (GramJS) library. It allows users to authenticate a session and retrieve a <code>stringSession</code> for reuse with other Telegram clients.</p>
|
|
71
81
|
|
|
72
82
|
<h3>Inputs</h3>
|
|
73
83
|
<dl class="message-properties">
|
|
74
|
-
<dt>payload.api_id
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
<
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
<
|
|
85
|
-
<span class="property-type">string</span>
|
|
86
|
-
</dt>
|
|
87
|
-
<dd>The phone number associated with the Telegram account.</dd>
|
|
88
|
-
|
|
89
|
-
<dt>payload.password
|
|
90
|
-
<span class="property-type">string</span>
|
|
91
|
-
</dt>
|
|
92
|
-
<dd>The password for two-factor authentication (if enabled on the Telegram account).</dd>
|
|
84
|
+
<dt>payload.api_id <span class="property-type">number | string</span></dt>
|
|
85
|
+
<dd>The Telegram API ID.</dd>
|
|
86
|
+
|
|
87
|
+
<dt>payload.api_hash <span class="property-type">string</span></dt>
|
|
88
|
+
<dd>The Telegram API hash.</dd>
|
|
89
|
+
|
|
90
|
+
<dt>payload.phoneNumber <span class="property-type">string</span></dt>
|
|
91
|
+
<dd>The phone number of the Telegram account, including country code (e.g. +1701234567).</dd>
|
|
92
|
+
|
|
93
|
+
<dt>payload.password <span class="property-type">string</span></dt>
|
|
94
|
+
<dd>(Optional) The password for two-factor authentication.</dd>
|
|
93
95
|
</dl>
|
|
94
96
|
|
|
97
|
+
<h3>Behavior</h3>
|
|
98
|
+
<p>When triggered, the node starts the login flow by sending a code via SMS or Telegram to the specified phone number. The node will wait for a verification code to be supplied separately.</p>
|
|
99
|
+
<p>To complete authentication, you must send the code using a function node like this:</p>
|
|
100
|
+
<pre>
|
|
101
|
+
const code = msg.payload.code;
|
|
102
|
+
const wait = flow.get("waitForCode");
|
|
103
|
+
if (typeof wait === "function") {
|
|
104
|
+
wait(code);
|
|
105
|
+
flow.set("waitForCode", null);
|
|
106
|
+
node.status({fill:"blue",shape:"ring",text:"Code sent!"});
|
|
107
|
+
}
|
|
108
|
+
</pre>
|
|
109
|
+
|
|
95
110
|
<h3>Outputs</h3>
|
|
96
111
|
<dl class="message-properties">
|
|
97
|
-
<dt>topic
|
|
98
|
-
<span class="property-type">string</span>
|
|
99
|
-
</dt>
|
|
112
|
+
<dt>topic <span class="property-type">string</span></dt>
|
|
100
113
|
<dd>
|
|
101
|
-
- <b>"auth_success"</b>:
|
|
102
|
-
- <b>"auth_error"</b>:
|
|
114
|
+
- <b>"auth_success"</b>: Login succeeded.<br>
|
|
115
|
+
- <b>"auth_error"</b>: Login failed.
|
|
103
116
|
</dd>
|
|
104
117
|
|
|
105
|
-
<dt>payload
|
|
106
|
-
<span class="property-type">object</span>
|
|
107
|
-
</dt>
|
|
118
|
+
<dt>payload <span class="property-type">object</span></dt>
|
|
108
119
|
<dd>
|
|
109
|
-
For <b>"auth_success"</b>:
|
|
110
|
-
<ul>
|
|
111
|
-
<li><code>payload.stringSession</code>: The generated session string.</li>
|
|
112
|
-
<li><code>payload.message</code>: Success message.</li>
|
|
113
|
-
</ul>
|
|
114
|
-
For <b>"auth_error"</b>:
|
|
115
120
|
<ul>
|
|
116
|
-
<li><code>
|
|
121
|
+
<li><code>stringSession</code>: The generated session string to reuse in your bots.</li>
|
|
122
|
+
<li><code>message</code> or <code>error</code>: Additional info.</li>
|
|
117
123
|
</ul>
|
|
118
124
|
</dd>
|
|
119
125
|
</dl>
|
|
120
126
|
|
|
121
|
-
<h3>Details</h3>
|
|
122
|
-
<p>To use the <b>auth</b> node, pass the required API credentials and phone number as part of the input message payload. The node will initiate the Telegram authentication flow. If a two-factor password is required, include it in the <code>payload.password</code>.</p>
|
|
123
|
-
|
|
124
|
-
<p>The node temporarily stores the phone code resolver in the flow context under the key <code>phoneCode</code>. This allows subsequent nodes to resolve the phone code using a separate input mechanism, such as user interaction.</p>
|
|
125
|
-
|
|
126
127
|
<h3>Example</h3>
|
|
127
128
|
<pre>
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
}
|
|
129
|
+
{
|
|
130
|
+
"payload": {
|
|
131
|
+
"api_id": "123456",
|
|
132
|
+
"api_hash": "your_api_hash",
|
|
133
|
+
"phoneNumber": "+46701234567",
|
|
134
|
+
"password": "optional_password"
|
|
135
135
|
}
|
|
136
|
+
}
|
|
136
137
|
</pre>
|
|
137
|
-
<p>
|
|
138
|
+
<p>Use a separate node to submit the received code after triggering this payload.</p>
|
|
138
139
|
</script>
|
package/nodes/auth.js
CHANGED
|
@@ -7,51 +7,69 @@ module.exports = function (RED) {
|
|
|
7
7
|
const node = this;
|
|
8
8
|
|
|
9
9
|
this.on("input", async (msg) => {
|
|
10
|
-
const api_idString = msg.payload.api_id || config.api_id;
|
|
11
|
-
const api_hash = msg.payload.api_hash || config.api_hash;
|
|
12
|
-
const phoneNumber = msg.payload.phoneNumber || config.phoneNumber;
|
|
13
|
-
const password = msg.payload.password || config.password;
|
|
14
|
-
const api_id = parseInt(api_idString);
|
|
15
10
|
|
|
16
|
-
const
|
|
11
|
+
const payload = (msg && typeof msg.payload === "object") ? msg.payload : {};
|
|
12
|
+
|
|
13
|
+
const api_id = parseInt(payload.api_id || config.api_id);
|
|
14
|
+
const api_hash = payload.api_hash || config.api_hash;
|
|
15
|
+
const phoneNumber = payload.phoneNumber || config.phoneNumber;
|
|
16
|
+
const password = payload.password || config.password;
|
|
17
|
+
|
|
18
|
+
if (!api_id || !api_hash || !phoneNumber) {
|
|
19
|
+
node.error("Missing required API credentials (api_id, api_hash, or phoneNumber).");
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const session = new StringSession(""); // always generate a new session
|
|
17
24
|
const client = new TelegramClient(session, api_id, api_hash, {
|
|
18
25
|
connectionRetries: 5,
|
|
19
26
|
});
|
|
20
27
|
|
|
21
|
-
|
|
22
|
-
let resolvePhoneCode;
|
|
23
28
|
const context = node.context().flow;
|
|
24
29
|
|
|
30
|
+
let phoneCodePromise = new Promise((resolve) => {
|
|
31
|
+
context.set("waitForCode", resolve);
|
|
32
|
+
});
|
|
33
|
+
|
|
25
34
|
try {
|
|
26
35
|
await client.start({
|
|
27
36
|
phoneNumber: () => phoneNumber,
|
|
28
37
|
password: () => password,
|
|
29
|
-
phoneCode: async () =>{
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
})
|
|
38
|
+
phoneCode: async () => {
|
|
39
|
+
node.status({ fill: "yellow", shape: "ring", text: "Waiting for code" });
|
|
40
|
+
const code = await phoneCodePromise;
|
|
41
|
+
return code;
|
|
34
42
|
},
|
|
35
|
-
onError: (err) => node.error(
|
|
43
|
+
onError: (err) => node.error("GramJS Error: " + err.message),
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
const stringSession = client.session.save();
|
|
47
|
+
|
|
48
|
+
console.log("Sending result to output:", {
|
|
49
|
+
stringSession,
|
|
50
|
+
messages: [
|
|
51
|
+
{ type: "auth_success", text: "Authorization successful!" },
|
|
52
|
+
{ type: "session_token", text: "Copy this stringSession to use in other nodes." }
|
|
53
|
+
]
|
|
36
54
|
});
|
|
37
55
|
|
|
38
|
-
const stringSession = client.session.save(); // Save session
|
|
39
56
|
node.send({
|
|
40
57
|
topic: "auth_success",
|
|
41
58
|
payload: {
|
|
42
59
|
stringSession,
|
|
43
|
-
message: "Authorization successful!"
|
|
44
|
-
}
|
|
60
|
+
message: "Authorization successful!"
|
|
61
|
+
}
|
|
45
62
|
});
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
63
|
+
|
|
64
|
+
node.status({ fill: "green", shape: "dot", text: "Authenticated" });
|
|
65
|
+
|
|
66
|
+
} catch (err) {
|
|
67
|
+
node.error("Authentication failed: " + err.message);
|
|
49
68
|
node.send({
|
|
50
69
|
topic: "auth_error",
|
|
51
|
-
payload: {
|
|
52
|
-
error: error.message,
|
|
53
|
-
},
|
|
70
|
+
payload: { error: err.message },
|
|
54
71
|
});
|
|
72
|
+
node.status({ fill: "red", shape: "ring", text: "Failed" });
|
|
55
73
|
}
|
|
56
74
|
});
|
|
57
75
|
}
|
package/nodes/command.html
CHANGED
|
@@ -3,19 +3,18 @@
|
|
|
3
3
|
category: 'telegram-account',
|
|
4
4
|
color: '#229ED9',
|
|
5
5
|
icon: 'tg.png',
|
|
6
|
-
align:"right",
|
|
7
6
|
defaults: {
|
|
8
7
|
name: { value: '' },
|
|
9
8
|
config: { type: 'config', required: false },
|
|
10
|
-
command: { value: "", required:true },
|
|
11
|
-
regex:{ value:false }
|
|
9
|
+
command: { value: "", required: true },
|
|
10
|
+
regex: { value: false }
|
|
12
11
|
},
|
|
13
12
|
inputs: 1,
|
|
14
13
|
outputs: 1,
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
14
|
+
paletteLabel: 'command',
|
|
15
|
+
label: function() {
|
|
16
|
+
return this.name||'command';
|
|
17
|
+
}
|
|
19
18
|
});
|
|
20
19
|
</script>
|
|
21
20
|
|
package/nodes/config.html
CHANGED
package/nodes/config.js
CHANGED
|
@@ -1,58 +1,54 @@
|
|
|
1
1
|
const { TelegramClient } = require("telegram");
|
|
2
2
|
const { StringSession } = require("telegram/sessions");
|
|
3
3
|
|
|
4
|
+
const activeClients = {}; // Cache: session string → connected client
|
|
5
|
+
|
|
4
6
|
module.exports = function (RED) {
|
|
5
7
|
function TelegramClientConfig(config) {
|
|
6
8
|
RED.nodes.createNode(this, config);
|
|
7
|
-
this.apiId = config.api_id;
|
|
8
|
-
this.apiHash = config.api_hash;
|
|
9
|
-
this.session = new StringSession(config.session);
|
|
10
|
-
this.useIPV6 = config.useIPV6;
|
|
11
|
-
this.timeout = config.timeout;
|
|
12
|
-
this.requestRetries = config.requestRetries;
|
|
13
|
-
this.connectionRetries = config.connectionRetries;
|
|
14
|
-
this.proxy = config.proxy;
|
|
15
|
-
this.downloadRetries = config.downloadRetries;
|
|
16
|
-
this.retryDelay = config.retryDelay;
|
|
17
|
-
this.autoReconnect = config.autoReconnect;
|
|
18
|
-
this.sequentialUpdates = config.sequentialUpdates;
|
|
19
|
-
this.floodSleepThreshold = config.floodSleepThreshold;
|
|
20
|
-
this.deviceModel = config.deviceModel;
|
|
21
|
-
this.systemVersion = config.systemVersion;
|
|
22
|
-
this.appVersion = config.appVersion;
|
|
23
|
-
this.langCode = config.langCode;
|
|
24
|
-
this.systemLangCode = config.systemLangCode;
|
|
25
|
-
this.useWSS = config.useWSS;
|
|
26
|
-
this.maxConcurrentDownloads = config.maxConcurrentDownloads;
|
|
27
|
-
this.securityChecks = config.securityChecks;
|
|
28
|
-
this.testServers = config.testServers;
|
|
29
|
-
const node = this;
|
|
30
9
|
|
|
10
|
+
const sessionStr = config.session;
|
|
11
|
+
const apiId = parseInt(config.api_id);
|
|
12
|
+
const apiHash = config.api_hash;
|
|
31
13
|
|
|
32
|
-
this.
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
14
|
+
this.session = new StringSession(sessionStr);
|
|
15
|
+
this.client = null;
|
|
16
|
+
|
|
17
|
+
const node = this;
|
|
18
|
+
|
|
19
|
+
if (activeClients[sessionStr]) {
|
|
20
|
+
// Reuse existing client
|
|
21
|
+
this.client = activeClients[sessionStr];
|
|
22
|
+
node.status({ fill: "green", shape: "dot", text: "Reused existing client" });
|
|
23
|
+
} else {
|
|
24
|
+
// Create and connect new client
|
|
25
|
+
this.client = new TelegramClient(this.session, apiId, apiHash, {
|
|
26
|
+
connectionRetries: config.connectionRetries || 5,
|
|
27
|
+
autoReconnect: config.autoReconnect !== false,
|
|
28
|
+
requestRetries: config.requestRetries || 5,
|
|
29
|
+
});
|
|
36
30
|
|
|
37
|
-
try {
|
|
38
31
|
this.client.connect().then(async () => {
|
|
39
|
-
|
|
40
|
-
if (!
|
|
41
|
-
node.error(
|
|
32
|
+
const authorized = await this.client.isUserAuthorized();
|
|
33
|
+
if (!authorized) {
|
|
34
|
+
node.error("Session is invalid");
|
|
42
35
|
} else {
|
|
43
36
|
node.status({ fill: "green", shape: "dot", text: "Connected" });
|
|
37
|
+
activeClients[sessionStr] = this.client;
|
|
44
38
|
}
|
|
39
|
+
}).catch(err => {
|
|
40
|
+
node.error("Connection error: " + err.message);
|
|
45
41
|
});
|
|
46
|
-
} catch (err) {
|
|
47
|
-
node.error('Authorisation error: ' + err.message);
|
|
48
42
|
}
|
|
49
43
|
|
|
50
|
-
this.on("close", () => {
|
|
51
|
-
if (this.client) {
|
|
52
|
-
this.client.disconnect();
|
|
44
|
+
this.on("close", async () => {
|
|
45
|
+
if (this.client && activeClients[sessionStr] === this.client) {
|
|
46
|
+
await this.client.disconnect();
|
|
47
|
+
delete activeClients[sessionStr];
|
|
53
48
|
node.status({ fill: "red", shape: "ring", text: "Disconnected" });
|
|
54
49
|
}
|
|
55
50
|
});
|
|
56
51
|
}
|
|
52
|
+
|
|
57
53
|
RED.nodes.registerType('config', TelegramClientConfig);
|
|
58
54
|
};
|
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
<script type="text/javascript">
|
|
2
2
|
RED.nodes.registerType('delete-message', {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
3
|
+
category: 'telegram-account',
|
|
4
|
+
color: '#FF5733',
|
|
5
|
+
icon: 'tg.png',
|
|
6
|
+
align: 'right',
|
|
7
|
+
defaults: {
|
|
8
|
+
name: { value: '' },
|
|
9
|
+
config: { type: 'config', required: false },
|
|
10
|
+
},
|
|
11
|
+
inputs: 1,
|
|
12
|
+
outputs: 1,
|
|
13
|
+
paletteLabel: 'delete message',
|
|
14
|
+
label: function() {
|
|
15
|
+
return this.name||'delete message';
|
|
16
|
+
}
|
|
16
17
|
});
|
|
17
18
|
</script>
|
|
18
19
|
|
package/nodes/get-entity.html
CHANGED
|
@@ -3,15 +3,16 @@
|
|
|
3
3
|
category: 'telegram-account',
|
|
4
4
|
color: '#229ED9',
|
|
5
5
|
icon: 'tg.png',
|
|
6
|
-
align:
|
|
6
|
+
align: 'right',
|
|
7
7
|
defaults: {
|
|
8
8
|
name: { value: '' },
|
|
9
9
|
config: { type: 'config', required: false },
|
|
10
10
|
},
|
|
11
11
|
inputs: 1,
|
|
12
12
|
outputs: 1,
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
paletteLabel: 'get entity',
|
|
14
|
+
label: function() {
|
|
15
|
+
return this.name||'get entity';
|
|
15
16
|
}
|
|
16
17
|
});
|
|
17
18
|
</script>
|
|
Binary file
|
package/nodes/iter-dialogs.html
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
RED.nodes.registerType('iter-dialogs', {
|
|
3
3
|
category: 'telegram-account',
|
|
4
4
|
color: '#32a3e0',
|
|
5
|
+
icon: 'tg.png',
|
|
6
|
+
align: 'right',
|
|
5
7
|
defaults: {
|
|
6
8
|
name: { value: '' },
|
|
7
9
|
config: { type: 'config', required: true },
|
|
@@ -15,10 +17,10 @@
|
|
|
15
17
|
},
|
|
16
18
|
inputs: 1,
|
|
17
19
|
outputs: 1,
|
|
18
|
-
paletteLabel: '
|
|
19
|
-
label: function
|
|
20
|
-
return this.name
|
|
21
|
-
}
|
|
20
|
+
paletteLabel: 'iterate dialogs',
|
|
21
|
+
label: function() {
|
|
22
|
+
return this.name||'iterate dialogs';
|
|
23
|
+
}
|
|
22
24
|
});
|
|
23
25
|
</script>
|
|
24
26
|
|
package/nodes/iter-messages.html
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
RED.nodes.registerType('iter-messages', {
|
|
3
3
|
category: 'telegram',
|
|
4
4
|
color: '#32a3e0',
|
|
5
|
+
icon: 'tg.png',
|
|
6
|
+
align: 'right',
|
|
5
7
|
defaults: {
|
|
6
8
|
name: { value: '' },
|
|
7
9
|
config: { type: 'config', required: true },
|
|
@@ -23,9 +25,9 @@
|
|
|
23
25
|
},
|
|
24
26
|
inputs: 1,
|
|
25
27
|
outputs: 1,
|
|
26
|
-
paletteLabel: '
|
|
27
|
-
label: function
|
|
28
|
-
return this.name
|
|
28
|
+
paletteLabel: 'iter messages',
|
|
29
|
+
label: function() {
|
|
30
|
+
return this.name||'iter messages';
|
|
29
31
|
},
|
|
30
32
|
oneditprepare: function(){
|
|
31
33
|
const node = this;
|
package/nodes/promote-admin.html
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
category: 'telegram-account',
|
|
4
4
|
color: '#229ED9',
|
|
5
5
|
icon: 'tg.png',
|
|
6
|
-
align:
|
|
6
|
+
align: 'right',
|
|
7
7
|
defaults: {
|
|
8
8
|
name: { value: '' },
|
|
9
9
|
config: { type: 'config', required: false },
|
|
@@ -24,8 +24,9 @@
|
|
|
24
24
|
},
|
|
25
25
|
inputs: 1,
|
|
26
26
|
outputs: 1,
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
paletteLabel: 'promote admin',
|
|
28
|
+
label: function() {
|
|
29
|
+
return this.name||'promote admin';
|
|
29
30
|
},
|
|
30
31
|
oneditprepare: function () {
|
|
31
32
|
// No extra logic needed
|
package/nodes/receiver.html
CHANGED
|
@@ -1,20 +1,19 @@
|
|
|
1
1
|
<script type="text/javascript">
|
|
2
2
|
RED.nodes.registerType('receiver', {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
3
|
+
category: 'telegram-account',
|
|
4
|
+
color: '#229ED9',
|
|
5
|
+
icon: 'tg.png',
|
|
6
|
+
defaults: {
|
|
7
|
+
name: { value: '' },
|
|
8
|
+
config: { type: 'config', required: false },
|
|
9
|
+
ignore: { value:""}
|
|
10
|
+
},
|
|
11
|
+
inputs: 1,
|
|
12
|
+
outputs: 1,
|
|
13
|
+
paletteLabel: 'receiver',
|
|
14
|
+
label: function() {
|
|
15
|
+
return this.name||'receiver';
|
|
16
|
+
}
|
|
18
17
|
});
|
|
19
18
|
</script>
|
|
20
19
|
|
package/nodes/send-file.html
CHANGED
|
@@ -30,11 +30,12 @@
|
|
|
30
30
|
},
|
|
31
31
|
inputs: 1,
|
|
32
32
|
outputs: 1,
|
|
33
|
-
icon: '
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
33
|
+
icon: 'tg.png',
|
|
34
|
+
align: 'right',
|
|
35
|
+
paletteLabel: 'send file',
|
|
36
|
+
label: function() {
|
|
37
|
+
return this.name||'send file';
|
|
38
|
+
}
|
|
38
39
|
});
|
|
39
40
|
</script>
|
|
40
41
|
|
package/nodes/send-message.html
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
category: 'telegram-account',
|
|
4
4
|
color: '#229ED9',
|
|
5
5
|
icon: 'tg.png',
|
|
6
|
-
align:
|
|
6
|
+
align: 'right',
|
|
7
7
|
defaults: {
|
|
8
8
|
name: { value: '' },
|
|
9
9
|
chatId: { value: '' },
|
|
@@ -28,8 +28,9 @@
|
|
|
28
28
|
},
|
|
29
29
|
inputs: 1,
|
|
30
30
|
outputs: 1,
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
paletteLabel: 'send message',
|
|
32
|
+
label: function() {
|
|
33
|
+
return this.name||'send message';
|
|
33
34
|
},
|
|
34
35
|
oneditprepare: function () {
|
|
35
36
|
const node = this;
|
package/package.json
CHANGED
|
Binary file
|
package/icons/tg.png
DELETED
|
Binary file
|