Converter
Context to be passed to be useful.
This allows you to implement converters that function similar to the special cased rebootpy classes.
Classes that derive from this should override the convert() method to do its conversion logic. This method must be a coroutine.
Methods
convert
CommandError derived exception as it will properly propagate to the error handlers.
Parameters:
ctx(Context): The invocation context that the argument is being used in.argument(str): The argument that is being converted.
Built-in Converters
UserConverter
rebootpy.User.
The lookup strategy is as follows (in order):
- Cache lookup by ID.
- Cache lookup by display name.
- API Request to fetch the user by id/display name.
PartyMemberConverter
rebootpy.PartyMember.
All lookups are done via the bots party member cache.
The lookup strategy is as follows (in order):
- Lookup by ID.
- Lookup by display name.
FriendConverter
rebootpy.Friend.
All lookups are via the friend cache.
The lookup strategy is as follows (in order):
- Lookup by ID.
- Lookup by display name.
Special Converters
Greedy
Creating Custom Converters
You can create custom converters by subclassingConverter and implementing the convert() method:
Type Hints as Converters
You can use type hints directly without creating converter classes for simple types:Basic Types
str- Default converter, returns the argument as-isint- Converts to an integerfloat- Converts to a floatbool- Converts to a boolean (accepts: yes/no, true/false, 1/0, on/off)