-
Notifications
You must be signed in to change notification settings - Fork 344
如何使用过滤器
author: tangyoha@outlook.com last edit:
2023/06/19
You can use filters to filter messages you don't want to download very easily
-
B
,KB
,MB
,GB
,TB
如 file_size > 1 * 1024
等价于 file_size > 1KB
-
date_time_str
- Support using./-
to split year, month, and day.Supports 4 precision time formats.- 2013.8.15 22:46:21 (eq 2013.8.15 22:46:21)
- 2013.8.15 22:46 (eq 2013.8.15 22:46:00)
- 2013.8.15 (eq 2013.8.15 00:00:00)
- 2014.8 (eq 2014.8.1 00:00:00)
-
str
- String supports two matching formats- simple string comparison
- message_caption == '123'
- regular expression match
- message_caption == r'123.*'
- simple string comparison
-
int
- message_id >= 1024
type | operator |
---|---|
date_time_str |
> < >= <= != ==
|
str |
!= ==
|
int |
> < >= <= != ==
|
meta data name | alias | type | unit | 支持版本 | 备注 |
---|---|---|---|---|---|
message_date | date_time_str | 消息发送时间 | |||
message_id | id | int | 消息id | ||
message_caption | caption | str | 消息的标题内容 | ||
media_file_size | file_size | int | Byte(字节) | 媒体的文件大小 | |
media_width | int | 媒体的视频宽度 | |||
media_height | int | 媒体的视频长度 | |||
media_file_name | file_name | str | 媒体的文件名称 | ||
media_duration | int | 媒体的时长 | |||
media_type | str | v2.2.0 |
媒体的类型 | ||
file_extension | str | v2.2.0 |
文件的拓展 |
audio
,document
,photo
,sticker
,animation
,video
,voice
,video_note
,new_chat_photo
注意配置格式, :后面是需要跟一个括号的
如 'mychannel': 'xxxx' 但是 'mychannel':'xxxx' 报错
in v2.1.4
chat:
- chat_id: your_chat_id
download_filter: your filter
in v2.1.3
chat_id: your_chat_id
download_filter:
'your_chat_id': your filter
- 下载消息id为1-900且标题包含
#我的最爱
且文件大小为1KB-20MB inv2.1.4
chat:
- chat_id: your_chat_id
download_filter: id >= 1 && id <= 900 && caption == r'.*#我的最爱.*' && file_size >= 1KB && file_size <= 20MB
in v2.1.3
chat_id: your_chat_id
download_filter:
'your_chat_id': id >= 1 && id <= 900 && caption == r'.*#我的最爱.*' && file_size >= 1KB && file_size <= 20MB
- 下载消息标题包含
#我的最爱
或者#健康视频
inv2.1.4
chat:
- chat_id: your_chat_id
download_filter: caption == r'.*#健康视频.*' or caption == r'.*#我的最爱.*'
in v2.1.3
chat_id: your_chat_id
download_filter:
'your_chat_id': caption == r'.*#健康视频.*' or caption == r'.*#我的最爱.*'
注意:如果你的配置中含有or条件,请将其他条件用(
)
框起来,避免逻辑错误
-
example: 你想下载文件大小为10MB - 100MB 且标题中含有#三体或者#我的最爱
-
1."file_size > 10MB and file_size < 100MB and (caption == r'.*#三体.*' or caption == r'.*#我的最爱.*')" 所有情况正确
-
2."file_size > 10MB and file_size < 100MB and caption == r'.*#三体.*' or caption == r'.*#我的最爱.*'" 文件大小不满足,但是满足标签含有#我的最爱,也能下载
-
注意:如果日期没有天默认为1号,如2022.01 实际解析为 2022.01.01 00:00:00
- 下载消息时间为 2022.01 - 2022.03 的消息
message_date > 2022.01 and message_date < 2022.03
- 下载消息时间为 2022.01.14 - 2022.03.15 的消息
message_date > 2022.01.14 and message_date < 2022.03.15
- 下载文件名称包含
bios
的文件
file_name == r'.*bios.*'
- 下载文件名称不包含
.bin
的文件
file_name != r'.*\.bios'
注意:如果你需要正则匹配部分特殊字符如.
,*
,+
等,需要在字符前加一个\
转义。
- 下载文件拓展名称为
mp4
或者mp3
的文件
file_extension == r'(mp4|mp3)'
- 下载文件类型为
video
或者audio
的文件
media_type == r'(video|audio)'
-
message_date_time
: - Date the message was sent(date_time_str
)- like: message_date_time > 2022.03.04 && message_date_time < 2022.03.08
- like: message_date_time > 2022-03-04 14:50 && message_date_time < 2022.03.08
- like: message_date_time > 2022-03 && message_date_time < 2022-04
- like: message_date_time > 2022-03 and message_date_time < 2022-04
- like: message_date_time >= 2022-03
- like: message_date_time <= 2022-03
-
message_id
: - Message 's id(int
)- like: message_id >= 20001 && message_id <=20100
- like: message_id >= 20001 and message_id <=20100
-
media_file_size
: - File size(int
)- like: media_file_size >= 10 * 1024 * 1024 && media_file_size <= 1024 * 1024 * 1024 # 1024 * 1024 * 1024 = 1G
-
media_width
: - Include photo and video(int
)- like: media_width >= 1920 and media_height >= 1080
-
media_height
: - Include photo and video(int
) -
media_duration
: - Media duration(int
) -
media_file_name
: - file name(str
)- like: media_file_name == 'test.mp4'(str equal)
- like: media_file_name == r'test.*mp4'(with
r
prefix) - like: media_file_name == r'.*test.*'(with
r
prefix)
-
message_caption
: - message caption(tpye:str
)- like: message_caption == '#v2'(str equal)
- like: message_caption == r'.*#v2.*'(with
r
prefix) - like: message_caption != r'.*#v2.*'(with
r
prefix)
You can discuss with us in the telegram group, or just submit a PR.
您可以在电报群中与我们讨论,或者直接提交 PR。