TG Searcher
众所周知,Telegram 的搜索功能较弱,尤其是对于中文等 CJK 语言,由于 Telegram 无法对其进行正确的分词,因此很难搜到想要的内容。本项目实现了一个通用的框架,用户可以对 Telegram 的会话建立索引,通过 bot 来便捷地搜索消息。
它的使用效果见下图:
用法
关于如何运行和部署 Searcher,参见 deploy.md
关于如何编写配置,参见 configuration.md
关于不同版本的修改记录,参见 CHANGELOG.md
Telegram Bot 前端
Telegram Bot 的前端提供了如下功能:
当用户给 bot 发送消息的时候,bot 默认会将消息的内容视为搜索的关键词,因此会返回根据这个关键词进行搜索的结果。除了简单的关键词查询以外,还支持如下的高级搜索语法
"foo bar"搜索出现foo bar这个字符串的消息AND,OR,NOT可以用来组合搜索逻辑,例如NOT foo AND (bar OR woo)搜索所有没有出现foo,并且出现了bar或者woo的消息*和?通配符,前者匹配任意多个字符,后者匹配一个字符。注意:包含通配符的搜索会较慢。- 更详细的语法介绍,参见 whoosh 的文档
下面几条命令任何用户都可以使用:
/search [keyword]: 搜索消息,同去掉/search的情形等价。/chats [keyword]: 列出所有被索引的,标题中包含keyword的会话列表。如果没有指定keyword,则返回所有的会话。bot 会返回一列按钮,点击一个按钮之后这条消息就对应了一个会话。有一些指令包含chat_id作为参数,对于这些指令,如果没有指定 chat_id 参数,那么可以通过回复这条消息来把会话的 ID 当作参数。如果回复搜索的关键词,则只搜索这个会话中的消息。/random:返回一条随机的消息(暂不支持指定会话)
下面几条命令只有管理员可以使用:
/download_history [--max=MAX] [--min=MIN] [CHAT...]: 下载某个会话的历史消息并将其进行索引。其中CHAT是对话的 id 或者用户名。如果没有指定CHAT也没有通过回复 bot 的消息来指定会话。MIN和MAX参数用于指定索引的消息的最小和最大 ID。在下载之后,会话会自动加入监听列表,所有新消息和旧消息的修改、删除均会被同步到索引/monitor_chat CHAT...: 仅将会话加入监听列表,不索引历史消息。注意:当前版本当后端重启之后,如果一个聊天没有任何消息被索引,那么它不会被加入监听列表,未来的版本可能会修复这个问题/stat: 报告后端的状态/clear [CHAT...]: 或者清除特定会话的索引,如果要清除所有索引,请使用\clear all/find_chat_id KEYWORD: 列出所有后端的账号的所有会话中包含keyword的会话以及对应的 id/refresh_chat_names: 刷新会话 id 和会话名称之间映射的缓存
Metadata
Release files for tg-searcher 0.5.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| tg_searcher-0.5.0.tar.gz | 17.1 kB | Without provenance | Details for tg_searcher-0.5.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| tg_searcher-0.5.0-py3-none-any.whl | Python 3 | none | any | Details for tg_searcher-0.5.0-py3-none-any.whl |
Total release size: 35.4 kB
Release files / tg_searcher-0.5.0.tar.gz
| Download URL | tg_searcher-0.5.0.tar.gz |
|---|---|
| Size | 17.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
62b843113f35c0daeef49444dedb8f4b6d453e162990fda7f2df70a4c48e6f80
|
|
BLAKE2b-256 checksum How to use checksums |
0368f92fafe33c4860a8cc3aee3620b593820ddf012815cb4f897f2158032054
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
pdm/2.15.2 CPython/3.10.12 Linux/6.5.0-1018-azure
|
Release files / tg_searcher-0.5.0-py3-none-any.whl
| Download URL | tg_searcher-0.5.0-py3-none-any.whl |
|---|---|
| Size | 18.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a18b6074aa28b120c508b63a45d5717adb1ded063f695f2a32beae8bcc250fc9
|
|
BLAKE2b-256 checksum How to use checksums |
1d68849ee4aab308541dc1fa2934756754a8c11d910642f0d6dea4e963259967
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
pdm/2.15.2 CPython/3.10.12 Linux/6.5.0-1018-azure
|
Security for tg-searcher 0.5.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.