Converter

You can see detailed converter use on this page.

A converter class that handles the conversion of Context to desired type.

class Anjani.util.converter.Converter

Base class of custom converters that require the ~Context to be passed.

Class that derived this base converter need to have the __call__ to do the conversion. This method should also be a coroutine.

async def __call__()

The base method that should be overrided and will be called on conversion.

Parameters:

  • ctx (~Context): The command invocation context that the argument used in.
  • arg (str): The argument that is being converted.

class Anjani.util.converter.UserConverter

Converts to a ~pyrogram.types.User.

Conversion priority:

  1. By user id.
  2. By username.
  3. By text mention.

async def __call__()

The base method that should be overrided and will be called on conversion.

Parameters:

  • ctx (~Context): The command invocation context that the argument used in.
  • arg (str): The argument that is being converted.

class Anjani.util.converter.ChatConverter

Converts to a ~pyrogram.types.ChatMember.

Conversion priority:

  1. By chat id.
  2. By chat username (with '@').
  3. By chat username (without '@').

async def __call__()

The base method that should be overrided and will be called on conversion.

Parameters:

  • ctx (~Context): The command invocation context that the argument used in.
  • arg (str): The argument that is being converted.

class Anjani.util.converter.ChatMemberConverter

Converts to a ~pyrogram.types.ChatMember.

Conversion priority:

  1. By user id.
  2. By username.
  3. By text mention.

async def __call__()

The base method that should be overrided and will be called on conversion.

Parameters:

  • ctx (~Context): The command invocation context that the argument used in.
  • arg (str): The argument that is being converted.