Releases: tm-a-t/TGPy
Releases · tm-a-t/TGPy
v0.9.1
v0.9.0
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
)
v0.8.0
v0.7.0
v0.6.2
v0.6.1
v0.6.0
Feature
- Use MessageEntityPre with language set to 'python' to enable syntax highlighting on supported clients (e.g. WebZ). Closes #24 (
5de6ded
)
Fix
- Keep 'cancel' message when replying to other user (fixes #21) (
057231d
) - Ignore error when running code deletes the message itself (
d022450
)
Documentation
- Update readme (
a321bbf
)
v0.5.1
v0.5.0
Feature
- 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
)
Fix
- 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
)
Documentation
- Guide rewrite