@patricktobias86/node-red-telegram-account 1.0.9 → 1.1.2
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/.editorconfig +12 -0
- package/nodes/auth.html +47 -60
- package/nodes/auth.js +36 -24
- package/nodes/command.html +3 -4
- package/nodes/config.html +1 -1
- package/nodes/config.js +32 -36
- package/nodes/delete-message.html +1 -2
- package/nodes/get-entity.html +1 -2
- package/nodes/icons/tg.png +0 -0
- package/nodes/iter-dialogs.html +3 -2
- package/nodes/iter-messages.html +3 -2
- package/nodes/promote-admin.html +135 -20
- package/nodes/promote-admin.js +1 -2
- package/nodes/receiver.html +1 -2
- package/nodes/send-file.html +3 -3
- package/nodes/send-message.html +1 -2
- package/package.json +1 -1
- package/.vscode/settings.json +0 -4
- package/icons/tg.png +0 -0
package/.editorconfig
ADDED
package/nodes/auth.html
CHANGED
|
@@ -3,26 +3,24 @@
|
|
|
3
3
|
category: 'telegram-account',
|
|
4
4
|
color: '#a6bbcf',
|
|
5
5
|
defaults: {
|
|
6
|
-
api_id: { value: ""
|
|
7
|
-
api_hash: { value: ""
|
|
8
|
-
phoneNumber: { value: ""
|
|
9
|
-
password: { value: "" }
|
|
6
|
+
api_id: { value: "" },
|
|
7
|
+
api_hash: { value: "" },
|
|
8
|
+
phoneNumber: { value: "" },
|
|
9
|
+
password: { value: "" }
|
|
10
10
|
},
|
|
11
11
|
inputs: 1,
|
|
12
12
|
outputs: 1,
|
|
13
|
-
icon:
|
|
14
|
-
|
|
15
|
-
return this.name || "Telegram Auth";
|
|
16
|
-
},
|
|
13
|
+
icon: 'tg.png',
|
|
14
|
+
paletteLabel: 'user auth',
|
|
17
15
|
oneditprepare: function () {
|
|
18
|
-
//
|
|
16
|
+
// Initialize values
|
|
19
17
|
$("#node-input-api_id").val(this.api_id || "");
|
|
20
18
|
$("#node-input-api_hash").val(this.api_hash || "");
|
|
21
19
|
$("#node-input-phoneNumber").val(this.phoneNumber || "");
|
|
22
20
|
$("#node-input-password").val(this.password || "");
|
|
23
21
|
},
|
|
24
22
|
oneditsave: function () {
|
|
25
|
-
//
|
|
23
|
+
// Save values
|
|
26
24
|
this.api_id = $("#node-input-api_id").val();
|
|
27
25
|
this.api_hash = $("#node-input-api_hash").val();
|
|
28
26
|
this.phoneNumber = $("#node-input-phoneNumber").val();
|
|
@@ -61,78 +59,67 @@
|
|
|
61
59
|
</div>
|
|
62
60
|
|
|
63
61
|
<p>
|
|
64
|
-
<strong>Note:</strong>
|
|
62
|
+
<strong>Note:</strong> These values are used to create a Telegram session string.
|
|
65
63
|
</p>
|
|
66
64
|
</script>
|
|
67
65
|
|
|
68
|
-
|
|
69
66
|
<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
|
|
67
|
+
<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
68
|
|
|
72
69
|
<h3>Inputs</h3>
|
|
73
70
|
<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>
|
|
71
|
+
<dt>payload.api_id <span class="property-type">number | string</span></dt>
|
|
72
|
+
<dd>The Telegram API ID.</dd>
|
|
73
|
+
|
|
74
|
+
<dt>payload.api_hash <span class="property-type">string</span></dt>
|
|
75
|
+
<dd>The Telegram API hash.</dd>
|
|
76
|
+
|
|
77
|
+
<dt>payload.phoneNumber <span class="property-type">string</span></dt>
|
|
78
|
+
<dd>The phone number of the Telegram account, including country code (e.g. +1701234567).</dd>
|
|
79
|
+
|
|
80
|
+
<dt>payload.password <span class="property-type">string</span></dt>
|
|
81
|
+
<dd>(Optional) The password for two-factor authentication.</dd>
|
|
93
82
|
</dl>
|
|
94
83
|
|
|
84
|
+
<h3>Behavior</h3>
|
|
85
|
+
<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>
|
|
86
|
+
<p>To complete authentication, you must send the code using a function node like this:</p>
|
|
87
|
+
<pre>
|
|
88
|
+
const code = msg.payload.code;
|
|
89
|
+
const wait = flow.get("waitForCode");
|
|
90
|
+
if (typeof wait === "function") {
|
|
91
|
+
wait(code);
|
|
92
|
+
flow.set("waitForCode", null);
|
|
93
|
+
}
|
|
94
|
+
</pre>
|
|
95
|
+
|
|
95
96
|
<h3>Outputs</h3>
|
|
96
97
|
<dl class="message-properties">
|
|
97
|
-
<dt>topic
|
|
98
|
-
<span class="property-type">string</span>
|
|
99
|
-
</dt>
|
|
98
|
+
<dt>topic <span class="property-type">string</span></dt>
|
|
100
99
|
<dd>
|
|
101
|
-
- <b>"auth_success"</b>:
|
|
102
|
-
- <b>"auth_error"</b>:
|
|
100
|
+
- <b>"auth_success"</b>: Login succeeded.<br>
|
|
101
|
+
- <b>"auth_error"</b>: Login failed.
|
|
103
102
|
</dd>
|
|
104
103
|
|
|
105
|
-
<dt>payload
|
|
106
|
-
<span class="property-type">object</span>
|
|
107
|
-
</dt>
|
|
104
|
+
<dt>payload <span class="property-type">object</span></dt>
|
|
108
105
|
<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
106
|
<ul>
|
|
116
|
-
<li><code>
|
|
107
|
+
<li><code>stringSession</code>: The generated session string to reuse in your bots.</li>
|
|
108
|
+
<li><code>message</code> or <code>error</code>: Additional info.</li>
|
|
117
109
|
</ul>
|
|
118
110
|
</dd>
|
|
119
111
|
</dl>
|
|
120
112
|
|
|
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
113
|
<h3>Example</h3>
|
|
127
114
|
<pre>
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
}
|
|
115
|
+
{
|
|
116
|
+
"payload": {
|
|
117
|
+
"api_id": "123456",
|
|
118
|
+
"api_hash": "your_api_hash",
|
|
119
|
+
"phoneNumber": "+46701234567",
|
|
120
|
+
"password": "optional_password"
|
|
135
121
|
}
|
|
122
|
+
}
|
|
136
123
|
</pre>
|
|
137
|
-
<p>
|
|
124
|
+
<p>Use a separate node to submit the received code after triggering this payload.</p>
|
|
138
125
|
</script>
|
package/nodes/auth.js
CHANGED
|
@@ -7,51 +7,63 @@ 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),
|
|
36
44
|
});
|
|
37
45
|
|
|
38
|
-
const stringSession = client.session.save();
|
|
46
|
+
const stringSession = client.session.save();
|
|
39
47
|
node.send({
|
|
40
|
-
topic: "
|
|
48
|
+
topic: "auth_complete",
|
|
41
49
|
payload: {
|
|
42
50
|
stringSession,
|
|
43
|
-
|
|
44
|
-
|
|
51
|
+
messages: [
|
|
52
|
+
{ type: "auth_success", text: "Authorization successful!" },
|
|
53
|
+
{ type: "session_token", text: "Copy this stringSession to use in other nodes." }
|
|
54
|
+
]
|
|
55
|
+
}
|
|
45
56
|
});
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
57
|
+
|
|
58
|
+
node.status({ fill: "green", shape: "dot", text: "Authenticated" });
|
|
59
|
+
|
|
60
|
+
} catch (err) {
|
|
61
|
+
node.error("Authentication failed: " + err.message);
|
|
49
62
|
node.send({
|
|
50
63
|
topic: "auth_error",
|
|
51
|
-
payload: {
|
|
52
|
-
error: error.message,
|
|
53
|
-
},
|
|
64
|
+
payload: { error: err.message },
|
|
54
65
|
});
|
|
66
|
+
node.status({ fill: "red", shape: "ring", text: "Failed" });
|
|
55
67
|
}
|
|
56
68
|
});
|
|
57
69
|
}
|
package/nodes/command.html
CHANGED
|
@@ -3,17 +3,16 @@
|
|
|
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
14
|
label: function () {
|
|
16
|
-
return this.name || '
|
|
15
|
+
return this.name || 'command';
|
|
17
16
|
},
|
|
18
17
|
|
|
19
18
|
});
|
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
|
};
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
category: 'telegram-account',
|
|
4
4
|
color: '#FF5733',
|
|
5
5
|
icon: 'tg.png',
|
|
6
|
-
align: 'right',
|
|
7
6
|
defaults: {
|
|
8
7
|
name: { value: '' },
|
|
9
8
|
config: { type: 'config', required: false },
|
|
@@ -11,7 +10,7 @@
|
|
|
11
10
|
inputs: 1,
|
|
12
11
|
outputs: 1,
|
|
13
12
|
label: function () {
|
|
14
|
-
return this.name || '
|
|
13
|
+
return this.name || 'delete message';
|
|
15
14
|
},
|
|
16
15
|
});
|
|
17
16
|
</script>
|
package/nodes/get-entity.html
CHANGED
|
@@ -3,7 +3,6 @@
|
|
|
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 },
|
|
@@ -11,7 +10,7 @@
|
|
|
11
10
|
inputs: 1,
|
|
12
11
|
outputs: 1,
|
|
13
12
|
label: function () {
|
|
14
|
-
return this.name || '
|
|
13
|
+
return this.name || 'get entity';
|
|
15
14
|
}
|
|
16
15
|
});
|
|
17
16
|
</script>
|
|
Binary file
|
package/nodes/iter-dialogs.html
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
RED.nodes.registerType('iter-dialogs', {
|
|
3
3
|
category: 'telegram-account',
|
|
4
4
|
color: '#32a3e0',
|
|
5
|
+
icon: 'tg.png',
|
|
5
6
|
defaults: {
|
|
6
7
|
name: { value: '' },
|
|
7
8
|
config: { type: 'config', required: true },
|
|
@@ -15,9 +16,9 @@
|
|
|
15
16
|
},
|
|
16
17
|
inputs: 1,
|
|
17
18
|
outputs: 1,
|
|
18
|
-
paletteLabel: '
|
|
19
|
+
paletteLabel: 'iterate dialogs',
|
|
19
20
|
label: function () {
|
|
20
|
-
return this.name || '
|
|
21
|
+
return this.name || 'iterate dialogs';
|
|
21
22
|
},
|
|
22
23
|
});
|
|
23
24
|
</script>
|
package/nodes/iter-messages.html
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
RED.nodes.registerType('iter-messages', {
|
|
3
3
|
category: 'telegram',
|
|
4
4
|
color: '#32a3e0',
|
|
5
|
+
icon: 'tg.png',
|
|
5
6
|
defaults: {
|
|
6
7
|
name: { value: '' },
|
|
7
8
|
config: { type: 'config', required: true },
|
|
@@ -23,9 +24,9 @@
|
|
|
23
24
|
},
|
|
24
25
|
inputs: 1,
|
|
25
26
|
outputs: 1,
|
|
26
|
-
paletteLabel: '
|
|
27
|
+
paletteLabel: 'iterate messages',
|
|
27
28
|
label: function () {
|
|
28
|
-
return this.name || '
|
|
29
|
+
return this.name || 'iterate messages';
|
|
29
30
|
},
|
|
30
31
|
oneditprepare: function(){
|
|
31
32
|
const node = this;
|
package/nodes/promote-admin.html
CHANGED
|
@@ -3,13 +3,12 @@
|
|
|
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
9
|
chatId: { value: '' },
|
|
11
10
|
userId: { value: '' },
|
|
12
|
-
rank: { value: '
|
|
11
|
+
rank: { value: 'admin' },
|
|
13
12
|
changeInfo: { value: true },
|
|
14
13
|
postMessages: { value: true },
|
|
15
14
|
editMessages: { value: true },
|
|
@@ -25,7 +24,7 @@
|
|
|
25
24
|
inputs: 1,
|
|
26
25
|
outputs: 1,
|
|
27
26
|
label: function () {
|
|
28
|
-
return this.name || '
|
|
27
|
+
return this.name || 'promote admin';
|
|
29
28
|
},
|
|
30
29
|
oneditprepare: function () {
|
|
31
30
|
// No extra logic needed
|
|
@@ -44,7 +43,7 @@
|
|
|
44
43
|
</div>
|
|
45
44
|
|
|
46
45
|
<div class="form-row">
|
|
47
|
-
<label for="node-input-chatId"><i class="fa fa-users"></i>
|
|
46
|
+
<label for="node-input-chatId"><i class="fa fa-users"></i> Chat ID</label>
|
|
48
47
|
<input type="text" id="node-input-chatId" placeholder="@groupname or ID">
|
|
49
48
|
</div>
|
|
50
49
|
|
|
@@ -55,24 +54,140 @@
|
|
|
55
54
|
|
|
56
55
|
<div class="form-row">
|
|
57
56
|
<label for="node-input-rank"><i class="fa fa-star"></i> Admin Rank</label>
|
|
58
|
-
<input type="text" id="node-input-rank" placeholder="e.g.
|
|
57
|
+
<input type="text" id="node-input-rank" placeholder="e.g. admin">
|
|
59
58
|
</div>
|
|
60
59
|
|
|
61
|
-
|
|
62
|
-
|
|
60
|
+
<div id="node-input-permissions-container" class="red-ui-treeList" tabindex="0" style="width: 100%; height: 100%;">
|
|
61
|
+
<div class="red-ui-treeList-container">
|
|
62
|
+
<div class="red-ui-editableList" style="inset: 0px; position: absolute;">
|
|
63
|
+
<div class="red-ui-editableList-border red-ui-editableList-container" style="inset: 0px; position: absolute; max-height: none; overflow-y: auto;">
|
|
64
|
+
<ol class="red-ui-treeList-list red-ui-editableList-list" style="position: static; inset: auto; height: auto;">
|
|
65
|
+
<li>
|
|
66
|
+
<div class="red-ui-editableList-item-content">
|
|
67
|
+
<div class="red-ui-treeList-label" style="justify-content: flex-start;">
|
|
68
|
+
<span class="red-ui-treeList-icon" style="width: unset; text-align: left; display: inline-flex;">
|
|
69
|
+
<input class="red-ui-treeList-checkbox" style="margin: 5px 5px 10px 5px;" type="checkbox" id="node-input-changeInfo">
|
|
70
|
+
<label for="node-input-changeInfo">Can change group info</label>
|
|
71
|
+
</span>
|
|
72
|
+
</div>
|
|
73
|
+
</div>
|
|
74
|
+
</li>
|
|
75
|
+
|
|
76
|
+
<li>
|
|
77
|
+
<div class="red-ui-editableList-item-content">
|
|
78
|
+
<div class="red-ui-treeList-label" style="justify-content: flex-start;">
|
|
79
|
+
<span class="red-ui-treeList-icon" style="width: unset; text-align: left; display: inline-flex;">
|
|
80
|
+
<input class="red-ui-treeList-checkbox" style="margin: 5px 5px 10px 5px;" type="checkbox" id="node-input-postMessages">
|
|
81
|
+
<label for="node-input-postMessages">Can post messages</label>
|
|
82
|
+
</span>
|
|
83
|
+
</div>
|
|
84
|
+
</div>
|
|
85
|
+
</li>
|
|
86
|
+
<li>
|
|
87
|
+
<div class="red-ui-editableList-item-content">
|
|
88
|
+
<div class="red-ui-treeList-label" style="justify-content: flex-start;">
|
|
89
|
+
<span class="red-ui-treeList-icon" style="width: unset; text-align: left; display: inline-flex;">
|
|
90
|
+
<input class="red-ui-treeList-checkbox" style="margin: 5px 5px 10px 5px;" type="checkbox" id="node-input-editMessages">
|
|
91
|
+
<label for="node-input-editMessages">Can edit messages</label>
|
|
92
|
+
</span>
|
|
93
|
+
</div>
|
|
94
|
+
</div>
|
|
95
|
+
</li>
|
|
96
|
+
|
|
97
|
+
<li>
|
|
98
|
+
<div class="red-ui-editableList-item-content">
|
|
99
|
+
<div class="red-ui-treeList-label" style="justify-content: flex-start;">
|
|
100
|
+
<span class="red-ui-treeList-icon" style="width: unset; text-align: left; display: inline-flex;">
|
|
101
|
+
<input class="red-ui-treeList-checkbox" style="margin: 5px 5px 10px 5px;" type="checkbox" id="node-input-deleteMessages">
|
|
102
|
+
<label for="node-input-deleteMessages">Can delete messages</label>
|
|
103
|
+
</span>
|
|
104
|
+
</div>
|
|
105
|
+
</div>
|
|
106
|
+
</li>
|
|
107
|
+
|
|
108
|
+
<li>
|
|
109
|
+
<div class="red-ui-editableList-item-content">
|
|
110
|
+
<div class="red-ui-treeList-label" style="justify-content: flex-start;">
|
|
111
|
+
<span class="red-ui-treeList-icon" style="width: unset; text-align: left; display: inline-flex;">
|
|
112
|
+
<input class="red-ui-treeList-checkbox" style="margin: 5px 5px 10px 5px;" type="checkbox" id="node-input-banUsers">
|
|
113
|
+
<label for="node-input-banUsers">Can ban users</label>
|
|
114
|
+
</span>
|
|
115
|
+
</div>
|
|
116
|
+
</div>
|
|
117
|
+
</li>
|
|
118
|
+
|
|
119
|
+
<li>
|
|
120
|
+
<div class="red-ui-editableList-item-content">
|
|
121
|
+
<div class="red-ui-treeList-label" style="justify-content: flex-start;">
|
|
122
|
+
<span class="red-ui-treeList-icon" style="width: unset; text-align: left; display: inline-flex;">
|
|
123
|
+
<input class="red-ui-treeList-checkbox" style="margin: 5px 5px 10px 5px;" type="checkbox" id="node-input-inviteUsers">
|
|
124
|
+
<label for="node-input-inviteUsers">Can invite users</label>
|
|
125
|
+
</span>
|
|
126
|
+
</div>
|
|
127
|
+
</div>
|
|
128
|
+
</li>
|
|
129
|
+
|
|
130
|
+
<li>
|
|
131
|
+
<div class="red-ui-editableList-item-content">
|
|
132
|
+
<div class="red-ui-treeList-label" style="justify-content: flex-start;">
|
|
133
|
+
<span class="red-ui-treeList-icon" style="width: unset; text-align: left; display: inline-flex;">
|
|
134
|
+
<input class="red-ui-treeList-checkbox" style="margin: 5px 5px 10px 5px;" type="checkbox" id="node-input-pinMessages">
|
|
135
|
+
<label for="node-input-pinMessages">Can pin messages</label>
|
|
136
|
+
</span>
|
|
137
|
+
</div>
|
|
138
|
+
</div>
|
|
139
|
+
</li>
|
|
140
|
+
|
|
141
|
+
<li>
|
|
142
|
+
<div class="red-ui-editableList-item-content">
|
|
143
|
+
<div class="red-ui-treeList-label" style="justify-content: flex-start;">
|
|
144
|
+
<span class="red-ui-treeList-icon" style="width: unset; text-align: left; display: inline-flex;">
|
|
145
|
+
<input class="red-ui-treeList-checkbox" style="margin: 5px 5px 10px 5px;" type="checkbox" id="node-input-addAdmins">
|
|
146
|
+
<label for="node-input-addAdmins">Can add new admins</label>
|
|
147
|
+
</span>
|
|
148
|
+
</div>
|
|
149
|
+
</div>
|
|
150
|
+
</li>
|
|
151
|
+
|
|
152
|
+
<li>
|
|
153
|
+
<div class="red-ui-editableList-item-content">
|
|
154
|
+
<div class="red-ui-treeList-label" style="justify-content: flex-start;">
|
|
155
|
+
<span class="red-ui-treeList-icon" style="width: unset; text-align: left; display: inline-flex;">
|
|
156
|
+
<input class="red-ui-treeList-checkbox" style="margin: 5px 5px 10px 5px;" type="checkbox" id="node-input-manageCall">
|
|
157
|
+
<label for="node-input-manageCall">Can manage voice/video chats</label>
|
|
158
|
+
</span>
|
|
159
|
+
</div>
|
|
160
|
+
</div>
|
|
161
|
+
</li>
|
|
162
|
+
|
|
163
|
+
<li>
|
|
164
|
+
<div class="red-ui-editableList-item-content">
|
|
165
|
+
<div class="red-ui-treeList-label" style="justify-content: flex-start;">
|
|
166
|
+
<span class="red-ui-treeList-icon" style="width: unset; text-align: left; display: inline-flex;">
|
|
167
|
+
<input class="red-ui-treeList-checkbox" style="margin: 5px 5px 10px 5px;" type="checkbox" id="node-input-anonymous">
|
|
168
|
+
<label for="node-input-anonymous">Is anonymous (hidden from group)</label>
|
|
169
|
+
</span>
|
|
170
|
+
</div>
|
|
171
|
+
</div>
|
|
172
|
+
</li>
|
|
173
|
+
|
|
174
|
+
<li>
|
|
175
|
+
<div class="red-ui-editableList-item-content">
|
|
176
|
+
<div class="red-ui-treeList-label" style="justify-content: flex-start;">
|
|
177
|
+
<span class="red-ui-treeList-icon" style="width: unset; text-align: left; display: inline-flex;">
|
|
178
|
+
<input class="red-ui-treeList-checkbox" style="margin: 5px 5px 10px 5px;" type="checkbox" id="node-input-manageTopics">
|
|
179
|
+
<label for="node-input-manageTopics">Can manage topics</label>
|
|
180
|
+
</span>
|
|
181
|
+
</div>
|
|
182
|
+
</div>
|
|
183
|
+
</li>
|
|
184
|
+
|
|
185
|
+
</ol>
|
|
186
|
+
</div>
|
|
187
|
+
</div>
|
|
188
|
+
</div>
|
|
189
|
+
</div>
|
|
63
190
|
|
|
64
|
-
<div><input type="checkbox" id="node-input-changeInfo"> <label for="node-input-changeInfo">Can change group info</label></div>
|
|
65
|
-
<div><input type="checkbox" id="node-input-postMessages"> <label for="node-input-postMessages">Can post messages</label></div>
|
|
66
|
-
<div><input type="checkbox" id="node-input-editMessages"> <label for="node-input-editMessages">Can edit messages</label></div>
|
|
67
|
-
<div><input type="checkbox" id="node-input-deleteMessages"> <label for="node-input-deleteMessages">Can delete messages</label></div>
|
|
68
|
-
<div><input type="checkbox" id="node-input-banUsers"> <label for="node-input-banUsers">Can ban users</label></div>
|
|
69
|
-
<div><input type="checkbox" id="node-input-inviteUsers"> <label for="node-input-inviteUsers">Can invite users</label></div>
|
|
70
|
-
<div><input type="checkbox" id="node-input-pinMessages"> <label for="node-input-pinMessages">Can pin messages</label></div>
|
|
71
|
-
<div><input type="checkbox" id="node-input-addAdmins"> <label for="node-input-addAdmins">Can add new admins</label></div>
|
|
72
|
-
<div><input type="checkbox" id="node-input-manageCall"> <label for="node-input-manageCall">Can manage voice/video chats</label></div>
|
|
73
|
-
<div><input type="checkbox" id="node-input-anonymous"> <label for="node-input-anonymous">Is anonymous (hidden from group)</label></div>
|
|
74
|
-
<div><input type="checkbox" id="node-input-manageTopics"> <label for="node-input-manageTopics">Can manage topics</label></div>
|
|
75
|
-
</fieldset>
|
|
76
191
|
</script>
|
|
77
192
|
<script type="text/html" data-help-name="promote-admin">
|
|
78
193
|
<p><b>Promote Admin</b> lets you promote a user to admin in a Telegram group or channel using the Telegram MTProto API (via GramJS).</p>
|
|
@@ -120,7 +235,7 @@
|
|
|
120
235
|
"payload": {
|
|
121
236
|
"chatId": "@mygroup",
|
|
122
237
|
"userId": "@targetuser",
|
|
123
|
-
"rank": "
|
|
238
|
+
"rank": "admin",
|
|
124
239
|
"banUsers": true,
|
|
125
240
|
"pinMessages": true
|
|
126
241
|
}
|
package/nodes/promote-admin.js
CHANGED
|
@@ -10,10 +10,9 @@ module.exports = function (RED) {
|
|
|
10
10
|
|
|
11
11
|
this.on('input', async function (msg) {
|
|
12
12
|
const client = msg.payload?.client || this.config.client;
|
|
13
|
-
|
|
14
13
|
const chatId = msg.payload.chatId || config.chatId;
|
|
15
14
|
const userId = msg.payload.userId || config.userId;
|
|
16
|
-
const rank = msg.payload.rank || config.rank || "
|
|
15
|
+
const rank = msg.payload.rank || config.rank || "admin";
|
|
17
16
|
|
|
18
17
|
try {
|
|
19
18
|
const group = chatId[0] === "@" ? await client.getEntity(chatId) : parseID(chatId);
|
package/nodes/receiver.html
CHANGED
|
@@ -3,7 +3,6 @@
|
|
|
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 },
|
|
@@ -12,7 +11,7 @@
|
|
|
12
11
|
inputs: 1,
|
|
13
12
|
outputs: 1,
|
|
14
13
|
label: function () {
|
|
15
|
-
return this.name || '
|
|
14
|
+
return this.name || 'receiver';
|
|
16
15
|
},
|
|
17
16
|
|
|
18
17
|
});
|
package/nodes/send-file.html
CHANGED
|
@@ -30,10 +30,10 @@
|
|
|
30
30
|
},
|
|
31
31
|
inputs: 1,
|
|
32
32
|
outputs: 1,
|
|
33
|
-
icon: '
|
|
34
|
-
paletteLabel: '
|
|
33
|
+
icon: 'tg.png',
|
|
34
|
+
paletteLabel: 'send files',
|
|
35
35
|
label: function () {
|
|
36
|
-
return this.name || '
|
|
36
|
+
return this.name || 'send files';
|
|
37
37
|
},
|
|
38
38
|
});
|
|
39
39
|
</script>
|
package/nodes/send-message.html
CHANGED
|
@@ -3,7 +3,6 @@
|
|
|
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
|
chatId: { value: '' },
|
|
@@ -29,7 +28,7 @@
|
|
|
29
28
|
inputs: 1,
|
|
30
29
|
outputs: 1,
|
|
31
30
|
label: function () {
|
|
32
|
-
return this.name || '
|
|
31
|
+
return this.name || 'send message';
|
|
33
32
|
},
|
|
34
33
|
oneditprepare: function () {
|
|
35
34
|
const node = this;
|
package/package.json
CHANGED
package/.vscode/settings.json
DELETED
package/icons/tg.png
DELETED
|
Binary file
|