# `chatstates` – Chat State Notification support (XEP-0085)

This module provides support to implement Chat State Notifications.

## XSOs

The module registers an attribute `xep0085_chatstate` with `aioxmpp.Message` to represent the chat state notification tags, it takes values from the following enumeration (or `None` if no tag is present):

class aioxmpp.chatstates.ChatState(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)

  Enumeration of the chat states defined by XEP-0085:

  ACTIVE
  COMPOSING
  PAUSED
  INACTIVE
  GONE

## Helpers

The module provides the following helper class, that handles the state management for chat state notifications:

class aioxmpp.chatstates.ChatStateManager(strategy=None)

  Manage the state of our chat state.

  Parameters:

    strategy (a subclass of `ChatStateStrategy`) – the strategy used to decide whether to send notifications (defaults to `DiscoverSupport`)

  handle(state, message=False)

    Handle a state update.

    Parameters:

      - state (`ChatState`) – the new chat state

      - message (`bool`) – pass true to indicate that we handle the `ACTIVE` state that is implied by sending a content message.

    Returns:

      whether a standalone notification must be sent for this state update, respective if a chat state notification must be included with the message.

    Raises:

      ValueError – if message is true and a state other than `ACTIVE` is passed.

  Methods to pass in protocol level information:

  no_reply()

    Call this method if the peer did not include a chat state notification.

  reset()

    Call this method on connection reset.

Its operation is controlled by one of the chat state strategies:

class aioxmpp.chatstates.DoNotEmit

  Chat state strategy: Do not emit chat state notifications.

class aioxmpp.chatstates.DiscoverSupport

  Chat state strategy: Discover support for chat state notifications as per section 5.1 of XEP-0085.

class aioxmpp.chatstates.AlwaysEmit

  Chat state strategy: Always emit chat state notifications.