Archived
1
0
Fork 0
This repository has been archived on 2024-04-26. You can view files and clone it, but cannot push or open issues or pull requests.
akari-bot/modules/ask/tools/random.py

35 lines
739 B
Python
Raw Normal View History

2023-04-08 05:22:26 +00:00
import secrets
import uuid
from .utils import AkariTool, parse_input
2023-04-19 07:41:39 +00:00
2023-06-20 07:29:56 +00:00
async def random_number(max: int, min: int):
random = secrets.randbelow(max - min + 1) + min
2023-04-08 05:22:26 +00:00
return random
2023-06-20 07:29:56 +00:00
async def random_choice(input: list[str]):
2023-04-08 05:22:26 +00:00
parsed = parse_input(input)
return secrets.choice(parsed)
2023-06-20 07:29:56 +00:00
async def random_uuid():
2023-04-08 05:22:26 +00:00
return uuid.uuid4()
2023-06-20 07:29:56 +00:00
random_number_tool = AkariTool.from_function(
2023-04-08 05:22:26 +00:00
func=random_number,
2023-06-20 07:29:56 +00:00
description='Generates a random number based on a max value and a min value.'
2023-04-08 05:22:26 +00:00
)
2023-06-20 07:29:56 +00:00
random_choice_tool = AkariTool.from_function(
2023-04-08 05:22:26 +00:00
func=random_choice,
2023-06-20 07:29:56 +00:00
description='Randomly chooses a input item.'
2023-04-08 05:22:26 +00:00
)
2023-06-20 07:29:56 +00:00
random_uuid_tool = AkariTool.from_function(
2023-04-08 05:22:26 +00:00
func=random_uuid,
2023-06-20 07:29:56 +00:00
description='Generates a random UUID.'
2023-04-08 05:22:26 +00:00
)