- Telegram API ID and hash now can be loaded from environment (
9c22347
)
- Parse_tgpy_message no longer returns positive result for
TGPy error>
messages (818e47d
) - Sending
cancel
in comments and topics now works correctly. Fixcancel
throwing error when the message is not a TGPy message (1d3ba1a
) - Ctx.is_manual_output is fixed (
2e591f5
)
- Describe loading of API secrets from env in guide (
eb2a023
)
- Config is no longer erased when it fails to save. Also, the config is saved synchronously now (
df539a3
) - Restart now works correctly when tgpy is not in PYTHONPATH (e.g. in a container) (
16d3830
) - The correct data directory is now used when TGPY_DATA is set to a relative path and restart is called (
f483d6c
)
- Telethon: Layer 179 (
010f4ef
) - Cd to DATA_DIR/workdir on tgpy start (
f51dc84
) - Real time progress feedback (
8e85d7a
) - Stop running message execution on
cancel
, addstop
command to only stop execution without blacklisting the message (547c1c6
) - Truncate exceptions (#39) (
739fbbc
)
- Reset page scale back to normal (
20ec126
)
- Use cryptg-anyos again, because there are no official cp312-aarch64 binaries (
50ca341
)
- docker: Run specified commands on container creation. This feature can be used for example to persist installed packages between updates (
456f503
)
- Tgpy error when editing MessageService, e.g. when deleting all messages in pm or beating your high score in games (
5d6fb5e
)
- Update telethon (fix draft constructor), update all dependencies (
a2b6064
)
- Use official cryptg (prebuilt wheels for Python 3.12), bump telethon (fixes usage of Draft), set minimum python version to 3.10 (
9e49739
)
- Support proxy (
cd6bc90
)
- Telethon: New layer fix (
8145bd3
)
- Telethon: Update to layer 166 (
a18dc0d
)
- Telethon: Fixes for the new layer and many more fixes from upstream (
800fcd5
)
- Telethon: Layer 164 (
2d0c186
)
- Revert narrowing container (
bb0bff9
) - Recipes and new homepage (
28e8eba
) - Fix transformer example (
8007b25
)
- Consistent colors in setup across all terminals (
faa625b
)
- Strip device model (
a775cc5
)
- Try to fix session termination issue by setting device_model and system_version to real values from the system (
44e1c3d
)
- Initial setup can now be interrupted with ctrl+c (
e6253c7
) - Initial setup prompts now work properly (
8713dff
)
- Deleting message no longer produces an error (
ef317d9
)
- Message editing bug (
3d1d566
)
- Update from older versions (
df11e8b
)
Major update
- restructured the code
- cancel, // now remember cancellation permanently
- reactions fix now remembers message content hashes after a restart. This means no more 'Edit message again to evaluate' messages
- implemented simple key-value store for storing various data
tgpy.api.config.get(key: str, default: JSON = None) -> JSON
tgpy.api.config.set(key: str, value: JSON)
tgpy.api.config.unset(key: str)
tgpy.api.config.save()
useful when modifying objects acquired using the .get method in place
- if the
__all__
variable is set in a module, only objects with names in that list are exported (added to variables list) ctx.is_module
is True if the code is executed as a module (on startup)ctx.is_manual_output
can be set to True to prevent the last message edit by TGPy so that you can edit it yourself- cancel, //, restart, ping, update, modules object and .await syntax are now implemented as regular modules in the
std
directory- builtin modules can be disabled with
core.disable_modules
config option (for example,tgpy.api.config.set('core.disable_modules', ['postfix_await'])
)
- builtin modules can be disabled with
- extra keys are now allowed in module metadata. They are parsed into
Module.extra
dict tgpy.api
module is now used for public API instead of thetgpy
object- moved
get_installed_version
,get_running_version
,installed_as_package
,get_user
,get_hostname
,running_in_docker
,try_await
,outgoing_messages_filter
functions totgpy.api
(tgpy.api.utils
) - new public API functions:
async parse_code(text: str) -> ParseResult(is_code: bool, original: str, transformed: str, tree: AST | None)
parse_tgpy_message(message: Message) -> MessageParseResult(is_tgpy_message: bool, code: str | None, result: str | None)
async tgpy_eval(code: str, message: Message = None, *, filename: str = None) -> EvalResult(result: Any, output: str)
- AST transformers. AST transformers are applied after code transformers
- exec hooks. Exec hooks are executed before the message is parsed and handled. Exec hooks must have the following signature:
async hook(message: Message, is_edit: bool) -> Message | bool | None
. An exec hook may edit the message using Telegram API methods and/or alter the message in place. If a hook returns Message object or alters it in place, it's used instead of the original Message object during the rest of handling (including calling other hook functions). If a hook returns True or None, execution completes normally. If a hook returns False, the rest of hooks are executed and then the handling stops without further message parsing or evaluating- Apply hooks with
tgpy.api.exec_hooks.apply(message: Message, *, is_edit: bool) -> Message | False
. This method returns False if any of the hooks returned False, Message object that should be used instead of the original one otherwise
- Apply hooks with
- new dict/list compatible transformers/hooks interface (
store_obj
is one oftgpy.api.code_transformers
,tgpy.api.ast_transformers
ortgpy.api.exec_hooks
)- add a function with
store_obj.add(name, function)
- add/replace a function with
store_obj[name] = function
- get a function with
store_obj[name or index]
- iter functions with
for name, function in store_obj
- apply transformers/hooks with
tgpy.api.code_transformers.apply(code: str) -> str
,tgpy.api.ast_transformers.apply(tree: AST) -> AST
ortgpy.api.exec_hooks.apply
(documented above)
- add a function with
- podman is now correctly detected so that tgpy doesn't try to update itself in the container
- Change in-message url to tgpy.tmat.me (
8737ca9
) - Move tokenize_string and untokenize_to_string to tgpy.api (
7d8c3b2
)
- Wrap sys.stdout instead of print to capture output + properly use contextvars (
7aa2015
)
- Don't stop on unhandled errors. They may happen when, for example, a module uses asyncio.create_task (
3584f22
)
- Update telethon (new markdown parser, html parser fixes) (
43dd76f
) - Update dependencies (layer 152) (
234dc86
)
- Handle entities properly when editing "//" message (
6d989dc
) - Specify parse_mode in error handler to support markdown global parse mode (
60cd81b
) - Use message.raw_text instead of message.text to detect // (
a85b1c8
)
- Fix IndentationError appearing for some non-code messages (
599c84f
) - docker: Add /venv/bin to path (
00be149
)
- Update readme intro (
c334669
)
- Update command saying "Already up to date" while in fact updating correctly (
9b25fe6
)
- Use MessageEntityPre with language set to 'python' to enable syntax highlighting on supported clients (e.g. WebZ). Closes #24 (
5de6ded
)
- Keep 'cancel' message when replying to other user (fixes #21) (
057231d
) - Ignore error when running code deletes the message itself (
d022450
)
- Update readme (
a321bbf
)
- Use custom telethon fork with updated layer (
91894fc
) (9c7738e
) - Transform x.await into await x (
6117421
) (fde6291
) - Better version detection, ping() builtin improvements (
265b83f
) - Allow to specify data directory via environment variable TGPY_DATA (
4d769da
)
- Setting/removing reaction no longer triggers reevaluation (#25) (
cf6e64e
) - Emojis no longer break messages markup (#10) (
20f48bc
) - Parsing of modules with triple quotes in code (
485166d
)
- Guide rewrite
- code detection: Ignore messages like "fix: fix" (
1b73815
)
- Multiple improvements (
6b9cbda
)
- code detection: Ignore messages like "cat (no)" and "fix: fix" (
75bb43e
) - Data directory path on Windows (
7d0e283
) - Print now always writes to message from which code is executed (
0e46527
) - Ctx.msg now always points to message from which code is executed (
59acde9
)
- update: Show when no updates are available (
62145ff
)
- update: Try both regular installation and --user installation (
50ffbe9
)
- update: Use --user installation when updating (
1902672
)