mirror of
https://github.com/LiteyukiStudio/nonebot-plugin-marshoai.git
synced 2024-11-23 21:41:07 +08:00
17 lines
548 B
Python
17 lines
548 B
Python
import random
|
|
import os
|
|
import aiohttp
|
|
import httpx
|
|
from pathlib import Path
|
|
BGIMAGE_PATH=Path('/home/asankilp/biography/User/RavenSenorita/sayings')
|
|
def choose_random():
|
|
randomfile = random.choice(list(BGIMAGE_PATH.iterdir()))
|
|
randomurl = str(randomfile)
|
|
return randomurl
|
|
async def download_file(url):
|
|
async with httpx.AsyncClient() as client:
|
|
response = await client.get(url)
|
|
response.raise_for_status() # 确保请求成功
|
|
with open("./azureaipic.png", 'wb') as f:
|
|
f.write(response.content)
|