This module contains the functions available to plugins to interact with Profanity.
The prof module must be imported
import prof
Profanity accepts both str and unicode objects as string arguments, to allow plugins to work with both Python 2 and 3.
Add values to be autocompleted by Profanity for a command, or command argument. If the key already exists, Profanity will add the items to the existing autocomplete items for that key.
Parameters: |
|
---|
Examples:
prof.completer_add("/mycommand", [
"action1",
"action2",
"dosomething"
])
prof.completer_add("/mycommand dosomething", [
"thing1",
"thing2"
])
Remove all values from autocompletion for a command, or command argument.
Parameters: | key – the prefix from which to clear the autocompletion items |
---|
Examples:
prof.completer_clear("/mycommand")
prof.completer_add("/mycommand dosomething")
Remove values from autocompletion for a command, or command argument.
Parameters: |
|
---|
Examples:
prof.completer_remove("/mycommand", [
"action1",
"action2"
])
prof.completer_add("/mycommand dosomething", [
"thing1"
])
Highlights the console window in the status bar.
Show a message indicating the command has been called incorrectly.
Parameters: | command (str or unicode) – the command name with leading slash, e.g. "/say" |
---|
Example:
prof.cons_bad_cmd_usage("/mycommand")
Show a message in the console window.
Parameters: | message (str or unicode) – the message to print |
---|
Example:
prof.cons_show("This will appear in the console window")
Show a message in the console, using the specified theme.
Themes can be must be specified in ~/.local/share/profanity/plugin_themes
Parameters: |
|
---|
Example:
prof.cons_show_themed("myplugin", "text", None, "Plugin themed message")
Determine whether or not the Console window is currently focussed.
Returns: | True if the user is currently in the Console window, False otherwise. |
---|---|
Return type: | boolean |
Add a service discovery feature the list supported by Profanity.
If a session is already connected, a presence update will be sent to allow any client/server caches to update their feature list for Profanity
Parameters: | feature (str) – the service discovery feature to be added |
---|
Example:
prof.disco_add_feature("urn:xmpp:omemo:0:devicelist+notify")
Retrieve the Jabber ID of the current room, when in a chat room window.
Returns: | the Jabber ID of the current chat room e.g. "metalchat@conference.chat.org", or None if not in a chat room window. |
---|---|
Return type: | str |
Retrieve the users nickname in a chat room, when in a chat room window.
Returns: | the users nickname in the current chat room e.g. "eddie", or None if not in a chat room window. |
---|---|
Return type: | str |
Retrieve nicknames of all occupants in a chat room, when in a chat room window.
Returns: | nicknames of all occupants in the current room or an empty list if not in a chat room window. |
---|---|
Return type: | list of str |
Retrieve the Jabber ID of the current chat recipient, when in a chat window.
Returns: | the Jabber ID of the current chat recipient e.g. "buddy@chat.org", or None if not in a chat window. |
---|---|
Return type: | str |
Trigger incoming message handling, this plugin will make profanity act as if the message has been received
Parameters: |
|
---|
Example:
prof.incoming_message("bob@server.org", "laptop", "Hello there")
Write to the Profanity log at level DEBUG.
Parameters: | message (str or unicode) – the message to log |
---|
Write to the Profanity log at level ERROR.
Parameters: | message (str or unicode) – the message to log |
---|
Write to the Profanity log at level INFO.
Parameters: | message (str or unicode) – the message to log |
---|
Write to the Profanity log at level WARNING.
Parameters: | message (str or unicode) – the message to log |
---|
Send a desktop notification.
Parameters: |
|
---|
Example:
prof.notify("Example notification for 5 seconds", 5000, "Example plugin")
Register a new command, with help information, and callback for command execution.
Profanity will do some basic validation when the command is called using the argument range.
Parameters: |
|
---|
Example:
synopsis = [
"/newcommand action1|action2",
"/newcommand print <argument>",
"/newcommand dosomething [<optional_argument>]"
]
description = "An example for the documentation"
args = [
[ "action1|action2", "Perform action1 or action2" ],
[ "print <argument>", "Print argument" ],
[ "dosomething [<optional_argument>]", "Do something, optionally with the argument" ]
]
examples = [
"/newcommand action1",
"/newcommand print \"Test debug message\"",
"/newcommand dosomething"
]
prof.register_command("/newcommand", 1, 2, synopsis, description, args, examples, my_function)
Register a function that Profanity will call periodically.
Parameters: |
|
---|
Example:
prof.register_timed(some_function, 30)
Send a line of input to Profanity to execute.
Parameters: | line (str or unicode) – the line to send |
---|
Example:
prof.send_line("/who online")
Send an XMPP stanza
Parameters: | stanza (str or unicode) – An XMPP stanza |
---|---|
Returns: | True if the stanza was sent successfully, False otherwise |
Return type: | boolean |
Example:
prof.send_stanza("<iq to='juliet@capulet.lit/balcony' id='s2c1' type='get'><ping xmlns='urn:xmpp:ping'/></iq>")
Get a boolean setting
Settings must be specified in ~/.local/share/profanity/plugin_settings
Parameters: |
|
---|
Example:
prof.settings_get_boolean("myplugin", "notify", False)
Set a boolean setting
Settings must be specified in ~/.local/share/profanity/plugin_settings
Parameters: |
|
---|
Example:
prof.settings_set_boolean("myplugin", "activate", True)
Get an integer setting
Settings must be specified in ~/.local/share/profanity/plugin_settings
Parameters: |
|
---|
Example:
prof.settings_get_int("myplugin", "timeout", 10)
Set an integer setting
Settings must be specified in ~/.local/share/profanity/plugin_settings
Parameters: |
|
---|
Example:
prof.settings_set_int("myplugin", "timeout", 100)
Get a string setting
Settings must be specified in ~/.local/share/profanity/plugin_settings
Parameters: |
|
---|
Example:
prof.settings_get_string("myplugin", "prefix", "prefix-->")
Add an item to a string list setting
Settings must be specified in ~/.local/share/profanity/plugin_settings
If the list does not exist, a new one will be created with the element added
Parameters: |
|
---|
Example:
prof.settings_string_list_add("someplugin", "somelist", "anelement")
Remove all items from a string list setting
Settings must be specified in ~/.local/share/profanity/plugin_settings
Parameters: |
|
---|---|
Returns: | True if the list was cleared, False if the list does not exist |
Return type: | boolean |
Example:
prof.settings_string_list_remove_all("someplugin", "somelist")
Get a string list setting
Settings must be specified in ~/.local/share/profanity/plugin_settings
The string list setting items are separated by semicolons.
Parameters: |
|
---|---|
Returns: | the list setting |
Return type: | list of str or unicode |
Example:
prof.settings_get_string_list("someplugin", "somelist")
Remove an item from a string list setting
Settings must be specified in ~/.local/share/profanity/plugin_settings
Parameters: |
|
---|---|
Returns: | True if the item was removed, or is not in the list, False if the list does not exist |
Return type: | boolean |
Example:
prof.settings_string_list_remove("someplugin", "somelist", "anelement")
Set a string setting
Settings must be specified in ~/.local/share/profanity/plugin_settings
Parameters: |
|
---|
Example:
prof.settings_set_string("myplugin", "prefix", "myplugin, ")
Create a plugin window.
Parameters: |
|
---|
Example:
prof.win_create("My Plugin", window_handler)
Determine whether or not a plugin window currently exists for the tag.
Parameters: | tag (str or unicode) – The tag used when creating the plugin window |
---|---|
Returns: | True if the window exists, False otherwise. |
Return type: | boolean |
Example:
prof.win_exists("My Plugin")
Focus a plugin window.
Parameters: | tag (str or unicode) – The tag of the window to focus |
---|
Example:
prof.win_focus("My Plugin")
Show a message in the plugin window.
Parameters: |
|
---|
Example:
prof.win_show("My Plugin", "This will appear in the plugin window")
Show a message in the plugin window, using the specified theme.
Themes must be specified in ~/.local/share/profanity/plugin_themes
Parameters: |
|
---|
Example:
prof.win_show_themed("My Plugin", "myplugin", "text", None, "Plugin themed message")