nonebot-plugin-acgnshow/nonebot_plugin_acgnshow/util.py

16 lines
382 B
Python
Raw Normal View History

2024-07-11 18:26:21 +08:00
from .config import BGIMAGE_PATH
import random
import datetime
2024-07-11 18:26:21 +08:00
def choose_random_bgimage():
randomfile = random.choice(list(BGIMAGE_PATH.iterdir()))
randomurl = randomfile.as_uri()
return randomurl
def convert_timestamp(timestamp):
obj = datetime.datetime.fromtimestamp(timestamp)
formatted_time = obj.strftime('%Y-%m-%d %H:%M:%S')
return formatted_time