Skip to content

Releases: tm-a-t/TGPy

v0.10.0

25 Sep 17:17
Compare
Choose a tag to compare

Feature

Documentation

  • Revert narrowing container (bb0bff9)
  • Recipes and new homepage (28e8eba)
  • Fix transformer example (8007b25)

v0.9.7

23 Jul 16:56
Compare
Choose a tag to compare

Fix

  • Consistent colors in setup across all terminals (faa625b)

v0.9.6

01 Jun 14:48
Compare
Choose a tag to compare

Fix

v0.9.5

01 Jun 14:42
Compare
Choose a tag to compare

Fix

  • Try to fix session termination issue by setting device_model and system_version to real values from the system (44e1c3d)

v0.9.4

05 May 17:59
Compare
Choose a tag to compare

Fix

  • Initial setup can now be interrupted with ctrl+c (e6253c7)
  • Initial setup prompts now work properly (8713dff)

v0.9.3

25 Feb 18:13
Compare
Choose a tag to compare

Fix

  • Deleting message no longer produces an error (ef317d9)

v0.9.2

25 Feb 09:57
Compare
Choose a tag to compare

Fix

v0.9.1

25 Feb 09:43
Compare
Choose a tag to compare

Fix

  • Update from older versions (df11e8b)

v0.9.0

25 Feb 09:14
Compare
Choose a tag to compare

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']))
  • 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 the tgpy object
  • moved get_installed_version, get_running_version, installed_as_package, get_user, get_hostname, running_in_docker, try_await, outgoing_messages_filter
    functions to tgpy.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
  • new dict/list compatible transformers/hooks interface (store_obj is one of tgpy.api.code_transformers, tgpy.api.ast_transformers or tgpy.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 or tgpy.api.exec_hooks.apply (documented above)
  • 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

15 Feb 17:52
Compare
Choose a tag to compare

Feature

  • Wrap sys.stdout instead of print to capture output + properly use contextvars (7aa2015)

Fix

  • Don't stop on unhandled errors. They may happen when, for example, a module uses asyncio.create_task (3584f22)