ptbtest.usergenerator module

This module provides a class to generate telegram users

class ptbtest.usergenerator.UserGenerator

Bases: PtbGenerator

User generator class. Placeholder for random names and mainly used via its get_user() method.

get_user(first_name: Optional[str] = None, last_name: Optional[str] = None, username: Optional[str] = None, user_id: Optional[int] = None) User

Returns a telegram.User object with the optionally given name(s) or username. If any of the arguments are omitted the names will be chosen randomly and the username will be generated as first_name + last_name.

Parameters
  • first_name (Optional[str]) – First name for the returned user.

  • last_name (Optional[str]) – Last name for the returned user.

  • username (Optional[str]) – Username for the returned user.

  • user_id (Optional[int]) – Id for the returned user.

Returns

A telegram user object

Return type

telegram.User