peony.commands package

peony.commands.event_handlers module

class peony.commands.event_handlers.EventHandler(func, event, prefix=None, strict=False)[source]

Bases: peony.commands.tasks.Task

classmethod event_handler(event, prefix=None, **values)[source]
class peony.commands.event_handlers.EventStream(client)[source]

Bases: abc.ABC

start()[source]
stream_request()[source]
class peony.commands.event_handlers.EventStreams[source]

Bases: list

check_setup(client)[source]
get_task(client)[source]
get_tasks(client)[source]
setup(client)[source]

peony.commands.event_types module

class peony.commands.event_types.Event(func, name)[source]

Bases: object

Represents an event, the handler attribute is an instance of Handler
Parameters:
  • func (callable) – a function that returns True when the data received corresponds to an event
  • name (str) – name given to the event
envelope()[source]

returns an Event that can be used for site streams

for_user()

returns an Event that can be used for site streams

class peony.commands.event_types.Events(*args, **kwargs)[source]

Bases: dict

A class to manage event handlers easily

class peony.commands.event_types.Handler(event)[source]

Bases: object

A decorator, the decorated function is used when the event is detected related to this handler is detected
Parameters:event (func) – a function that returns True when the data received corresponds to an event
with_prefix(prefix, strict=False)[source]
decorator to handle commands with prefixes
Parameters:
  • prefix (str) – the prefix of the command
  • strict (bool, optional) – If set to True the command must be at the beginning of the message. Defaults to False.
Returns:

a decorator that returns an EventHandler instance

Return type:

function

peony.commands.tasks module

class peony.commands.tasks.Task(func)[source]

Bases: object

peony.commands.tasks.task

alias of peony.commands.tasks.Task

peony.commands.utils module

peony.commands.utils.doc(func)[source]
Find the message shown when someone calls the help command
Parameters:func (function) – the function
Returns:The help message for this command
Return type:str
peony.commands.utils.permission_check(data, command_permissions, command=None, permissions=None)[source]
Check the permissions of the user requesting a command
Parameters:
  • data (dict) – message data
  • command_permissions (dict) – permissions of the command, contains all the roles as key and users with these permissions as values
  • command (function) – the command that is run
  • permissions (tuple or list) – a list of permissions for the command
Returns:

True if the user has the right permissions, False otherwise

Return type:

bool

Module contents