Extending#
Creating a custom hook class#
To create a custom hook, subclass BaseHook
and implement the following methods.
handle_discord_message()
This will be called on every incoming Discord message.
Can be left as a noop, if this is an IRC only hook.
handle_irc_message()
This will be called on every incoming IRC message.
Can be left as a noop, if this is a Discord only hook.
load()
This method should load the hook into a
WalnutBot
instance.At a minimum, it should add message handling methods to
discord_hooks
andirc_hooks
respectively.
Loading a custom hook class#
To load a custom hook, you will need to create a WalnutBot
instance directly,
provide it with an appropriate Config
, and call run()
manually,
bypassing the CLI interface. To provide custom configuration options for your hook, you might need to subclass Config
.
Manual hooks#
Any method with compatible parameters can be added to discord_hooks
and irc_hooks
.
This allows use of entirely separate classes, and standalone functions.
Discord commands#
To add a Discord command, create an appropriate object, and pass it to add_discord_command()
.
Refer to documentation for discord.ext.commands and discord.py’s examples for more instructions.
Syncing currently has to be done manually after run()
is called (or at least discord
is started).