User¶
-
class
pyrubrum.
User
¶ Representation of a user, which behaves like a dictionary and has got, by definition, a key named
user_id
which is the unique identifier of the user.-
delete
(database: pyrubrum.database.base_database.BaseDatabase)¶ Given a database, delete this object from it.
- Parameters
database (BaseDatabase) – The database from which the user is being deleted.
-
classmethod
get
(database: pyrubrum.database.base_database.BaseDatabase, user_id: int) → pyrubrum.objects.user.User¶ Get a user from a given database seeking a key that follows this pattern:
user_[USER_ID]
- Parameters
database (BaseDatabase) – The database which is queried to seek the user.
user_id (int) – The unique identifier of the user that is being seeked.
- Returns
The retrieved user.
- Return type
-
classmethod
get_or_create
(database: pyrubrum.database.base_database.BaseDatabase, user_id: int) → pyrubrum.objects.user.User¶ Get a user from a given database, if any. Otherwise, a new user is created using the following pattern as key:
user_[USER_ID]
- Parameters
database (BaseDatabase) – The database which is queried to seek the user.
user_id (int) – The unique identifier of the user that is being seeked.
- Returns
The retrieved user.
- Return type
-
classmethod
parse
(data: str) → pyrubrum.objects.user.User¶ Automatically create a new
User
object from a JSON object.
-
classmethod
preliminary
(handler: ParameterizedBaseHandler, client: pyrogram.client.client.Client, context: Any, parameters: Dict[str, Any] = None)¶ Automatically retrieve the
User
object relying on the identifier of the user who made the query and assign it tocontext.current_user
.- Parameters
handler (BaseHandler) – The handler which coordinates the management of the menus.
client (Client) – The client which is linked to the handler.
context (CallbackQuery) – The callback query for which the button is generated.
parameters (Optional[Dict[str, Any]]) – The parameters which were passed to the handler. Defaults to
None
.
-
save
(database: pyrubrum.database.base_database.BaseDatabase)¶ Save the
User
object to the the database using the following pattern as key:user_[USER_ID]
- Parameters
database (BaseDatabase) – The database to which this object is being saved.
-