{"id":23091784,"url":"https://github.com/tgbot-collection/searchgram","last_synced_at":"2025-05-16T13:04:28.279Z","repository":{"id":37442407,"uuid":"477727772","full_name":"tgbot-collection/SearchGram","owner":"tgbot-collection","description":"🔠 Telegram 中文聊天记录搜索机器人 Effortlessly search your Telegram chat history, including CJK languages, with fuzzy and typo-tolerant search capabilities.","archived":false,"fork":false,"pushed_at":"2025-04-11T17:12:15.000Z","size":2970,"stargazers_count":312,"open_issues_count":4,"forks_count":34,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-11T18:29:46.036Z","etag":null,"topics":["cjk","search","telegram"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tgbot-collection.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","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,"zenodo":null},"funding":{"github":"BennyThink","custom":"https://buy.stripe.com/dR67vU4p13Ox73a6oq"}},"created_at":"2022-04-04T14:04:39.000Z","updated_at":"2025-04-11T17:12:11.000Z","dependencies_parsed_at":"2024-01-01T17:31:22.510Z","dependency_job_id":"32189687-c00a-473f-aade-59195153d303","html_url":"https://github.com/tgbot-collection/SearchGram","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tgbot-collection%2FSearchGram","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tgbot-collection%2FSearchGram/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tgbot-collection%2FSearchGram/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tgbot-collection%2FSearchGram/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tgbot-collection","download_url":"https://codeload.github.com/tgbot-collection/SearchGram/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248544040,"owners_count":21121882,"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":["cjk","search","telegram"],"created_at":"2024-12-16T21:19:59.418Z","updated_at":"2025-04-12T09:21:58.412Z","avatar_url":"https://github.com/tgbot-collection.png","language":"Python","funding_links":["https://github.com/sponsors/BennyThink","https://buy.stripe.com/dR67vU4p13Ox73a6oq","https://www.buymeacoffee.com/bennythink"],"categories":[],"sub_categories":[],"readme":"# SearchGram\n\nSearchGram is a Telegram bot that improves search experience for Chinese, Japanese, and Korean (CJK) languages and\nprovides message backup functionality.\n\n# Introduction\n\nTelegram's search function has poor support for CJK languages because there are no spaces to separate words.\n\nIssues regarding this have been reported years ago but have yet to be resolved.\n\n* https://github.com/tdlib/td/issues/1004\n* https://bugs.telegram.org/c/724\n\n# Feature\n\n* Supports text message search\n* Provides typo-tolerant and fuzzy search for CJK languages\n* Supports filters for GROUP, CHANNEL, PRIVATE, SUPERGROUP, and BOT\n* Supports username/ID filtering\n* Supports caption search for photos and documents\n* Supports seamless chat history sync in the background\n* Provides pagination\n* Uses a WebUI for searching\n\n# search syntax\n\n1. global search: send any message to the bot\n2. chat type search: `-t=GROUP keyword`, support types are [\"BOT\", \"CHANNEL\", \"GROUP\", \"PRIVATE\", \"SUPERGROUP\"]\n3. chat user search: `-u=user_id|username keyword`\n4. exact match: `-m=e keyword` or directly `\"keyword\"`\n5. combine of above: `-t=GROUP -u=user_id|username keyword`\n6. `/private [username] keyword`: search in private chat with username, if username is omitted, search in all private\n   chats. This also applies to all above search types.\\n\n\n# commands\n\n```shell\n/start - Start the bot\n/ping - Check if the bot is alive\n/help - Show help message and search syntax\n/delete - Delete all messages from specific chat\n/bot - Search messages from bots\n/channel - Search messages from channels\n/group - Search messages from groups\n/private - Search messages from private chats\n/supergroup - Search messages from supergroups\n```\n\n# Theory\n\nSearchGram works by:\n\n1. Allowing multiple sessions, with a maximum of 10 clients.\n2. Creating a hidden session to store all incoming and outgoing text messages to MeiliSearch.\n3. Creating another bot to query MeiliSearch.\n4. Returning the whole sentence to use Telegram's built-in search feature, which is known to be buggy.\n\nIf you're concerned about chat history prior to running the bot,\n\nyou can relax because SearchGram offers a solution to sync your chat history using a configuration file.\n\n# Screenshots\n\n![](assets/1.png)\n![](assets/2.png)\n![](assets/3.png)\n![](assets/4.png)\n\n# System Requirements\n\nAny system that can run Python 3.8+ and MeiliSearch should be able to run SearchGram.\n\nBetter to have bigger ram so MeiliSearch can run faster.\n\nIf you have limited RAM, you can set environment variables `MEILI_MAX_INDEXING_MEMORY=800M` to limit the RAM use in\nMeiliSearch.\n\nFor more information, please\nsee [Max indexing memory](https://www.meilisearch.com/docs/learn/configuration/instance_options#max-indexing-memory)\n\n# Installation\n\n**Note: Because chat history should be kept private, we do not offer any public bots.**\n\nPlease follow the steps below to install SearchGram on your own server.\n\nThis guide will show you how to install SearchGram with our default search engine, MeiliSearch.\n\n**To learn how to use SearchGram in Docker with different search engine, please refer to the [Docker.md](Docker.md)**\n\n## 1. Preparation\n\n* Download or clone this repository\n* Install Python from here: https://www.python.org/downloads/\n* Install MeiliSearch from here: https://github.com/meilisearch/meilisearch\n* Apply for APP_ID and APP_HASH from here: https://my.telegram.org/\n* Obtain your bot token by contacting https://t.me/BotFather.\n* Obtain your user ID by contacting https://t.me/blog_update_bot.\n\n## 2. Modify environment file\n\nUse your favorite editor to modify `config.py`, example:\n\n```python\nAPP_ID = 176552\nAPP_HASH = \"667276jkajhw\"\nTOKEN = \"123456:8hjhad\"\nMEILI_HOST = \"localhost\"\nOWNER_ID = \"2311231\"\n```\n\nIf you have limited network access, such as in China, you will need to set up a proxy.\n\n```python\nPROXY = {\"scheme\": \"socks5\", \"hostname\": \"localhost\", \"port\": 1080}\n```\n\n## 3. Login to client\n\nOpen a terminal (such as cmd or iTerm), navigate to the directory where you have saved the code, and then:\n\n```shell\npython client.py\n```\n\nEnter your phone number and log in to the client. You can exit by pressing `Ctrl + C`.\n\n## 4. (optional)Setup sync id\n\nSee [here](Docker.md#6-optionalsetup-sync-id)\n\n## 5. Run!\n\nOpen two terminals and run the following commands in each terminal:\n\n```shell\npython client.py\npython bot.py\n```\n\n## 6. (Optional) Migration\n\n* add timestamp to all your data for better sorting `python add_timestamp.py`\n\n# Sponsor\n\n* [Buy me a coffee](https://www.buymeacoffee.com/bennythink)\n* [Afdian](https://afdian.net/@BennyThink)\n* [GitHub Sponsor](https://github.com/sponsors/BennyThink)\n\n## Stripe\n\nIf you would like to donate to the project using Stripe, please click on the button below.\n\nYou can choose the currency and payment method that best suits you.\n\n| USD(Card, Apple Pay and Google Pay)              | SEK(Card, Apple Pay and Google Pay)              | CNY(Card, Apple Pay, Google Pay and Alipay)      |\n|--------------------------------------------------|--------------------------------------------------|--------------------------------------------------|\n| [USD](https://buy.stripe.com/cN203sdZB98RevC3cd) | [SEK](https://buy.stripe.com/bIYbMa9JletbevCaEE) | [CNY](https://buy.stripe.com/dR67vU4p13Ox73a6oq) |\n| ![](assets/USD.png)                              | ![](assets/SEK.png)                              | ![](assets/CNY.png)                              |\n\n# License\n\nThis project is licensed under the GNU GENERAL PUBLIC LICENSE Version 3.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftgbot-collection%2Fsearchgram","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftgbot-collection%2Fsearchgram","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftgbot-collection%2Fsearchgram/lists"}