this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

at main 40 lines 1.9 kB view raw
1#!/usr/bin/env python3 2from typing import Optional 3from atproto import Client, models 4import argparse 5 6def main(user: str, password: str, name: str, description: str, server: str, rkey: Optional[str] = None, image: Optional[str] = None): 7 client = Client() 8 client.login(user, password) 9 avatar_blob = None 10 if image: 11 with open(image, 'rb') as f: 12 avatar_data = f.read() 13 avatar_blob = client.upload_blob(avatar_data).blob 14 response = client.com.atproto.repo.put_record(models.ComAtprotoRepoPutRecord.Data( 15 repo=client.me.did, 16 collection=models.ids.AppBskyFeedGenerator, 17 rkey=rkey, 18 record=models.AppBskyFeedGenerator.Record( 19 did=f'did:web:{server}', 20 display_name=name, 21 description=description, 22 avatar=avatar_blob, 23 created_at=client.get_current_time_iso(), 24 ) 25 )) 26 print('Feed URI :', response.uri) 27 28 29if __name__ == '__main__': 30 parser = argparse.ArgumentParser() 31 parser.add_argument("-u", "--user", help="The handle to publish the feed under. Ex: smokesignal.events") 32 parser.add_argument("-p", "--password", help="The password for the handle publishing the feed") 33 parser.add_argument("-n", "--name", help="The name of the feed. Ex: What's Hot") 34 parser.add_argument("-d", "--description", help="The description of the feed. Ex: Top trending content from the whole network") 35 parser.add_argument("-i", "--image", default=None, help="The path to the avatar image for the feed. Ex: ./path/to/avatar.jpeg") 36 parser.add_argument("-s", "--server", help="The server hostname servicing the feed. Ex: feeds.smokesignal.events") 37 parser.add_argument("-r", "--rkey", default=None, help="The rkey of a feed being updated.") 38 args = parser.parse_args() 39 main(args.user, args.password, args.name, args.description, args.server, args.rkey, args.image) 40