slackminion.plugin package

Submodules

slackminion.plugin.base module

class slackminion.plugin.base.BasePlugin(bot: Bot, **kwargs)[source]

Bases: object

at_user(*args, **kwargs)[source]
get_channel(channel)[source]

Utility function to query slack for a particular channel

Parameters:channel – The channel name or id of the channel to lookup
Returns:SlackChannel object or None
get_channel_by_name(channel_name)[source]

Utility function to query slack for a particular channel

Parameters:channel – The channel name of the channel to lookup
Returns:SlackChannel object or None
get_user(user_id)[source]

Utility function to query slack for a particular user

Parameters:user_id – The username of the user to lookup
Returns:SlackUser object or None
notify_event_types = []
on_connect()[source]

Executes immediately after connecting to slack.

Will not fire on reconnects.

on_load()[source]

Executes when a plugin is loaded.

Override this if your plugin needs to do initialization when loading. Do not use this to restore runtime changes to variables – they will be overwritten later on by PluginManager.load_state()

on_unload()[source]

Executes when a plugin is unloaded.

Override this if your plugin needs to do cleanup when unloading.

run_async(func, *args, **kwargs)[source]
send_message(channel, text, thread=None, reply_broadcast=False, parse=None)[source]

Used to send a message to the specified channel.

  • channel - can be a channel or user
  • text - message to send
  • thread - thread to reply in
  • reply_broadcast - whether or not to also send the message to the channel
  • parse - Set to “full” for the slack api to linkify names and channels
start_periodic_task(duration, func, *args, **kwargs)[source]

Schedules a function to be called after some period of time.

  • duration - time in seconds to wait before firing
  • func - function to be called
  • args - arguments to pass to the function
start_timer(duration, func, *args, **kwargs)[source]

Schedules a function to be called after some period of time.

  • duration - time in seconds to wait before firing
  • func - function to be called
  • args - arguments to pass to the function
stop_timer(func)[source]

Stops a timer if it hasn’t fired yet

  • func - the function passed in start_timer

slackminion.plugin.manager module

class slackminion.plugin.manager.PluginManager(bot: Bot, test_mode=False)[source]

Bases: object

broadcast_event(event_type, data)[source]
connect()[source]
load()[source]
load_state(*args, **kwargs)[source]
save_state(*args, **kwargs)[source]
unload_all()[source]

Module contents

slackminion.plugin.cmd(admin_only=False, acl='*', aliases=None, while_ignored=False, reply_in_thread=False, reply_broadcast=False, parse=None, strip_formatting=False, *args, **kwargs)[source]

Decorator to mark plugin functions as commands in the form of !<cmd_name>

  • admin_only - indicates only users in bot_admin are allowed to execute (only used if AuthManager is loaded)
  • acl - indicates which ACL to perform permission checks against (only used if AuthManager is loaded)
  • aliases - register function with additional commands (i.e. !alias1, !alias2, etc)
  • while_ignored - allows a command to be run, even if channel has been !sleep
  • reply_in_thread - determines whether bot replies in the channel or a thread
  • reply_broadcast - if replying in a thread, whether to also send the message to the channel
  • parse - Set to “full” for the slack api to linkify names and channels
  • strip_formatting - Remove formtting added by slack to the messages
slackminion.plugin.webhook(*args, **kwargs)[source]

Decorator to mark plugin functions as entry points for web calls

  • route - web route to register, uses Flask syntax
  • method - GET/POST, defaults to POST