@patricktobias86/node-red-telegram-account 1.1.2 → 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 +14 -0
- package/nodes/auth.js +11 -5
- package/nodes/command.html +4 -4
- package/nodes/config.html +1 -1
- package/nodes/delete-message.html +14 -12
- package/nodes/get-entity.html +4 -2
- package/nodes/iter-dialogs.html +4 -3
- package/nodes/iter-messages.html +4 -3
- package/nodes/promote-admin.html +4 -2
- package/nodes/receiver.html +14 -14
- package/nodes/send-file.html +5 -4
- package/nodes/send-message.html +4 -2
- package/package.json +1 -1
- package/patricktobias86-node-red-telegram-account-1.1.3.tgz +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,6 +3,7 @@
|
|
|
3
3
|
category: 'telegram-account',
|
|
4
4
|
color: '#a6bbcf',
|
|
5
5
|
defaults: {
|
|
6
|
+
name: { value: "" },
|
|
6
7
|
api_id: { value: "" },
|
|
7
8
|
api_hash: { value: "" },
|
|
8
9
|
phoneNumber: { value: "" },
|
|
@@ -11,9 +12,14 @@
|
|
|
11
12
|
inputs: 1,
|
|
12
13
|
outputs: 1,
|
|
13
14
|
icon: 'tg.png',
|
|
15
|
+
align: 'right',
|
|
14
16
|
paletteLabel: 'user auth',
|
|
17
|
+
label: function() {
|
|
18
|
+
return this.name||'user auth';
|
|
19
|
+
},
|
|
15
20
|
oneditprepare: function () {
|
|
16
21
|
// Initialize values
|
|
22
|
+
$("#node-input-name").val(this.name || "");
|
|
17
23
|
$("#node-input-api_id").val(this.api_id || "");
|
|
18
24
|
$("#node-input-api_hash").val(this.api_hash || "");
|
|
19
25
|
$("#node-input-phoneNumber").val(this.phoneNumber || "");
|
|
@@ -21,6 +27,7 @@
|
|
|
21
27
|
},
|
|
22
28
|
oneditsave: function () {
|
|
23
29
|
// Save values
|
|
30
|
+
this.name = $("#node-input-name").val();
|
|
24
31
|
this.api_id = $("#node-input-api_id").val();
|
|
25
32
|
this.api_hash = $("#node-input-api_hash").val();
|
|
26
33
|
this.phoneNumber = $("#node-input-phoneNumber").val();
|
|
@@ -30,6 +37,12 @@
|
|
|
30
37
|
</script>
|
|
31
38
|
|
|
32
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>
|
|
33
46
|
<div class="form-row">
|
|
34
47
|
<label for="node-input-api_id">
|
|
35
48
|
<i class="fa fa-key"></i> API ID
|
|
@@ -90,6 +103,7 @@ const wait = flow.get("waitForCode");
|
|
|
90
103
|
if (typeof wait === "function") {
|
|
91
104
|
wait(code);
|
|
92
105
|
flow.set("waitForCode", null);
|
|
106
|
+
node.status({fill:"blue",shape:"ring",text:"Code sent!"});
|
|
93
107
|
}
|
|
94
108
|
</pre>
|
|
95
109
|
|
package/nodes/auth.js
CHANGED
|
@@ -44,14 +44,20 @@ module.exports = function (RED) {
|
|
|
44
44
|
});
|
|
45
45
|
|
|
46
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
|
+
]
|
|
54
|
+
});
|
|
55
|
+
|
|
47
56
|
node.send({
|
|
48
|
-
topic: "
|
|
57
|
+
topic: "auth_success",
|
|
49
58
|
payload: {
|
|
50
59
|
stringSession,
|
|
51
|
-
|
|
52
|
-
{ type: "auth_success", text: "Authorization successful!" },
|
|
53
|
-
{ type: "session_token", text: "Copy this stringSession to use in other nodes." }
|
|
54
|
-
]
|
|
60
|
+
message: "Authorization successful!"
|
|
55
61
|
}
|
|
56
62
|
});
|
|
57
63
|
|
package/nodes/command.html
CHANGED
package/nodes/config.html
CHANGED
|
@@ -1,17 +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
|
-
|
|
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
|
+
}
|
|
15
17
|
});
|
|
16
18
|
</script>
|
|
17
19
|
|
package/nodes/get-entity.html
CHANGED
|
@@ -3,14 +3,16 @@
|
|
|
3
3
|
category: 'telegram-account',
|
|
4
4
|
color: '#229ED9',
|
|
5
5
|
icon: 'tg.png',
|
|
6
|
+
align: 'right',
|
|
6
7
|
defaults: {
|
|
7
8
|
name: { value: '' },
|
|
8
9
|
config: { type: 'config', required: false },
|
|
9
10
|
},
|
|
10
11
|
inputs: 1,
|
|
11
12
|
outputs: 1,
|
|
12
|
-
|
|
13
|
-
|
|
13
|
+
paletteLabel: 'get entity',
|
|
14
|
+
label: function() {
|
|
15
|
+
return this.name||'get entity';
|
|
14
16
|
}
|
|
15
17
|
});
|
|
16
18
|
</script>
|
package/nodes/iter-dialogs.html
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
category: 'telegram-account',
|
|
4
4
|
color: '#32a3e0',
|
|
5
5
|
icon: 'tg.png',
|
|
6
|
+
align: 'right',
|
|
6
7
|
defaults: {
|
|
7
8
|
name: { value: '' },
|
|
8
9
|
config: { type: 'config', required: true },
|
|
@@ -17,9 +18,9 @@
|
|
|
17
18
|
inputs: 1,
|
|
18
19
|
outputs: 1,
|
|
19
20
|
paletteLabel: 'iterate dialogs',
|
|
20
|
-
label: function
|
|
21
|
-
return this.name
|
|
22
|
-
}
|
|
21
|
+
label: function() {
|
|
22
|
+
return this.name||'iterate dialogs';
|
|
23
|
+
}
|
|
23
24
|
});
|
|
24
25
|
</script>
|
|
25
26
|
|
package/nodes/iter-messages.html
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
category: 'telegram',
|
|
4
4
|
color: '#32a3e0',
|
|
5
5
|
icon: 'tg.png',
|
|
6
|
+
align: 'right',
|
|
6
7
|
defaults: {
|
|
7
8
|
name: { value: '' },
|
|
8
9
|
config: { type: 'config', required: true },
|
|
@@ -24,9 +25,9 @@
|
|
|
24
25
|
},
|
|
25
26
|
inputs: 1,
|
|
26
27
|
outputs: 1,
|
|
27
|
-
paletteLabel: '
|
|
28
|
-
label: function
|
|
29
|
-
return this.name
|
|
28
|
+
paletteLabel: 'iter messages',
|
|
29
|
+
label: function() {
|
|
30
|
+
return this.name||'iter messages';
|
|
30
31
|
},
|
|
31
32
|
oneditprepare: function(){
|
|
32
33
|
const node = this;
|
package/nodes/promote-admin.html
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
category: 'telegram-account',
|
|
4
4
|
color: '#229ED9',
|
|
5
5
|
icon: 'tg.png',
|
|
6
|
+
align: 'right',
|
|
6
7
|
defaults: {
|
|
7
8
|
name: { value: '' },
|
|
8
9
|
config: { type: 'config', required: false },
|
|
@@ -23,8 +24,9 @@
|
|
|
23
24
|
},
|
|
24
25
|
inputs: 1,
|
|
25
26
|
outputs: 1,
|
|
26
|
-
|
|
27
|
-
|
|
27
|
+
paletteLabel: 'promote admin',
|
|
28
|
+
label: function() {
|
|
29
|
+
return this.name||'promote admin';
|
|
28
30
|
},
|
|
29
31
|
oneditprepare: function () {
|
|
30
32
|
// No extra logic needed
|
package/nodes/receiver.html
CHANGED
|
@@ -1,19 +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
|
-
|
|
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
|
+
}
|
|
17
17
|
});
|
|
18
18
|
</script>
|
|
19
19
|
|
package/nodes/send-file.html
CHANGED
|
@@ -31,10 +31,11 @@
|
|
|
31
31
|
inputs: 1,
|
|
32
32
|
outputs: 1,
|
|
33
33
|
icon: 'tg.png',
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
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,6 +3,7 @@
|
|
|
3
3
|
category: 'telegram-account',
|
|
4
4
|
color: '#229ED9',
|
|
5
5
|
icon: 'tg.png',
|
|
6
|
+
align: 'right',
|
|
6
7
|
defaults: {
|
|
7
8
|
name: { value: '' },
|
|
8
9
|
chatId: { value: '' },
|
|
@@ -27,8 +28,9 @@
|
|
|
27
28
|
},
|
|
28
29
|
inputs: 1,
|
|
29
30
|
outputs: 1,
|
|
30
|
-
|
|
31
|
-
|
|
31
|
+
paletteLabel: 'send message',
|
|
32
|
+
label: function() {
|
|
33
|
+
return this.name||'send message';
|
|
32
34
|
},
|
|
33
35
|
oneditprepare: function () {
|
|
34
36
|
const node = this;
|
package/package.json
CHANGED
|
Binary file
|