Commit Graph

51 Commits

Author SHA1 Message Date
50dd34ef9f Added support for file in message context variables
- Fixed file_bot example
- Added functions for extacting file data when building CTX_MESSAGE
- Added `file` variable for Message model
- Fixed RoomEvent builder inability to set room ID when it is missing in source
2026-11-08 19:58:35 +03:00
b5210359b1 Message is built by Pydantic now 2026-10-31 21:34:17 +03:00
ada7af9dd6 Added CTX_ROOM_EVENT 2026-10-31 21:00:45 +03:00
d5367ebc6b Big refactoring
- Changed event callback signature to `(ctx: EventContext, vars: ContextVars)`
- Changed event filter signature to `(ctx: EventContext, vars: ContextVars)`
- Partially fixed examples
- Refactored `src/mab/__init__.py` to be more structured
- Added support for local event context variables so that different filters don't mess with each other
- Refactored file structure for context variables
- Added support for combination of ContextVars
- `ContextVarsPopulator` does not look builders dynamically anymore; `ContextVarsPopulator.autobuilder` is used to mark function as a builder that must be automatically called
- `ContextVarsPopulator` does not required to be created anymore
- Added context variable `CTX_COMMAND`
- `MessageTypeFilter` supports message types passed as strings from now on
- `MessageHasFile` renamed to `MessageHasFileFilter`
- Added docs for context variables
2026-10-31 20:37:57 +03:00
eacb0c0d25 Refactoring in progress
- Context variables are no longer stored in `EventContext`, they are stored in `ContextVars` from now on
- Context variables related stuff has been moved to `mab.context.vars`
- Removed `CTX_FILE`
- Changed variable builder name prefix to `autobuild_`
- Changed variable builder signature to (EventContext, ContextVars)
- Most examples are broken
2026-10-31 16:30:24 +03:00
33efd5e104 Added CTX_FILE variable
- Modified file_bot.py example to utilize CTX_FILE
- Removed docstring for message builders.py
- Removed mab.models namespace package
2026-10-18 16:22:35 +03:00
17031500e9 Added context variable builders system
- Fixed subpackages missing __init__.py
- Fixed mab/__init__.py containing __all__
- Filters no longer add variables to EventContext
- Removed most context variables
- Reorganized file tree a bit
- Fixed echo_bot.py example

Most examples are broken
2026-10-18 15:29:12 +03:00
afcd3f53f4 Added more room APIs, filter changes
- Added APIs to create rooms and forget rooms
- Removed excess imports from filters
- `BaseEventFilter` now sets `CTX_SENDER`
- Added an example for rooms
- Added a note about version freezing to README
2026-10-04 21:37:08 +03:00
b22e7b4903 Added room operations (not tested) v0.6.1 2026-09-27 16:47:08 +03:00
2867582c01 Got rid of proxy methods in MatrixBot, v0.6.0
- Updated README.md
- Updated examples
- `MatrixBot` does not redefine methods from classes it is composed of anymore
v0.6.0
2026-09-27 16:17:40 +03:00
16b849ebd8 Added file uploading support, v0.5.2
- Added example `file_bot.py`
- Added *.tmp to .gitignore
- Added CTX_FILE_SIZE, CTX_FILE_MIME and CTX_FILE_NAME
- Added MessageHasFile filter
- Added `send_file` and `send_file_bytes` for ClientSender and Bot
v0.5.2
2026-09-23 19:43:30 +03:00
35bd68516a Fixed README.md link to image_bot.py 2026-09-13 04:18:43 +03:00
86257a70e3 Added overloads for MatrixBot.download_file 2026-09-13 03:39:23 +03:00
43b5d8e3a6 Fixed downloader bugs related to temp file name 2026-09-13 03:28:27 +03:00
0e9b621895 Added file downloading, updated to v0.5.1 v0.5.1 2026-09-13 03:17:12 +03:00
f3f1e24c0b Updated to v0.5.0 v0.5.0 2026-09-12 23:34:57 +03:00
2e4228b22a Added example for commands 2026-09-12 23:34:06 +03:00
0b79d78715 Fixed RoomEncryptedFilter 2026-09-12 23:01:48 +03:00
a90cd66d3e Fixed CTX_MESSAGE_TYPE typing 2026-09-12 22:56:45 +03:00
cb520814d8 Added description of filter system to README.md 2026-09-12 22:49:55 +03:00
4287a0d20c Improved filters system
- `RoomEventData` is renamed to `EventContext` and moved to context.py
- `EventContext.filter` is removed
- Added context variables system which improves type hints and simplifies callbacks code
- `BodyCommandFilter` sets context variables from now on
- Added `super().__call__` invocation to filters implements in base.py
- Examples are updated to include required changes
2026-09-12 22:19:28 +03:00
e10c920a56 Fixed README.md 2026-09-12 20:24:18 +03:00
156afd6b61 Fixed README references example that don't exist 2026-09-12 20:23:44 +03:00
2d47483d55 Fixed BodyRegexFilter returning re.Match 2026-09-12 20:22:02 +03:00
fc4f664a5c Fixed BaseEventFilter.__ror__ recursion 2026-09-12 20:20:41 +03:00
fa97e4b098 Repo improvements
- Improved README.md
- Added examples
- Added `session_storage/` to .gitignore so that examples do not introduce leftover files after execution
2026-09-12 20:16:39 +03:00
1fe4434e16 Filters refactoring and small improvement
- Removed `filters/__init__.py` (filters are to be imported from `mab` directly)
- Renamed `Text` filters to `Body` filters
- Fixed `base.py` filters not propagating **kwargs to base classes
- Added `__init__` for BaseEventFilter so that keyword argument that remain unused by its children get logged using `logging.critical`
2026-09-12 20:14:28 +03:00
4f0792b9aa Added filter for msgtype 2026-09-12 20:08:27 +03:00
31fbcb4697 Added send_image_bytes(...) to avoid temp files 2026-09-12 20:04:55 +03:00
3e15ae426c Added MatrixBot.run() for dev simplification 2026-09-12 18:06:55 +03:00
b8e598715c Little README update 2026-09-09 19:46:05 +03:00
f58c8601d1 Filter update, fixed bot stop, v0.4.0
- Fixed `asyncio.shield` not being awaited in `ClientManager.stop()` (that led to `next_batch` value not being saved and session not being closed properly)
- `BaseEventFilter` does not have any abstract methods anymore and can be used to use callback for any event
- `BaseEventFilter.__repr__` prints class name now
- `BaseEventFilter.__call__` returns True now
- Added `EventTypeFilter` which can be used to check if the event is an instance of some class
- Removed most room events
- Added `NewMessageFilter`, `EditedMessageFilter`, `RedactedMessageFilter`, `SenderIsFilter` and `SenderIsBotFilter`
- Removed `FormattedTextFilter`
- Text filters are derived from `NewMessageFilter` so they won't match edited messages anymore
v0.4.0
2026-09-09 19:43:29 +03:00
159a43ebe6 Fixed _callbacks.py did not reraise CancelledError 2026-09-09 18:19:52 +03:00
9f4cd4948a Text filters update and stability
- **kwargs are propagated to base classes in text filters from now on
- `_callbacks.py` prints filter exceptions from now on
2026-09-09 18:18:07 +03:00
d14e110525 Updated text filters
- Improved inheritance (most text filters are derived from `TextFilter` from now on)
- Added `TextRegexFilter`
- Most text filters store string lists by reference from now on
2026-09-09 17:25:23 +03:00
3d74cb737b Added some room filters 2026-09-09 01:50:54 +03:00
7d6230881b Preparing to update filter system
- Filters are asynchronous from now on
- Filters are provided with the AsyncClient from now on
2026-09-09 01:03:51 +03:00
5fd87879ca Fixed MatrixBotConfig.allow_ainput_password
`MatrixBotConfig.allow_ainput_password` was ignored before this commit
because it was forgotten about during refactoring
2026-09-09 00:53:33 +03:00
90c5ae7a78 Updated to v0.3.0 v0.3.0 2026-09-09 00:40:08 +03:00
1ba1094a42 Refactoring 2026-09-09 00:33:26 +03:00
0ea2b0e51a Updated to v0.2.0 v0.2.0 2026-09-07 01:18:06 +03:00
Nikita Tyukalov, ASUS, Linux
363b9a3d45 Image/video support. Related upgrades.
- Removed `_check_and_remove_html`. Using `_process_html_text` instead
- Added method for file uploading `_upload_file`
- Added method for raw bytes uploading `_upload_provider`
- Added method for thumbnail uploading `_upload_thumbnail`
- Added method that sends `content` JSON to the room using `m.room.message` type
- Fixed `self._debug_event_callback` not being called in `_callback_filter_router`
- Fixed type hints in `add_event_callback`
- Removed `kwargs` from `send_text_to_room`
- Added `send_image_to_room`
- Added `send_video_to_room`
- Added `auto_ffprobe` and `auto_ffmpeg` to `MatrixBotConfig`
- Added `VideoFileProperties` dataclass
2026-09-07 01:10:13 +03:00
Nikita Tyukalov, ASUS, Linux
bc3a7500e2 Filters fixes and updates
- Removed leftover `print` in `TextStartsWithFilter.__call__`
- Fixed broken `CompoundEventFilter.__repr__`
- Fixed typo in `TextContainsFilter.__repr__`
- Fixed text returned by `TextFilter.__repr__`, `FormattedTextFilter.__repr__`
- Fixed type error in `TextFilter.__call__`, `FormattedTextFilter.__call__`
- Added `any_case` setting for `TextContainsFilter`, `TextStartsWithFilter`, `TextEndsWithFilter`
2026-09-07 01:02:38 +03:00
Nikita Tyukalov, ASUS, Linux
8dd1f55fdd Added *.vscode to .gitignore 2026-09-07 00:56:05 +03:00
b62473c468 Updated README v0.1.0 2026-09-02 18:24:24 +03:00
d8bf1818d7 Updated to v0.1.0, added event filters 2026-09-02 18:20:48 +03:00
d41b588adc Updated to 0.0.2. Fixed "invalid room" bug
`2026-matrix-csonac` (it uses this package) failed to send messages to the room after bot restart. The problem would go away if the bot received some message in the room it was trying to send a message to. This commit fixes the problem.
- Added `load_store` (issue #1)
- Added `full_state=True` to sync_forever
v0.0.2
2026-09-02 13:54:55 +03:00
Nikita Tyukalov, ASUS, Linux
c3046307c7 README update v0.0.1 2026-08-25 09:48:13 +03:00
Nikita Tyukalov, ASUS, Linux
e5a3533f4b Source files moved from 2026-matrix-csonac 2026-08-24 21:35:02 +03:00
Nikita Tyukalov, ASUS, Linux
793ef5ee1c Fixed invalid pyproject.toml 2026-08-24 20:43:50 +03:00