-
-
Save Higgs1/2a199ed8613b0ee7a4cad460e51bb266 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import atoot, aiohttp, PIL, io, asyncio | |
# access_token = | |
def gen_img(i): | |
img = PIL.Image.new('RGB', (500,500), (250,250,250)) | |
draw = PIL.ImageDraw.Draw(img) | |
draw.text((75, -175), str(i), (0,0,0), PIL.ImageFont.truetype("OpenSans-Bold.ttf", 600)) | |
file = io.BytesIO() | |
img.save(file, format= 'PNG') | |
file.seek(0) | |
return file | |
attachments = [gen_img(i) for i in range(4)] # critter.camp only allows a max of 4 piccies | |
print('Image gen is all done!') | |
async def upload_and_get_id(client, img_file): | |
idnum = int((await client.upload_attachment(img_file))['id']) | |
print('uploaded image', attachments.index(img_file), 'with id of', idnum) | |
return idnum | |
async with atoot.client('social.critter.camp', access_token = access_token) as client: | |
upload_jobs = [upload_and_get_id(client, img_file) for img_file in attachments] | |
attachment_ids = await asyncio.gather(*upload_jobs) | |
print('All piccies are done being uploaded') | |
await client.create_status({}, 'Test hewwo!', attachment_ids) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment