disco.bot.plugin
Classes
BasePluginDeco
Functions
add_meta_deco(cls, meta)
with_config(cls, config_cls)
Sets the plugins config class to the specified config class.
listen(cls,*args,**kwargs
)
Binds the function to listen for a given event name.
listen_packet(cls,*args,**kwargs
)
Binds the function to listen for a given gateway op code.
command(cls,*args,**kwargs
)
Creates a new command attached to the function.
pre_command(cls
)
Runs a function before a command is triggered.
post_command(cls
)
Runs a function after a command is triggered.
pre_listener(cls
)
Runs a function before a listener is triggered.
post_listener(cls
)
Runs a function after a listener is triggered.
schedule(cls,*args,**kwargs
)
Runs a function repeatedly, waiting for a specified interval.
add_argument(cls,*args,**kwargs
)
Adds an argument to the argument parser.
route(cls,*args,**kwargs
)
Adds an HTTP route.
PluginDeco
Inherits From BasePluginDeco
A utility mixin which provides various function decorators that a plugin author can use to create bound event/command handlers.
Plugin
Inherits From LoggingClass
, PluginDeco
A plugin is a set of listeners/commands which can be loaded/unloaded by a bot.
Parameters
Name | Type | Description |
---|---|---|
bot | :class:`disco.bot.Bot` |
The bot this plugin is a member of. |
config | any |
The configuration data for this plugin. |
Attributes
Name | Type | Description |
---|---|---|
client | :class:`disco.client.Client` |
An alias to the client the bot is running with. |
state | :class:`disco.state.State` |
An alias to the state object for the client. |
listeners | list |
List of all bound listeners this plugin owns. |
commands | list(:class:`disco.bot.command.Command`) |
List of all commands this plugin owns. |
Functions
init(self, bot, config)
name(self
)
bind_all(self
)
bind_meta(self, member, meta)
handle_exception(self, greenlet, event)
wait_for_event(self, event_name, conditional,**kwargs)
spawn_wrap(self, spawner, method,*args,**kwargs)
spawn(self,*args,**kwargs
)
spawn_later(self, delay,*args,**kwargs)
execute(self, event)
Executes a CommandEvent this plugin owns.
register_trigger(self, typ, when, func)
Registers a trigger.
dispatch(self, typ, func, event,*args,**kwargs)
register_listener(self, func, what,*args,**kwargs)
Registers a listener.
Parameters
Name | Type | Description |
---|---|---|
what | str |
What the listener is for (event, packet) |
func | function |
The function to be registered. |
desc | The descriptor of the event/packet. |
register_command(self, func,*args,**kwargs)
Registers a command.
Parameters
Name | Type | Description |
---|---|---|
func | function |
The function to be registered. |
args | Arguments to pass onto the :class:`disco.bot.command.Command` object. | |
kwargs | Keyword arguments to pass onto the :class:`disco.bot.command.Command` object. |
register_schedule(self, func, interval, repeat, init=True)
Registers a function to be called repeatedly, waiting for an interval
Args
Name | Type | Description |
---|---|---|
func | function |
The function to be registered. |
interval | int |
Interval (in seconds) to repeat the function on. |
repeat | bool |
Whether this schedule is repeating (or one time). |
init | bool |
Whether to run this schedule once immediatly, or wait for the first scheduled iteration. |
load(self, ctx)
Called when the plugin is loaded.
unload(self, ctx)
Called when the plugin is unloaded.