Users¶
User system is one of the main parts of GD Server API. gd.py provides convenient interface for simplifying interaction with them via modern pythonic code.
Here is a quick example of interacting with users:
client = gd.Client()
user = await client.get_user(71)
# <User account_id=71 id=16 name='RobTop' ...>
for comment in await user.get_comment_history(pages=range(20)):
print(comment.id, comment.rating, comment.body)
User¶
-
class
gd.
AbstractUser
(*, client: gd.client.Client, **options)[source]¶ Class that represents an Abstract Geometry Dash User. This class is derived from
AbstractEntity
.-
as_user
() → gd.abstractuser.AbstractUser[source]¶ Returns
AbstractUser
object.This is used mainly in subclasses.
- Returns
Abstract User from given object.
- Return type
-
await
to_user
() → gd.user.User[source]¶ This function is a coroutine.
Convert
self
toUser
object.- Returns
A user object corresponding to the abstract one.
- Return type
-
await
send
(subject: str, body: str) → Optional[gd.message.Message][source]¶ This function is a coroutine.
Send the message to
self
. Requires logged client.- Parameters
- Raises
MissingAccess – Failed to send a message.
- Returns
Sent message.
- Return type
Optional[
Message
]
-
await
block
() → None[source]¶ This function is a coroutine.
Block a user. Requires logged in client.
- Raises
MissingAccess – Failed to block a user.
-
await
unblock
() → None[source]¶ This function is a coroutine.
Unblock a user. Requires logged in client.
- Raises
MissingAccess – Failed to unblock a user.
-
await
unfriend
() → None[source]¶ This function is a coroutine.
Try to unfriend a user. Requires logged in client.
- Raises
MissingAccess – Failed to unfriend a user.
-
await
send_friend_request
(message: str = '') → Optional[gd.friend_request.FriendRequest][source]¶ This function is a coroutine.
Send a friend request to a user.
Note
This function does not raise any error if request was already sent.
- Parameters
message (
str
) – A message to attach to a request.- Raises
MissingAccess – Failed to send a friend request to user.
- Returns
Sent friend request.
- Return type
Optional[
FriendRequest
]
-
await
get_levels_on_page
(page: int = 0, *, exclude: Tuple[Type[BaseException]] = (<class 'gd.errors.NothingFound'>, )) → List[gd.level.Level][source]¶ This function is a coroutine.
Fetches user’s levels on a given page.
This function is equivalent to calling:
await self.client.search_levels_on_page( page=page, filters=gd.Filters.setup_by_user(), user=self, exclude=exclude ) # 'self' is an AbstractUser instance here.
- Parameters
page (
int
) – Page to look for levels at.exclude (Tuple[Type[
BaseException
]]) – Exceptions to ignore. By default includes onlyNothingFound
.
- Returns
All levels found. Can be an empty list.
- Return type
List[
Level
]
-
await
get_levels
(pages: Iterable[int] = range(0, 10)) → List[gd.level.Level][source]¶ This function is a coroutine.
Gets levels on specified pages.
This is equivalent to calling:
return await self.client.search_levels( pages=pages, filters=gd.Filters.setup_by_user(), user=self ) # where 'self' is an AbstractUser instance.
-
await
get_page_comments
(page: int = 0, exclude: Tuple[Type[BaseException]] = (<class 'gd.errors.NothingFound'>, )) → List[gd.comment.Comment][source]¶ This function is a coroutine.
Gets user’s profile comments on a specific page.
This is equivalent to:
await self.retrieve_page_comments('profile', page, exclude=exclude)
-
await
get_page_comment_history
(strategy: Union[int, str, gd.utils.enums.CommentStrategy] = 0, page: int = 0, exclude: Tuple[Type[BaseException]] = (<class 'gd.errors.NothingFound'>, )) → List[gd.comment.Comment][source]¶ This function is a coroutine.
Retrieves user’s level comments. (history)
Equivalent to calling:
await self.retrieve_page_comments('profile', page, strategy=strategy, exclude=exclude)
-
await
get_comments
(pages: Optional[Iterable[int]] = range(0, 10)) → List[gd.comment.Comment][source]¶ This function is a coroutine.
Gets user’s profile comments on specific pages.
This is equivalent to the following:
await self.retrieve_comments('profile', pages)
-
await
get_comment_history
(strategy: Union[int, str, gd.utils.enums.CommentStrategy] = 0, pages: Optional[Iterable[int]] = range(0, 10)) → List[gd.comment.Comment][source]¶ This function is a coroutine.
Gets user’s level (history) comments on specific pages.
This is equivalent to the following:
await self.retrieve_comments('level', pages, strategy=strategy)
-
await
retrieve_page_comments
(type: str = 'profile', page: int = 0, *, strategy: Union[int, str, gd.utils.enums.CommentStrategy] = 0, exclude: Tuple[Type[BaseException]] = (<class 'gd.errors.NothingFound'>, )) → List[gd.comment.Comment][source]¶ This function is a coroutine.
Utilizes getting comments. This is used in two other methods,
User.get_page_comments()
andUser.get_page_comment_history()
.- Parameters
type (
str
) – Type of comments to retrieve. Either ‘profile’ or ‘level’. Defaults to ‘profile’.page (
int
) – Page to look comments at.exclude (Tuple[Type[
BaseException
]]) – Exceptions to ignore. By default includes onlyNothingFound
.strategy (Union[
int
,str
,CommentStrategy
]) – A strategy to apply when searching.
- Returns
List of all comments retrieved, if comments were found.
- Return type
List[
Comment
]- Raises
NothingFound – No comments were found.
-
await
retrieve_comments
(type: str = 'profile', pages: Optional[Iterable[int]] = range(0, 10), strategy: Union[int, str, gd.utils.enums.CommentStrategy] = 0) → List[gd.comment.Comment][source]¶ This function is a coroutine.
Utilizes getting comments on specified pages.
- Parameters
type (
str
) – Type of comments to retrieve. Either ‘profile’ or ‘level’. Defaults to ‘profile’.pages (Sequence[
int
]) – Pages to look at, represented as a finite sequence, so iterations can be performed.strategy (Union[
int
,str
,CommentStrategy
]) – A strategy to apply when searching.
- Returns
List of comments found. Can be an empty list.
- Return type
List[
Comment
]
-
-
class
gd.
LevelRecord
(*, client: gd.client.Client, **options)[source]¶ Class that represents Geometry Dash User’s Level Record. This class is derived from
AbstractUser
.
-
class
gd.
UserStats
(*, client: gd.client.Client, **options)[source]¶ Class that extends
AbstractUser
, adding user’s statistics to it.
-
class
gd.
User
(*, client: gd.client.Client, **options)[source]¶ Class that represents a Geometry Dash User. This class is derived from
UserStats
.-
role
¶ A status level of the user.
- Type
-
message_policy
¶ A type indicating user’s message inbox policy.
- Type
-
friend_request_policy
¶ A type indicating user’s friend requests policy.
-
comment_policy
¶ A type indicating user’s comment history policy.
- Type
-
gd.py also provides interface to users’ icons and colors:
nekit = await client.get_user(5509312)
# <User account_id=5509312 id=17876467 name='nekitdev' ...>
Icon Set and Color¶
-
class
gd.
IconSet
(*, client: gd.client.Client = None, **options)[source]¶ Class that represents an Icon Set.
-
main
¶ ID of the main icon of the iconset. (see
IconSet.main_type
)- Type
-
await
generate
(type: Optional[Union[int, str, gd.utils.enums.IconType]] = None, as_image: bool = False) → Union[bytes, PIL.Image.Image][source]¶ This function is a coroutine.
Generate an image of an icon.
-
await
generate_many
(*types: Iterable[Union[int, str, gd.utils.enums.IconType]], as_image: bool = False) → Union[List[bytes], List[PIL.Image.Image]][source]¶ This function is a coroutine.
Generate images of icons.
- Parameters
- Returns
List of bytes or of images, based on
as_image
.- Return type
Union[List[
bytes
], List[PIL.Image.Image
]]
-
await
generate_image
(*types: Iterable[Union[int, str, gd.utils.enums.IconType]], as_image: bool = False) → Union[bytes, PIL.Image.Image][source]¶ This function is a coroutine.
Generate images of icons and connect them into one image.
-
-
class
gd.
Color
(value: int = 0)[source]¶ Represents a Color. This class is similar to a (red, green, blue)
tuple
.There is an alias for this called Colour.
-
index
¶ Returns index that represents position of the colour in
colors
.None
if the colour is not present incolors
.- Type
Optional[
int
]
-
to_rgb
() → Tuple[int, int, int][source]¶ Tuple[
int
,int
,int
]: Returns an (r, g, b) tuple representing the colour.
-
to_rgba
() → Tuple[int, int, int, int][source]¶ Tuple[
int
,int
,int
,int
]: Same asColor.to_rgb()
, but contains alpha component (always255
).
-