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

39 lines
946 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-04-08 05:22:26 +00:00
async def random_number(input: str):
parsed = parse_input(input)
random = secrets.randbelow(int(parsed[0]) - int(parsed[1]) + 1) + int(parsed[1])
return random
async def random_choice(input: str):
parsed = parse_input(input)
return secrets.choice(parsed)
async def random_uuid(input: str):
return uuid.uuid4()
random_number_tool = AkariTool(
2023-04-30 03:30:59 +00:00
name='Random Number',
2023-04-08 05:22:26 +00:00
func=random_number,
description='Generates a random number based on a max value and a min value. Requires 2 inputs, which are the max and min value.'
)
2023-04-30 03:30:59 +00:00
random_choice_tool = AkariTool(
name='Random Choice',
2023-04-08 05:22:26 +00:00
func=random_choice,
description='Randomly chooses a input item. Supports arbitrary amounts of inputs.'
)
2023-04-30 03:30:59 +00:00
random_uuid_tool = AkariTool(
name='Random UUID',
2023-04-08 05:22:26 +00:00
func=random_uuid,
description='Generates a random UUID. No input is required.'
)