-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathReadHistory.json
More file actions
101 lines (101 loc) · 4.14 KB
/
Copy pathReadHistory.json
File metadata and controls
101 lines (101 loc) · 4.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
[
{
"id": "read_history_tab",
"type": "tab",
"label": "Read history",
"disabled": false,
"info": "Reads the last 50 messages of a chat and joins them back into one array.\n\nThe Function node in front sets msg.payload with the same settings the list node offers - Read, Read from, Limit and Output. What arrives with the message wins over what is configured, so one node can serve several reads. Delete the Function node and the node's own settings apply.\n\nThe list node streams one message per item, so a large history never has to fit in memory at once. The join node in automatic mode uses msg.parts, which the list node sets - count comes from Telegram's own total for the query, capped at the limit. Switching Output to array makes the list node send one message with everything, and then the join node has nothing to do.\n\nSet the Bot to your telegram client config node and inject. It reads your own Saved Messages, which every account has - put a username or a chat id in the Function node to read something else.\n\nMind the limit: 0 means no limit, which on a busy channel reads it back to the first message and can earn a FLOOD_WAIT."
},
{
"id": "history_trigger",
"type": "inject",
"z": "read_history_tab",
"name": "read it",
"props": [
{
"p": "payload"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 150,
"y": 120,
"wires": [["history_settings"]]
},
{
"id": "history_settings",
"type": "function",
"z": "read_history_tab",
"name": "what to read",
"func": "// Everything the list node offers in its dialog can also arrive with the message, and what arrives\n// wins over what is configured. So one configured node can serve a flow that reads different things,\n// and this Function node is where that choice lives.\n//\n// Leave a field out - or delete this node - to use the node's own settings instead.\nmsg.payload = {\n what: 'messages', // \"Read\": messages | dialogs | participants\n peer: 'me', // \"Read from\": a username, a chat id, or \"me\" for your own Saved Messages\n limit: 50, // \"Limit\": 0 means everything, which on a busy chat can earn a FLOOD_WAIT\n mode: 'stream', // \"Output\": stream = one message per item, array = one message with all of them\n // search: 'invoice', // only messages and participants can be searched\n};\n\nreturn msg;\n",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 330,
"y": 120,
"wires": [["history_read"]]
},
{
"id": "history_read",
"type": "telegram client list",
"z": "read_history_tab",
"name": "last 50 messages",
"bot": "",
"what": "messages",
"peer": "me",
"limit": "50",
"search": "",
"mode": "stream",
"x": 540,
"y": 120,
"wires": [["history_join"]]
},
{
"id": "history_join",
"type": "join",
"z": "read_history_tab",
"name": "back into one array",
"mode": "auto",
"build": "array",
"property": "payload",
"propertyType": "msg",
"key": "topic",
"joiner": "\\n",
"joinerType": "str",
"accumulate": false,
"timeout": "",
"count": "",
"reduceRight": false,
"reduceExp": "",
"reduceInit": "",
"reduceInitType": "",
"reduceFixup": "",
"x": 740,
"y": 120,
"wires": [["history_debug"]]
},
{
"id": "history_debug",
"type": "debug",
"z": "read_history_tab",
"name": "the messages",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"targetType": "msg",
"statusVal": "",
"statusType": "auto",
"x": 940,
"y": 120,
"wires": []
}
]