-
-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathREADME.txt
More file actions
451 lines (315 loc) · 13.7 KB
/
README.txt
File metadata and controls
451 lines (315 loc) · 13.7 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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
━━━━━━━━━━
TG-FOCUS
micdeb
━━━━━━━━━━
Table of Contents
─────────────────
TG-Focus💡
Quickstart
TGFCMD Examples
Filters Rules
Contributing
FAQ
License
TG-Focus💡
══════════
<a
href="<https://github.com/micl2e2/tg-focus/blob/master/LICENSE-GPL>"></a>
<a href="<https://core.telegram.org/tdlib>"></a> <a
href="<https://github.com/tdlib/td>"></a>
tg-focus is a reliable <b>T</b>ele<b>g</b>ram message filter/forwarder
that helps you *focus*. A gentle user bot for message forwarding. Most
of message types are supported: public/private chats, channel updates,
and more.
With [TGFCMD], you have full control of the messages you'd see in a
dedicated chat *TG-FOCUS*.
Being built on top of [TDLib] directly, tg-focus is inherently as
consistent, reliable and stable as TDLib itself for most
Telegram-specific features.
The supported platforms are:
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
OS \ ARCH x86 64 aarch64
───────────────────────────────────────────
Linux ✅ ✅
Windows [WSL] ✅ ✅
macOS [Containerization] 🔨 🔨
Windows 🔨 🔨
BSD 🔨 🔨
macOS 🔨 🔨
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Supported(✅). Work In Progress(🔨).
[TGFCMD] See section Using TGFCMD
[TDLib] <https://core.telegram.org/tdlib/>
[WSL] <https://learn.microsoft.com/en-us/windows/wsl/install>
[Containerization]
<https://github.com/apple/container?tab=readme-ov-file#get-started>
Overhead
────────
In case someone cares about the overhead, here is a rough overview,
randomly captured after *~2 months* of uninterrupted running on a *1C
1G* machine: With *~500K* messages being filtered, it occupied *<1%*
of CPU and *<40%* of memory (TDLib included).
Quickstart
══════════
You can use [Docker] or [executable binaries] to get started.
[Docker] See section Using Docker/Podman
[executable binaries] See section Using Binaries
Using Docker/Podman
───────────────────
The following 5 steps will help you run tg-focus and filter some
specific messages.
1. Download the images:
┌────
│ docker pull micl2e2/tg-focus
└────
or
┌────
│ # if you use Podman rather than Docker
│ podman pull docker.io/micl2e2/tg-focus
│
│ # If you have trouble in reaching Docker Hub, try GitHub Package:
│ docker pull ghcr.io/micl2e2/tg-focus
│ # or
│ podman pull ghcr.io/micl2e2/tg-focus
└────
2. Run tg-focus:
┌────
│ docker run -d --name tgfocus micl2e2/tg-focus
└────
3. Log in your Telegram account:
┌────
│ docker exec -i tgfocus auth
│
│ # Enter phone number: +1 23 4567
│ # Enter login code: xxxxxx
└────
/note: phone number in international format `+1 23 4567' if your
number is `23 4567' with region code `+1' (spaces are allowed)./
If everthing works fine, you should see:
Logged in!
You can check more details about tg-focus by `docker exec -i
tgfocus status'.
4. Go back to your Telgram application, wait for the TG-FOCUS group
showing up. /(usually takes up 1~2 mins, depends on your network
connection)/
If TG-FOCUS group doesn't appear, send a message
"tg-focus" in a random group(e.g. Saved
Messages). /This is because by default, only messages
contain "tg-focus" will be filtered and forwarded./
If TG-FOCUS group doesn't appear after a long
wait(e.g. 10 mins), run a command `./tgfocus status',
report and open a GitHub issue with the command output
attached.
5. Once the group shown up, you send a message `TGFCMD help' to get
started. Check [TGFCMD] for more details.
[TGFCMD] See section Using TGFCMD
Using Binaries
──────────────
The following 6 steps will help you run tg-focus and filter some
specific messages.
1. Download the binaries at GitHub releases [page].
2. Extract the files:
┌────
│ # linux
│ tar xf tg-focus-3.0-linux-x86_64.tar.gz
│ cd tg-focus-3.0-linux-x86_64
└────
3. Log in your Telegram account:
┌────
│ ./tgfocus auth
│
│ # Enter phone number: +1 23 4567
│ # Enter login code: xxxxxx
└────
/note: phone number in international format `+1 23 4567' if your
number is `23 4567' with region code `+1' (spaces are allowed)./
If everthing works fine, you should see:
Logged in!
4. Start up tg-focus daemon:
┌────
│ ./tgfocus quickstart
└────
/note: conversely, use `./tgfocus shutdown' to shutdown tg-focus/
If everthing works fine, you should see:
startup: done
focus-start: done
5. Go back to your Telgram application, wait for the TG-FOCUS group
showing up. /(usually takes up 1~2 mins, depends on your network
connection)/
If TG-FOCUS group doesn't appear, send a message
"tg-focus" in a random group(e.g. Saved
Messages). /This is because by default, only messages
contain "tg-focus" will be filtered and forwarded./
If TG-FOCUS group doesn't appear after a long
wait(e.g. 10 mins), run a command `./tgfocus status',
report and open a GitHub issue with the command output
attached.
6. Once the group shown up, you send a message `TGFCMD help' to get
started. Check [TGFCMD] for more details.
[page] <https://github.com/micl2e2/tg-focus/releases>
[TGFCMD] See section Using TGFCMD
Using TGFCMD
────────────
Say there is a Telegram user, called Bob. He owns a group. Every day,
plenty of messages are sending out in that group, it is too
overwhelming, Bob wants to focus on the messages that strongly
interest him, he decides to use tg-focus. After the previous 6-step
setup, he now is going to use TGFCMD to configure his tg-focus to
forward the messages he is strongly interested in:
<img src="docs/imgtuto/tuto1.png" width="500px"/><br/> <img
src="docs/imgtuto/tuto2.png" width="800px"/><br/> <img
src="docs/imgtuto/tuto3.png" width="500px"/><br/> <img
src="docs/imgtuto/tuto4.png" width="550px"/><br/> <img
src="docs/imgtuto/tuto5.png" width="700px"/><br/> <img
src="docs/imgtuto/tuto6.png" width="600px"/><br/> <img
src="docs/imgtuto/tuto7.png" width="550px"/><br/>
TGFCMD Examples
═══════════════
/Note that TGFCMD commands are to be sent out in the TG-FOCUS group/
To forward the messages that belong to the chat "Freedom User Group":
┌────
│ TGFCMD filter.edit 1 titles add "Freedom User Group"
└────
To forward the messages that sent by the user "Some One":
┌────
│ TGFCMD filter.edit 1 senders add "Some One"
└────
To forward the messages that contain a word "freedom":
┌────
│ TGFCMD filter.edit 1 keywords add "freedom"
└────
To forward two types of messages, the first contains a word "free
things" and belongs to the chat "Nonfree Lovers", the second contains
a word "nonfree things" and belongs to "Free Lovers":
┌────
│ TGFCMD filter.edit 1 titles add "Nonfree Lovers"
│ TGFCMD filter.edit 1 keywords add "free things"
│ TGFCMD filter.edit 2 titles add "Free Lovers"
│ TGFCMD filter.edit 2 keywords add "nonfree things"
└────
Not to forward the messages that sent by the user "Nonfree Lover":
┌────
│ TGFCMD filter.edit 1 no-senders add "Nonfree Lover"
└────
Check current filters configuration:
┌────
│ TGFCMD filters
└────
Pause forwarding:
┌────
│ TGFCMD pause
└────
Resume forwarding:
┌────
│ TGFCMD resume
└────
Filters Rules
═════════════
Filters configurationa is composed of many /Focus Filters/. A /Focus
Filter/ is a filter to match against the message's
chat/sender/content. They have several rules(or properties):
• /titles/
• /keywords/
• /senders/
• /no-titles/
• /no-senders/
• /no-keywords/
Simply put, /titles/, /keywords/, /senders/ are the lists of chat
titles, keywords, senders that you are interested in respectively.
/no-titles/, /no-keywords/, /no-senders/ are the ones you don't want
to see.
Users can add values to those rules as many as they like, they accept
**simple text** or **regular expression**, as well as filters.
When a message comes, filters are tried one by one, if there is any
filter than can *match* the message and not *reject* it, it will be
forwarded to TG-FOCUS chat.
A focus filter *matches* the message if it matches any filter's:
• /titles/ and
• /senders/ and
• /keywords/
Note that an empty rule(i.e., you haven't configure it) matches
everthing.
If a focus filter fails to match the incoming message, the next focus
filter will be tried. If all focus filters fail to match it, the
message will be discarded.
A focus filter *rejects* the message if it matches any filter's:
• /no-title/ or
• /no senders/ or
• /no-keywords/
Note thta if any focus filter rejects the message, the next focus
filter will not be tried, and the message will be discarded.
(You can think of the first three rules as /whitelist/, the last three
rules as /blacklist/)
Contributing
════════════
tg-focus is still far from perfect, any form of contribution is
welcomed:
• Ask question (open an issue with label "question")
• Bug Report (open an issue with label "bug")
• Feature Request (open an issue with label "enhancement")
• Documentation Improvement
• Code Contribution (tg-focus follows [GCC](<https://gcc.gnu.org/>)
code style)
ToDo list
─────────
This is a list of TODOs that are certainly to be finished in the near
future, you can pick one then get started if you are interested in:
• ☐ Project Logo (also used as TG-FOCUS group avatar)
• ☐ Forwarded message's Look
• ☐ Configuration in JSON Format
• ☐ Windows Port
• ☐ BSD Port
• ☐ macOS Port
• ☐ More C++20/23/26 features
• ☐ More different build systems
Development
───────────
Linux
╌╌╌╌╌
Distribution:
• Debian 11 (Bullseye)
• /note: bullseye-like distros might work, but it won't be
considered an issue if not working there./
Software:
• bash, git, sudo, apt, etc.
• run `bash ci/prep-libs-deb11-x86_64.bash' to automatically prepare
them.
• custom built GCC
• run `bash ci/prep-toolc-deb11-x86_64.bash' to automatically
prepare them.
Building:
• run `bash ci/build-tgfocus-deb11-x86_64.bash' to get a Release
build.
• run `DDD=1 bash ci/build-tgfocus-deb11-x86_64.bash' to get a Debug
build.
FAQ
═══
Why yet another Telegram message forwarder?
───────────────────────────────────────────
There are already many TG message forwarders over there, and some of
them have been continuously developed for a long time. I do think most
of them are doing a great job. However what I was looking for was a
message forwarder with a combination of stability, reliability,
transparency, and flexibility, none of them could completely meet my
personal preference, at least in the days before this project started.
Can I trust tg-focus?
─────────────────────
Yes.
First of all, consider that tg-focus is a GPL-licensed [free
software](<https://www.gnu.org/philosophy/free-sw.en.html>). As for
privacy, only credentials necessary for tdlib initialization are saved
on the user's machine. And they are completely /yours-irrelavent/. As
for source code, tg-focus's source as well as its dependencies' source
are completely open.
And one more step we take is that, all of released binaries are built
by *not* any individual, but *Github-hosted* machines. Check [github
actions] for more details.
[github actions] <https://github.com/micl2e2/tg-focus/actions>
License
═══════
tg-focus is licensed under /GNU General Public License Version
3.0/. There is NO WARRANTY, to the extent permitted by law.