Class that all plugins derive from.
Method called at the creation of the plugin.
Do not override __init__ and use this instead.
Method called before the destruction of the plugin.
Use it to erase or save things before the plugin is disabled.
The Poezio Core object. Use it carefully.
Each plugin inheriting BasePlugin has an api member variable, which refers to a PluginAPI object.
The PluginAPI object is an a interface through which the BasePlugin (and inheritors) should go to interact with poezio. If it is not sufficient, then the core member can be used.
The public API exposed to the plugins. Its goal is to limit the use of the raw Core object as much as possible.
Add a global command.
Parameters: |
|
---|---|
Raises Exception: | |
If the command already exists. |
Add an event handler for a poezio event.
Parameters: |
---|
A complete list of those events can be found at http://poezio.eu/doc/en/dev/events.html
Associate a global binding to a handler.
Parameters: |
|
---|---|
Raises Exception: | |
If the binding is already present. |
Add an event handler for a sleekxmpp event.
Parameters: |
|
---|
A list of the SleekXMPP events can be found here http://sleekxmpp.com/event_index.html
Add a command to only one type of tab.
Parameters: |
|
---|---|
Raises Exception: | |
If the command already exists. |
Associate a binding to a handler, but only for a certain tab type.
Parameters: |
|
---|
Schedule a timed event.
Parameters: | event (timed_events.TimedEvent) – The timed event to schedule. |
---|
Create a delayed event, but do not schedule it; add_timed_event() must be used for that.
A delayed event is a timed event with a delay from the time this function is called (instead of a datetime).
Parameters: |
|
---|---|
Returns: | The created event. |
Return type: |
Create a timed event, but do not schedule it; add_timed_event() must be used for that.
Parameters: |
|
---|---|
Returns: | The created event. |
Return type: |
Remove a global command.
Parameters: | name (str) – The name of the command to remove. That command _must_ have been added by the same plugin |
---|
Remove a handler for a poezio event.
Parameters: |
|
---|
Remove a global binding.
Parameters: | key (str) – The binding to remove. |
---|
Remove a handler for a SleekXMPP event
Parameters: |
|
---|
Remove a tab-specific command.
Parameters: |
|
---|
Remove a binding added with add_tab_key
Parameters: |
|
---|
Get all the Messages of the current Tab.
Returns: | The list of text_buffer.Message objects. |
---|---|
Returns: | None if the Tab does not inherit from ChatTab. |
Return type: | list |
Display a new message in the information buffer.
Parameters: |
---|
Unschedule a timed event.
Parameters: | event (timed_events.TimedEvent) – The event to unschedule. |
---|
Example 1: Add a simple command that sends “Hello World!” into the conversation
class Plugin(BasePlugin):
def init(self):
self.add_command('hello', self.command_hello, "Send 'Hello World!'")
def command_hello(self, arg):
self.core.send_message('Hello World!')
Example 2: Adds an event handler that sends “tg” to a groupchat when a message is received from someone named “Partauche”
class Plugin(BasePlugin):
def init(self):
self.add_event_handler('muc_msg', self.on_groupchat_message)
def on_groupchat_message(self, message, tab):
if message['mucnick'] == "Partauche":
tab.command_say('tg')