Skip to content

Converters

Gaung Ramadhan edited this page Sep 5, 2021 · 1 revision

~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.

~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.

~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.

~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.