Skip to content

1.7.0

Choose a tag to compare

@jykob jykob released this 10 Jul 19:56
· 16 commits to main since this release

What's Changed

Plugin callbacks

Plugin callbacks allow plugins to do side-effects when the the bot instance loads your plugin.

class CallbackPlugin(plugin.TSPlugin):
    hello_command: commands.TSCommand

    async def plugin_hello(self, bot: TSBot, ctx: TSCtx):
        await bot.respond(ctx, "Hello!")

    def on_load(self, bot: TSBot):
        self.hello_command = bot.register_command("hello", self.plugin_hello)
        print("Plugin loaded")

    def on_unload(self, bot: TSBot):
        bot.remove_command(self.hello_command)
        print("Plugin unloaded")

You can define on_load and on_unload methods in your plugin, and the bot instance will call them on load/unload.
New method bot.unload_plugin() allows plugins to be unloaded from the bot.

PR: #79


Default plugins parameter

You can customize the default plugins loaded by the bot.
You can add your own plugins, remove default ones or not load any of them.

# Add your plugin as default:
bot = TSBot(
    ...
    default_plugins=(*DEFAULT_PLUGINS, CustomPlugin()),
)

# Or remove some of the default ones:
bot = TSBot(
    ...
    default_plugins=DEFAULT_PLUGINS.remove(DEFAULT_PLUGINS.help),
)

# Or disable all the default plugins:
bot = TSBot(
    ...
    default_plugins=(),
)

PR: #81


Every task immediate

bot.register_every_task() now allows you to have your task handler immediately invoked by the bot.

bot.register_every_task(60, handler, immediate=True)

PR: #76


Update command handler types

Update to typing_extensions backported some behavior to Python 3.10 that allows better typing for command handlers.

PR: #77

Full Changelog: 1.6.2...1.7.0