{"id":13815117,"url":"https://github.com/SharzyL/tg_searcher","last_synced_at":"2025-05-15T07:31:54.968Z","repository":{"id":45394897,"uuid":"278648329","full_name":"SharzyL/tg_searcher","owner":"SharzyL","description":"A bot to provide versatile Chinese optimized searching for telegram chats.    通过 bot 来给 Telegram 提供针对中文优化的搜索。","archived":false,"fork":false,"pushed_at":"2025-04-14T04:48:51.000Z","size":265,"stargazers_count":331,"open_issues_count":12,"forks_count":39,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-05-10T18:48:24.489Z","etag":null,"topics":["python","telegram-bot"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/SharzyL.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-07-10T14:01:35.000Z","updated_at":"2025-05-10T10:31:31.000Z","dependencies_parsed_at":"2024-10-28T11:31:12.435Z","dependency_job_id":"3094f08c-7b15-4387-ba7c-2eedb8f31a51","html_url":"https://github.com/SharzyL/tg_searcher","commit_stats":{"total_commits":130,"total_committers":6,"mean_commits":"21.666666666666668","dds":0.2153846153846154,"last_synced_commit":"62ac0a7bd3d1cdf0d475de4cc2d1f23b8b3cf517"},"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SharzyL%2Ftg_searcher","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SharzyL%2Ftg_searcher/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SharzyL%2Ftg_searcher/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SharzyL%2Ftg_searcher/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SharzyL","download_url":"https://codeload.github.com/SharzyL/tg_searcher/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254295942,"owners_count":22047174,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["python","telegram-bot"],"created_at":"2024-08-04T04:02:58.654Z","updated_at":"2025-05-15T07:31:54.358Z","avatar_url":"https://github.com/SharzyL.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"# TG Searcher\n\n众所周知，Telegram 的搜索功能较弱，尤其是对于中文等 CJK 语言，由于 Telegram 无法对其进行正确的分词，因此很难搜到想要的内容。本项目实现了一个通用的框架，用户可以对 Telegram 的会话建立索引，通过 bot 来便捷地搜索消息。\n\n它的使用效果见下图：\n\n\u003cimg src=\"./assets/example.jpg\" alt=\"使用示例\" height=\"500\"\u003e\n\n## 用法\n关于如何运行和部署 Searcher，参见 [deploy.md](./doc/deploy.md)\n\n关于如何编写配置，参见 [configuration.md](./doc/configuration.md)\n\n关于不同版本的修改记录，参见 [CHANGELOG.md](./CHANGELOG.md)\n\n## Telegram Bot 前端\n\nTelegram Bot 的前端提供了如下功能：\n\n当用户给 bot 发送消息的时候，bot 默认会将消息的内容视为搜索的关键词，因此会返回根据这个关键词进行搜索的结果。除了简单的关键词查询以外，还支持如下的高级搜索语法\n\n1. `\"foo bar\"` 搜索出现 `foo bar` 这个字符串的消息\n2. `AND`, `OR`, `NOT` 可以用来组合搜索逻辑，例如 `NOT foo AND (bar OR woo)` 搜索所有没有出现 `foo`，并且出现了 `bar` 或者 `woo` 的消息\n3. `*` 和 `?` 通配符，前者匹配任意多个字符，后者匹配一个字符。注意：包含通配符的搜索会较慢。\n4. 更详细的语法介绍，参见 whoosh 的[文档](https://whoosh.readthedocs.io/en/latest/querylang.html)\n\n下面几条命令任何用户都可以使用：\n\n1. `/search [keyword]`: 搜索消息，同去掉 `/search` 的情形等价。\n2. `/chats [keyword]`: 列出所有被索引的，标题中包含 `keyword` 的会话列表。如果没有指定 `keyword`，则返回所有的会话。bot 会返回一列按钮，点击一个按钮之后这条消息就对应了一个会话。有一些指令包含 `chat_id` 作为参数，对于这些指令，如果没有指定 chat_id 参数，那么可以通过回复这条消息来把会话的 ID 当作参数。如果回复搜索的关键词，则只搜索这个会话中的消息。\n3. `/random`：返回一条随机的消息（暂不支持指定会话）\n\n下面几条命令只有管理员可以使用：\n\n1. `/download_chat [--max=MAX] [--min=MIN] [CHAT...]`: 下载某个会话的历史消息并将其进行索引。其中 `CHAT` 是对话的 id 或者用户名。如果没有指定 `CHAT` 也没有通过回复 bot 的消息来指定会话。`MIN` 和 `MAX` 参数用于指定索引的消息的最小和最大 ID。在下载之后，会话会自动加入监听列表，所有新消息和旧消息的修改、删除均会被同步到索引\n2. `/monitor_chat CHAT...`: 仅将会话加入监听列表，不索引历史消息。注意：当前版本当后端重启之后，如果一个聊天没有任何消息被索引，那么它不会被加入监听列表，未来的版本可能会修复这个问题\n3. `/stat`: 报告后端的状态\n4. `/clear [CHAT...]`: 或者清除特定会话的索引，如果要清除所有索引，请使用 `\\clear all`\n5. `/find_chat_id KEYWORD`: 列出所有后端的账号的所有会话中包含 `keyword` 的会话以及对应的 id\n6. `/refresh_chat_names`: 刷新会话 id 和会话名称之间映射的缓存\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FSharzyL%2Ftg_searcher","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FSharzyL%2Ftg_searcher","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FSharzyL%2Ftg_searcher/lists"}