kutana.plugin module

class kutana.plugin.Plugin(name, description='')

Bases: object

Plugin provides functionality to the application.

Parameters:
  • name – Name of the plugin
  • description – Description of the plugin
on_after()

Decorator for registering coroutine to be called after an update was processed. It will be passed the update, it’s context and result of processing (kutana.handler.HandlerResponse) as arguments.

on_any_message(*args, **kwargs)
on_any_unprocessed_message(*args, **kwargs)
on_any_unprocessed_update(*args, **kwargs)
on_any_update(*args, **kwargs)
on_attachments(types, group_state='*', user_state='*', priority=0, router_priority=None)

Decorator for registering coroutine to be called when incoming update is message and have at least one attachment with one of specified types.

See kutana.plugin.Plugin.on_commands for details about ‘group_state’, ‘user_state’, ‘priority’ and ‘router_priority’.

on_before()

Decorator for registering coroutine to be called before an update will be processed. It will be passed the update and it’s context as arguments.

on_commands(commands, group_state='*', user_state='*', priority=0, router_priority=None)

Decorator for registering coroutine to be called when incoming update is message, starts with prefix and one of provided commands.

If case_insensitive is True, commands will be processed with ignored case.

Context is automatically populated with following values:

  • prefix
  • command
  • body
  • match

You can specify group_state and/or user_state to control which state must have groups and users attempting to access this coroutine.

Priority is a value that used to determine order in which coroutines are executed. Router priority is a value that used to determine the order in which routers is checked for appropriate handler. By default, most of the times, priority is 0, and router_priority is None (default value will be used).

If coroutine returns anythign but kutana.handler.HandlerResponse SKIPPED, other coroutines are not executed further.

on_exception()

Decorator for registering coroutine to be called when exception was raised while processing an update. It will be passed the update, it’s context and raised exception as arguments.

on_match(pattern, group_state='*', user_state='*', priority=0, router_priority=-3)

Decorator for registering coroutine to be called when incoming update is message and it’s text is matched by provided pattern.

Context is automatically populated with following values:

  • match

See kutana.plugin.Plugin.on_commands for details about ‘group_state’, ‘user_state’, ‘priority’ and ‘router_priority’.

on_messages(group_state='*', user_state='*', priority=0, router_priority=None)

Decorator for registering coroutine to be called when incoming update is message. This will always be called. If you want to catch all unprocessed message, you should use kutana.plugin.Plugin.on_unprocessed_messages().

See kutana.plugin.Plugin.on_commands for details about ‘group_state’, ‘user_state’, ‘priority’ and ‘router_priority’.

on_shutdown()

Decorator for registering coroutine to be called when application will be stopped. It will be passed application as an argument.

on_start()

Decorator for registering coroutine to be called when application starts. It will be passed an application as an argument.

on_unprocessed_messages(group_state='*', user_state='*', priority=0, router_priority=-3)

Decorator for registering coroutine to be called when incoming update is message. This will be called if no other coroutine processed update.

See kutana.plugin.Plugin.on_commands for details about ‘group_state’, ‘user_state’, ‘priority’ and ‘router_priority’.

on_unprocessed_updates(group_state='*', user_state='*', priority=0, router_priority=-3)

Decorator for registering coroutine to be called when incoming update is update. This will be called if no other coroutine processed update.

See kutana.plugin.Plugin.on_commands for details about ‘group_state’, ‘user_state’, ‘priority’ and ‘router_priority’.

on_updates(group_state='*', user_state='*', priority=0, router_priority=None)

Decorator for registering coroutine to be called when incoming update is not message. This will always be called. If you want to catch all unprocessed message, you should use kutana.plugin.Plugin.on_unprocessed_updates().

See kutana.plugin.Plugin.on_commands for details about ‘group_state’, ‘user_state’, ‘priority’ and ‘router_priority’.

vk