telefire 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. telefire-0.1.0/.github/workflows/publish.yml +20 -0
  2. telefire-0.1.0/.gitignore +167 -0
  3. telefire-0.1.0/Dockerfile +10 -0
  4. telefire-0.1.0/LICENSE +21 -0
  5. telefire-0.1.0/PKG-INFO +21 -0
  6. telefire-0.1.0/README.md +121 -0
  7. telefire-0.1.0/SKILL.md +137 -0
  8. telefire-0.1.0/StopWords.txt +1623 -0
  9. telefire-0.1.0/chengyu_list.txt +30895 -0
  10. telefire-0.1.0/pyproject.toml +30 -0
  11. telefire-0.1.0/src/telefire/__init__.py +0 -0
  12. telefire-0.1.0/src/telefire/cli.py +20 -0
  13. telefire-0.1.0/src/telefire/config.py +111 -0
  14. telefire-0.1.0/src/telefire/plugins/__init__.py +24 -0
  15. telefire-0.1.0/src/telefire/plugins/auto_frds.py +42 -0
  16. telefire-0.1.0/src/telefire/plugins/auto_invite.py +87 -0
  17. telefire-0.1.0/src/telefire/plugins/auto_reaction.py +40 -0
  18. telefire-0.1.0/src/telefire/plugins/auto_repeat.py +31 -0
  19. telefire-0.1.0/src/telefire/plugins/auto_reply.py +35 -0
  20. telefire-0.1.0/src/telefire/plugins/auto_reply_test.py +32 -0
  21. telefire-0.1.0/src/telefire/plugins/auto_three.py +41 -0
  22. telefire-0.1.0/src/telefire/plugins/base.py +211 -0
  23. telefire-0.1.0/src/telefire/plugins/burst_send.py +32 -0
  24. telefire-0.1.0/src/telefire/plugins/chat_count.py +63 -0
  25. telefire-0.1.0/src/telefire/plugins/delete_all.py +41 -0
  26. telefire-0.1.0/src/telefire/plugins/find_user.py +24 -0
  27. telefire-0.1.0/src/telefire/plugins/get_all_chats.py +15 -0
  28. telefire-0.1.0/src/telefire/plugins/get_entity.py +20 -0
  29. telefire-0.1.0/src/telefire/plugins/get_messages_by_ids.py +21 -0
  30. telefire-0.1.0/src/telefire/plugins/jarryxiaobot.py +29 -0
  31. telefire-0.1.0/src/telefire/plugins/list_deleted_user_messages.py +20 -0
  32. telefire-0.1.0/src/telefire/plugins/list_messages.py +45 -0
  33. telefire-0.1.0/src/telefire/plugins/log_chat.py +22 -0
  34. telefire-0.1.0/src/telefire/plugins/matrix_chengyu_bot.py +150 -0
  35. telefire-0.1.0/src/telefire/plugins/matrix_list_rooms.py +26 -0
  36. telefire-0.1.0/src/telefire/plugins/matrix_plus_mode.py +24 -0
  37. telefire-0.1.0/src/telefire/plugins/plus_mode.py +334 -0
  38. telefire-0.1.0/src/telefire/plugins/regex_messages.py +36 -0
  39. telefire-0.1.0/src/telefire/plugins/search_messages.py +55 -0
  40. telefire-0.1.0/src/telefire/plugins/special_attention_mode.py +25 -0
  41. telefire-0.1.0/src/telefire/plugins/stream_to_redis.py +72 -0
  42. telefire-0.1.0/src/telefire/plugins/summary.py +23 -0
  43. telefire-0.1.0/src/telefire/plugins/summary_man.py +61 -0
  44. telefire-0.1.0/src/telefire/plugins/summary_messages.py +26 -0
  45. telefire-0.1.0/src/telefire/plugins/word_cloud.py +56 -0
  46. telefire-0.1.0/src/telefire/plugins/word_cloud_inchat.py +133 -0
  47. telefire-0.1.0/src/telefire/plugins/words_notify.py +23 -0
  48. telefire-0.1.0/src/telefire/plugins/words_to_ifttt.py +23 -0
  49. telefire-0.1.0/src/telefire/plugins/words_to_pushbullet.py +27 -0
  50. telefire-0.1.0/src/telefire/plugins/yvlu.py +129 -0
  51. telefire-0.1.0/src/telefire/simsun.ttf +0 -0
  52. telefire-0.1.0/src/telefire/storage.py +188 -0
  53. telefire-0.1.0/src/telefire/util/__init__.py +0 -0
  54. telefire-0.1.0/src/telefire/util/chengyu.py +95 -0
  55. telefire-0.1.0/src/telefire/utils.py +36 -0
  56. telefire-0.1.0/uv.lock +1935 -0
@@ -0,0 +1,20 @@
1
+ name: Publish to PyPI
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - "v*"
7
+
8
+ jobs:
9
+ publish:
10
+ runs-on: ubuntu-latest
11
+ permissions:
12
+ id-token: write
13
+ steps:
14
+ - uses: actions/checkout@v4
15
+
16
+ - uses: astral-sh/setup-uv@v6
17
+
18
+ - run: uv build
19
+
20
+ - uses: pypa/gh-action-pypi-publish@release/v1
@@ -0,0 +1,167 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ wheels/
23
+ pip-wheel-metadata/
24
+ share/python-wheels/
25
+ *.egg-info/
26
+ .installed.cfg
27
+ *.egg
28
+ MANIFEST
29
+
30
+ # PyInstaller
31
+ # Usually these files are written by a python script from a template
32
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
33
+ *.manifest
34
+ *.spec
35
+
36
+ # Installer logs
37
+ pip-log.txt
38
+ pip-delete-this-directory.txt
39
+
40
+ # Unit test / coverage reports
41
+ htmlcov/
42
+ .tox/
43
+ .nox/
44
+ .coverage
45
+ .coverage.*
46
+ .cache
47
+ nosetests.xml
48
+ coverage.xml
49
+ *.cover
50
+ *.py,cover
51
+ .hypothesis/
52
+ .pytest_cache/
53
+
54
+ # Translations
55
+ *.mo
56
+ *.pot
57
+
58
+ # Django stuff:
59
+ *.log
60
+ local_settings.py
61
+ db.sqlite3
62
+ db.sqlite3-journal
63
+
64
+ # Flask stuff:
65
+ instance/
66
+ .webassets-cache
67
+
68
+ # Scrapy stuff:
69
+ .scrapy
70
+
71
+ # Sphinx documentation
72
+ docs/_build/
73
+
74
+ # PyBuilder
75
+ target/
76
+
77
+ # Jupyter Notebook
78
+ .ipynb_checkpoints
79
+
80
+ # IPython
81
+ profile_default/
82
+ ipython_config.py
83
+
84
+ # pyenv
85
+ .python-version
86
+
87
+ # pipenv
88
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
89
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
90
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
91
+ # install all needed dependencies.
92
+ #Pipfile.lock
93
+
94
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow
95
+ __pypackages__/
96
+
97
+ # Celery stuff
98
+ celerybeat-schedule
99
+ celerybeat.pid
100
+
101
+ # SageMath parsed files
102
+ *.sage.py
103
+
104
+ # Environments
105
+ .env
106
+ .venv
107
+ env/
108
+ venv/
109
+ ENV/
110
+ env.bak/
111
+ venv.bak/
112
+
113
+ # Spyder project settings
114
+ .spyderproject
115
+ .spyproject
116
+
117
+ # Rope project settings
118
+ .ropeproject
119
+
120
+ # mkdocs documentation
121
+ /site
122
+
123
+ # mypy
124
+ .mypy_cache/
125
+ .dmypy.json
126
+ dmypy.json
127
+
128
+ # Pyre type checker
129
+ .pyre/
130
+
131
+ # Telethon session
132
+ *.session
133
+ *.session-journal
134
+
135
+ # Vim stuff
136
+ *.swp
137
+
138
+ # Intellij
139
+ .idea/
140
+
141
+ # VS Code
142
+ .vscode/
143
+
144
+ *.pkl
145
+ matrix.jpeg
146
+ matrix.png
147
+ matrix.webm
148
+ matrix.webp
149
+ guamei_*.jpeg
150
+ all_chats
151
+ data.csv
152
+ matrix_all_chats
153
+ matrix_media_decrypt.py
154
+ test.py
155
+ plugins/yvlu/
156
+ src/telefire/plugins/yvlu/
157
+ .pdm-python
158
+ .python-version
159
+
160
+ # Legacy flat layout (now in src/telefire/)
161
+ /plugins/
162
+ /utils.py
163
+ /telefire.py
164
+ /util/
165
+
166
+ # pdm
167
+ pdm.lock
@@ -0,0 +1,10 @@
1
+ FROM python:3.8-slim
2
+
3
+ RUN apt-get update && apt-get install gcc -y && apt-get clean
4
+
5
+ RUN mkdir -p /tg
6
+ WORKDIR /tg
7
+
8
+ COPY requirements.txt requirements.txt
9
+ RUN pip install -r requirements.txt
10
+
telefire-0.1.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2019 Lei Shi
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,21 @@
1
+ Metadata-Version: 2.4
2
+ Name: telefire
3
+ Version: 0.1.0
4
+ Summary: CLI tool for Telegram automation via user account
5
+ Author-email: Lei Shi <me@leishi.io>
6
+ License: MIT
7
+ License-File: LICENSE
8
+ Requires-Python: >=3.10
9
+ Requires-Dist: aiohttp>=3.9.0
10
+ Requires-Dist: aiosqlite>=0.20.0
11
+ Requires-Dist: fire>=0.5.0
12
+ Requires-Dist: jieba>=0.42.1
13
+ Requires-Dist: loguru>=0.7.0
14
+ Requires-Dist: mautrix>=0.20.0
15
+ Requires-Dist: pillow>=10.0.0
16
+ Requires-Dist: python-dateutil>=2.8.0
17
+ Requires-Dist: telethon>=1.40.0
18
+ Requires-Dist: tomli>=2.0.0; python_version < '3.11'
19
+ Requires-Dist: wordcloud>=1.9.0
20
+ Provides-Extra: ai
21
+ Requires-Dist: g4f>=0.3.8; extra == 'ai'
@@ -0,0 +1,121 @@
1
+ <p align="center">
2
+ <h2 align="center">Telethon X Fire - TeleFire</h2>
3
+ </p>
4
+
5
+ <p align="center">A set of userful command line tools to interact with telegram.</p>
6
+
7
+ <p align="center">
8
+ <b><a href="#what-has-inside">What has inside</a></b>
9
+ |
10
+ <b><a href="#how">How</a></b>
11
+ |
12
+ <b><a href="#docker">Docker</a></b>
13
+ </p>
14
+
15
+
16
+ ## What is inside
17
+
18
+ - :flags:<a href="#get_all_chats">get_all_chats</a>: Fetches all the chat IDs and names.
19
+ - :bookmark_tabs:<a href="#list_messages">list_messages</a>: List messages in a certain chat.
20
+ - :mag:<a href="#search_messages">search_messages</a>: Search messages in a certain chat.
21
+ - :skull:<a href="#delete_all">delete_all</a>: Delete all the messages that you have permission to delete in a certain chat.
22
+ - :question:<a href="#plus_mode">plus_mode</a>: Delete certain messages after certain time.
23
+ - :speech_balloon:<a href="#words_to_ifttt">words_to_ifttt</a>: Send an event to IFTTT when somebody said some words
24
+ you interested.
25
+ - :heart_eyes:<a href="#other-commands">special_attention_mode</a>: Get notified when someone in special attention mode said something.
26
+
27
+ ## Usage
28
+
29
+ ### Setup
30
+
31
+ 0. [Login to your Telegram account](https://my.telegram.org/auth) with the phone number of the account you wish to use.
32
+ 1. Click **API Development tools**.
33
+ 2. A `Create new application` window will appear if you didn't create one. Go head and create one.
34
+ 3. Once you finish creation, get the `api_id` and `api_hash`, you will use it later.
35
+
36
+
37
+ ### get_all_chats
38
+
39
+ ```shell
40
+ TELEGRAM_API_ID=[YOUR_API_ID] TELEGRAM_API_HASH=[YOUR_API_HASH] python telefire.py get_all_chats
41
+
42
+ -100XXXXXXXXXX: CHANNEL_NAME0
43
+ XXXXXXXXXX: CHANNEL_NAME1
44
+ ```
45
+ Those negative IDs start with `-100` are private groups, that's the only way you can access to these groups. For public groups, you can either use id, public url, username to access to it.
46
+
47
+
48
+ ### list_messages
49
+
50
+ ```shell
51
+ TELEGRAM_API_ID=[YOUR_API_ID] TELEGRAM_API_HASH=[YOUR_API_HASH] python telefire.py list_messages --chat [CHAT_IDENTIFIER] [Optional: --user USER_IDENTIFIER]
52
+ ```
53
+ For `CHAT_IDENTIFIER`, it can be a chat ID you got from <a href="#get_all_chats">get_all_chats</a>, or it can be something like `t.me/LGTMer` or `LGTMer`.
54
+
55
+ For `USER_IDENTIFIER`, it can be the user's ID or username.
56
+
57
+
58
+ ### search_messages
59
+
60
+ ```shell
61
+ TELEGRAM_API_ID=[YOUR_API_ID] TELEGRAM_API_HASH=[YOUR_API_HASH] python telefire.py search_messages --peer [PEER_IDENTIFIER] --query [QUERY_STRING]
62
+ ```
63
+ This command comes with some optional parameters that you can custom:
64
+ - `--slow`: Whether to use telegram's search API or iterate through whole message history to do the search. The later can be comprehensive if you are searching UTF-8 characters such as Chinese.
65
+ - `--limit [INTEGER]`: Set the limit of search result, default `100`.
66
+ - `--from_id [USER_IDENTIFIER]`: The id/username of the message sender.
67
+
68
+ ### delete_all
69
+
70
+ ```shell
71
+ TELEGRAM_API_ID=[YOUR_API_ID] TELEGRAM_API_HASH=[YOUR_API_HASH] python telefire.py delete_all --chat [CHAT_IDENTIFIER] [Optional: --query QUERY_STRING]
72
+ ```
73
+ For `CHAT_IDENTIFIER`, smiliar to `CHAT_IDENTIFIER` in <a href="#get_all_chats">get_all_chats</a>, or it can be something like `t.me/LGTMer` or `LGTMer`.
74
+
75
+ You can also using the `--query` to specify only messages containing certain string will be deleted.
76
+
77
+ ### plus_mode
78
+
79
+ ```shell
80
+ TELEGRAM_API_ID=[YOUR_API_ID] TELEGRAM_API_HASH=[YOUR_API_HASH] python telefire.py plus_mode
81
+ ```
82
+ It's a command you have to keep it running in the backgroud to use it. It's my personal favorite command! It includes several functions that's interesting and useful:
83
+ - `Auto delete mode`: Add `\[NUMBER][s|m|h|d] ` before the message you want to auto delete after certain time, for example, add `\10s `(notice the space), then this message will be deleted automately after 10 seconds. you can also specify minutes(`m`), hours(`h`) and days(`d`) as the message experation time.
84
+ - `Shiny mode`: just try it, add `\shiny ` to your original message!.
85
+ - `Search mode`: \search [CHAT] [USERNAME] [Optional: QUERY]
86
+
87
+
88
+ ### words_to_ifttt
89
+
90
+ ```shell
91
+ TELEGRAM_API_ID=[YOUR_API_ID] TELEGRAM_API_HASH=[YOUR_API_HASH] python telefire.py words_to_ifttt --event [IFTTT EVENT] --key [IFTTT WEBHOOK KEY] [WORDS YOU INTERESTED]
92
+ ```
93
+
94
+ Like `auto_delete`, you need to keep this command running to make it work. For the `event` and `key`, you can get it from [here](https://ifttt.com/maker_webhooks). For `WORDS YOU INTERESTED`, it can be something like `telefire "telefire is so cool"`, then whenever anybody said **telefire** or **telefire is so cool**, an IFTTT event will be sent and you can create an applet to do whatever you like on IFTTT, such as sending notifications, turn on a light, etc.
95
+
96
+ ### Other commands
97
+
98
+ For all the others commands I didn't methtion or simply too lazy to add docs for it:
99
+ ```shell
100
+ python telefire.py --help
101
+ ```
102
+ to get a list of all the available commands. And:
103
+ ```shell
104
+ python telefire.py COMMAND - --help
105
+ ```
106
+ to learn how to use it.
107
+
108
+
109
+ ## Docker
110
+
111
+ This project also come with a `Dockerfile` so that you don't need to setup any python environment, just run the following command:
112
+ ```shell
113
+ docker build . -t telefire
114
+ docker run -ti --rm -v $(pwd)/telefire.py:/tg/telefire.py telefire python telefire.py [COMMAND] [OPTIONS]
115
+ ```
116
+ And that's it, enjoy!
117
+
118
+ ## TODO
119
+
120
+ - :heavy_check_mark: For deleting messages, add an option to delete messages based on time instead of always delete all.
121
+ - :heavy_check_mark: A long-running service that will notify user if someone said something contains some interested words.
@@ -0,0 +1,137 @@
1
+ ---
2
+ name: telefire
3
+ description: Use when the user asks to interact with Telegram — listing chats, searching messages, fetching history, deleting messages, monitoring keywords, generating word clouds, or running any Telegram automation from the CLI
4
+ ---
5
+
6
+ # Telefire
7
+
8
+ CLI tool for Telegram automation via user account. Built on Telethon + python-fire.
9
+
10
+ **Install:** `uv tool install telefire` or `pip install telefire`
11
+ **Run pattern:** `telefire <command> --arg1=val1 --arg2=val2`
12
+
13
+ **IMPORTANT:** All arguments must use named flags (`--chat=X`, `--user=X`). Bare positional args do NOT work with python-fire in this codebase.
14
+
15
+ ## Before Running Any Command
16
+
17
+ **You MUST verify setup before executing telefire commands.** Follow this checklist:
18
+
19
+ 1. **Check config exists:** `cat ~/.telefire/config.toml`
20
+ - If missing or empty → run `telefire init` (interactive, needs user input)
21
+ - Needs `[telegram]` section with `api_id` and `api_hash`
22
+ 2. **Check session exists:** `ls ~/.telefire/test.session` or `ls ./test.session`
23
+ - If missing → run any telefire command (e.g. `telefire get_all_chats`), it will prompt for phone number + verification code (needs user input)
24
+ 3. **Check session is valid:** `telefire get_all_chats 2>&1 | head -3`
25
+ - If it outputs chat list → ready to use
26
+ - If `ValueError: Please set TELEGRAM_API_ID` → config is missing, go to step 1
27
+ - If `SessionPasswordNeededError` or auth error → session expired, delete `~/.telefire/test.session` and re-authenticate
28
+ - If `ConnectionError` → network issue, retry
29
+
30
+ Credentials can also be set via env vars (`TELEGRAM_API_ID`, `TELEGRAM_API_HASH`) or `.env` file.
31
+
32
+ ## Start Here
33
+
34
+ Always run `get_all_chats` first to find chat IDs/usernames:
35
+ ```bash
36
+ telefire get_all_chats
37
+ ```
38
+ Most commands take `--chat=` (username, numeric ID, or display name).
39
+
40
+ **`--user=` must be a Telegram username or numeric user ID.** Display names do NOT work — they fail with `ValueError: Cannot find any entity`. Use `find_user` to resolve:
41
+ ```bash
42
+ telefire find_user --chat=coder_ot --name='风扇'
43
+ # Output: ID: 567376438, Name: 风扇滑翔翼, Username: Fangliding
44
+ ```
45
+
46
+ ## Quick Reference
47
+
48
+ ### One-Shot Commands (run and exit)
49
+
50
+ | Command | Usage | Purpose |
51
+ |---------|-------|---------|
52
+ | `get_all_chats` | `get_all_chats` | List all chats with IDs |
53
+ | `get_entity` | `get_entity --entity=X` | Resolve user/chat info |
54
+ | `find_user` | `find_user --chat=X --name=X [--limit=500]` | Find username/ID from display name |
55
+ | `search_messages` | `search_messages --chat=X --query=X [--user=X] [--slow=True] [--limit=100] [--before=DATE] [--after=DATE]` | Search messages. Fast=server-side (default), slow=full scan |
56
+ | `list_messages` | `list_messages --chat=X [--user=X] [--output=log] [--print_stat=True] [--cut=True] [--before=DATE] [--after=DATE]` | List all messages from a user. `--print_stat` shows hourly distribution, `--cut` enables jieba segmentation |
57
+ | `get_messages_by_ids` | `get_messages_by_ids --chat=X --ids=ID1,ID2` | Fetch specific messages |
58
+ | `summary_messages` | `summary_messages --chat=X [--user=X] [--limit=10]` | Recent messages from user |
59
+ | `list_deleted_user_messages` | `list_deleted_user_messages --chat=X` | Messages from deleted accounts |
60
+ | `delete_all` | `delete_all --chat=X [--before=DATE] [--after=DATE] [--query=X]` | Delete own messages (irreversible, no dry-run) |
61
+ | `word_cloud` | `word_cloud --chat=X [--user=X] [--start=DATE] [--end=DATE]` | Generate word cloud image |
62
+
63
+ ### Long-Running Commands (event listeners, run in tmux/screen)
64
+
65
+ | Command | Usage | Purpose |
66
+ |---------|-------|---------|
67
+ | `plus_mode` | `plus_mode` | Advanced mode: auto-delete, markdown, search, AI summary |
68
+ | `auto_reply` | `auto_reply --regex=X --reply=X [--chat=X] [--from_sender=X]` | Auto-reply on regex match |
69
+ | `auto_repeat` | `auto_repeat --chat=X` | Repeat when 2 users send same text |
70
+ | `auto_reaction` | `auto_reaction --chat=X --user=X` | Auto-react to user's messages |
71
+ | `words_to_ifttt` | `words_to_ifttt --event=X --key=X WORD1 [WORD2]...` | IFTTT notification on keyword (all chats) |
72
+ | `words_to_pushbullet` | `words_to_pushbullet --token=X --device=X WORD1 [WORD2]...` | Pushbullet notification on keyword (all chats) |
73
+ | `words_notify` | `words_notify --chats=X WORD1 [WORD2]...` | Forward keyword matches to debug channel (specific chats) |
74
+ | `special_attention_mode` | `special_attention_mode --event=X --key=X PERSON1...` | IFTTT notification when specific people speak |
75
+ | `log_chat` | `log_chat` | Log all incoming messages |
76
+ | `wordcloud` | `wordcloud [--db=PATH]` | In-chat word cloud generation (triggered by "wordcloud" message) |
77
+ | `chat_to_redis` | `chat_to_redis [--db=PATH]` | Stream all messages to SQLite |
78
+
79
+ ### Matrix Commands
80
+
81
+ | Command | Usage | Purpose |
82
+ |---------|-------|---------|
83
+ | `matrix_list_rooms` | `matrix_list_rooms` | List joined Matrix rooms |
84
+ | `matrix_plus_mode` | `matrix_plus_mode` | Matrix plus mode |
85
+ | `matrix_chengyu_bot` | `matrix_chengyu_bot --chat=X [--dry_run=True]` | Chinese idiom game bot |
86
+
87
+ ## Common Workflows
88
+
89
+ **List messages with hourly stats:**
90
+ ```bash
91
+ telefire list_messages --chat=coder_ot --user=Fangliding --print_stat=True
92
+ ```
93
+
94
+ **Search messages from a specific user:**
95
+ ```bash
96
+ telefire search_messages --chat=coder_ot --query='keyword' --user=username --limit=500
97
+ ```
98
+
99
+ **Monitor keywords with phone notifications:**
100
+ ```bash
101
+ # Pushbullet (direct push) — monitors ALL chats
102
+ telefire words_to_pushbullet --token=TOKEN --device=DEVICE_ID outage alert
103
+
104
+ # IFTTT webhook — monitors ALL chats
105
+ telefire words_to_ifttt --event=event-name --key=webhook-key outage alert
106
+
107
+ # Forward to Telegram channel — monitors SPECIFIC chats
108
+ telefire words_notify --chats=chat-id keyword1 keyword2
109
+ ```
110
+
111
+ **Safe message deletion (preview first):**
112
+ ```bash
113
+ # Step 1: Preview with list_messages (no delete)
114
+ telefire list_messages --chat=chat-name --user=your-username
115
+
116
+ # Step 2: Delete (irreversible)
117
+ telefire delete_all --chat=chat-name --before='2024-01-01'
118
+ ```
119
+
120
+ **Plus mode sub-commands** (send as Telegram messages while plus_mode is running):
121
+ - `/Ns MESSAGE` — auto-delete after N seconds (e.g., `/30s hello`)
122
+ - `/Nm`, `/Nh`, `/Nd` — minutes, hours, days
123
+ - `/md` — markdown mode
124
+ - `/search user=X chat=Y query=Z` — search and create results channel
125
+ - `/summary user=X count=N [prompt]` — AI summarize recent messages
126
+ - `/getid` — get user ID (reply to their message)
127
+ - `-paolu` — delete all own messages in current chat
128
+
129
+ ## Known Limitations
130
+
131
+ - **`--user=` requires username or numeric ID** — display names fail. Use the lookup snippet above to resolve.
132
+ - `delete_all` has **no dry-run mode** — always preview with `list_messages` first
133
+ - `words_to_ifttt` and `words_to_pushbullet` monitor **all chats** — no chat filter (use `words_notify` for specific chats, but it forwards to Telegram, not phone)
134
+ - Log output does **not include message dates** (date line is commented out in base.py)
135
+ - `search_messages` fast mode uses Telegram's server-side `SearchRequest` — **performs poorly with Chinese text**. Use `--slow=True` for Chinese searches (iterates all messages client-side with substring match)
136
+ - `list_messages` and `search_messages` support `--before` and `--after` date filters (parsed by dateutil, e.g. `2024-01-01`, `last week`)
137
+ - Plugins that need storage accept `--db=PATH` for custom SQLite path (defaults to `~/.telefire/data.db`)