feat: Data and client framework
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
import random
|
||||
from typing import Optional
|
||||
|
||||
|
||||
stuff = {}
|
||||
|
||||
def register_var(name: str | None = None):
|
||||
def wrapper(coro):
|
||||
varname = name or coro.__name__
|
||||
stuff[varname] = coro
|
||||
return coro
|
||||
return wrapper
|
||||
|
||||
|
||||
@register_var('random')
|
||||
async def random_func(ctx, a: int, b: Optional[int] = None):
|
||||
if b is not None:
|
||||
low, high = a, b
|
||||
else:
|
||||
low, high = 0, a
|
||||
return random.randint(low, high)
|
||||
|
||||
@register_var('user')
|
||||
async def user_func(ctx, userstr: int | str):
|
||||
"""
|
||||
Attempt to turn the given userstr into a user.
|
||||
Currently just looks up the user directly.
|
||||
Some fuzzy matching may be appropriate in the future.
|
||||
"""
|
||||
...
|
||||
Reference in New Issue
Block a user