Skip to content

Commit d5e2293

Browse files
authored
Add update profile example (#120)
1 parent 9426d77 commit d5e2293

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import os
2+
3+
from atproto import Client, models
4+
5+
6+
def main():
7+
client = Client()
8+
client.login(os.environ['USERNAME'], os.environ['PASSWORD'])
9+
10+
current_profile_record = client.com.atproto.repo.get_record(
11+
models.ComAtprotoRepoGetRecord.Params(
12+
collection=models.ids.AppBskyActorProfile,
13+
repo=client.me.did,
14+
rkey='self',
15+
)
16+
)
17+
current_profile = current_profile_record.value
18+
19+
# set new values to update
20+
new_description = None
21+
new_display_name = 'I love Python'
22+
23+
client.com.atproto.repo.put_record(
24+
models.ComAtprotoRepoPutRecord.Data(
25+
collection=models.ids.AppBskyActorProfile,
26+
repo=client.me.did,
27+
rkey='self',
28+
swapRecord=current_profile_record.cid,
29+
record=models.AppBskyActorProfile.Main(
30+
avatar=current_profile.avatar,
31+
banner=current_profile.banner,
32+
description=new_description or current_profile.description,
33+
displayName=new_display_name or current_profile.display_name,
34+
),
35+
)
36+
)
37+
38+
39+
if __name__ == '__main__':
40+
main()

0 commit comments

Comments
 (0)