Comments, Friend Requests and Messages¶
gd.py implements reading, sending and interacting with comments, friend requests and messages:
client = gd.Client()
# we can only read comments if we are not logged in.
await client.login('username', 'password')
nekit = await client.search_user('nekitdev')
# <User account_id=5509312 id=17876467 name='nekitdev' ...>
for comment in await nekit.get_comments():
print(comment.body)
# find some featured level by user
levels = await nekit.get_levels()
level = gd.utils.find(lambda level: level.is_featured(), levels)
# if found, print comments and post a comment
if level is not None:
for comment in level.get_comments():
print(comment)
await level.comment('gd.py testing')
# print some messages
for message in await client.get_messages():
print(message.author.name, message.subject)
# send a friend request
await nekit.send_friend_request('<sent-from-gd.py>')
# post a comment
await client.post_comment('This comment is posted using gd.py')
Comment¶
-
class
gd.
Comment
(*, client: gd.client.Client = None, **options)[source]¶ Class that represents a Profile/Level comment in Geometry Dash. This class is derived from
AbstractEntity
.An author of the comment.
- Type
-
type
¶ Whether comment is on profile or on a level.
- Type
-
is_spam
() → bool[source]¶ bool
: Indicates whether a comment is marked as spam.False
if profile comment.
-
await
like
() → None[source]¶ This function is a coroutine.
Likes a comment.
- Raises
MissingAccess – Failed to like a comment.
-
await
dislike
() → None[source]¶ This function is a coroutine.
Dislikes a comment.
- Raises
MissingAccess – Failed to dislike a comment.
-
await
delete
() → None[source]¶ This function is a coroutine.
Deletes a comment from Geometry Dash servers.
Obviously, only comments of client logged in using
Client.login()
can be deleted.The normal behaviour of the server is returning 1 if comment was deleted, so the error is raised on response != 1.
- Raises
MissingAccess – Server did not return 1, which means comment was not deleted.
Friend Request¶
-
class
gd.
FriendRequest
(*, client: gd.client.Client = None, **options)[source]¶ Class that represents a friend request. This class is derived from
AbstractEntity
.An author of the friend request.
- Type
-
recipient
¶ A recipient of the friend request.
- Type
-
type
¶ Whether request is incoming or sent.
- Type
-
await
read
() → None[source]¶ This function is a coroutine.
Read a friend request. Sets
is_read
toTrue
on success.- Raises
MissingAccess – Failed to read a request.
-
await
delete
() → None[source]¶ This function is a coroutine.
Delete a friend request.
- Raises
MissingAccess – Failed to delete a request.
-
await
accept
() → None[source]¶ This function is a coroutine.
Accept a friend request.
- Raises
MissingAccess – Failed to accept a request.
Message¶
-
class
gd.
Message
(*, client: gd.client.Client = None, **options)[source]¶ Class that represents private messages in Geometry Dash. This class is derived from
AbstractEntity
.An author of the message.
- Type
-
recipient
¶ A recipient of the message.
- Type
-
type
¶ Whether a message is sent or inbox.
- Type
-
body
¶ A body of the message. Requires
Message.read()
.- Type
Optional[
str
]
-
await
read
() → str[source]¶ This function is a coroutine.
Read a message. Set the body of the message to the content.
- Returns
The content of the message.
- Return type
-
await
reply
(content: str, schema: Optional[str] = None) → None[source]¶ This function is a coroutine.
Reply to the message. Format the subject according to schema.
Schema format can only contain
{message.attr}
elements.Content also allows schema format.
Example:
await message.reply( content='Replying to message by {message.author.name}.' schema='Re: {message.subject} ({message.rating})' )
-
await
delete
() → None[source]¶ This function is a coroutine.
Delete a message.
- Raises
MissingAccess – Failed to delete a message.