Auto-update
ZwyLib provides plugin developers with the ability to enable auto-updating for their plugins. However, the timeout between update checks is controlled only in the ZwyLib plugin settings. To enable auto-update for your plugin, you need to:
- Make a post in any public channel containing the plugin file that ZwyLib will download;
- Add a task to the ZwyLib auto-updater:
# ... metadata and zwylib import ...
class MyPlugin(BasePlugin):
def on_plugin_load(self):
update_channel_id = 123456789 # ID of the channel where the post is located
update_message_id = 11 # ID of the message with the plugin file
# add the task
zwylib.add_autoupdater_task(__id__, update_channel_id, update_message_id)
... # other plugin logicAlso, if you want to make auto-update optional, or you simply need to remove the task at some point, you can use the remove_autoupdater_task method:
zwylib.remove_autoupdater_task(__id__)If a plugin is identified as beta (its version string contains "b"), its auto-update task is skipped during checks.
zwylib.add_autoupdater_task
zwylib.add_autoupdater_task(channel_id: int, message_id: int)
zwylib.add_autoupdater_task(plugin_id: str, channel_id: int, message_id: int)Registers an auto-update task. plugin_id can be omitted entirely — ZwyLib will infer it from the call stack of the caller’s plugin file, so calling it from inside your own plugin usually only requires channel_id and message_id.
Parameters
plugin_id(str, optional): ID of the plugin the task belongs to. Inferred automatically if omitted.channel_id(int): ID of the channel where the post with the plugin file is located.message_id(int): ID of the message containing the plugin file.
Example
# both are equivalent when called from your own plugin's code
zwylib.add_autoupdater_task(__id__, 123456789, 11)
zwylib.add_autoupdater_task(123456789, 11)zwylib.remove_autoupdater_task
zwylib.remove_autoupdater_task(plugin_id: Optional[str] = None)Removes a previously registered auto-update task.
Parameters
plugin_id(Optional[str], defaultNone): ID of the plugin whose task should be removed. If omitted, ZwyLib infers it from the call stack of the caller’s plugin file.
Example
zwylib.remove_autoupdater_task(__id__)
# or, equivalently, from inside your own plugin:
zwylib.remove_autoupdater_task()