mirror of
https://github.com/searxng/searxng
synced 2024-01-01 19:24:07 +01:00
more andon
This commit is contained in:
parent
9ab55ea47a
commit
63b486662a
1 changed files with 21 additions and 3 deletions
|
@ -42,9 +42,6 @@ def random_color():
|
||||||
color = "%06x" % random.randint(0, 0xFFFFFF)
|
color = "%06x" % random.randint(0, 0xFFFFFF)
|
||||||
return f"#{color.upper()}"
|
return f"#{color.upper()}"
|
||||||
|
|
||||||
def random_number(x: int):
|
|
||||||
return str(random.randint(1, x))
|
|
||||||
|
|
||||||
def random_coin():
|
def random_coin():
|
||||||
return random.choice(['heads', 'tails'])
|
return random.choice(['heads', 'tails'])
|
||||||
|
|
||||||
|
@ -57,6 +54,24 @@ def random_dice():
|
||||||
def random_d20():
|
def random_d20():
|
||||||
return str(random.randint(1, 20))
|
return str(random.randint(1, 20))
|
||||||
|
|
||||||
|
def random_number(x: int):
|
||||||
|
return str(random.randint(1, x))
|
||||||
|
|
||||||
|
def random_groups(team_count: int, items: list):
|
||||||
|
if type(items) is list and len(items) < 2:
|
||||||
|
if ',' in items[0]:
|
||||||
|
items = items[0].split(',')
|
||||||
|
else:
|
||||||
|
return []
|
||||||
|
|
||||||
|
random.shuffle(items)
|
||||||
|
groups = [[] for _ in range(team_count)]
|
||||||
|
|
||||||
|
for i in range(len(items)):
|
||||||
|
groups[i % team_count].append(items[i])
|
||||||
|
|
||||||
|
return str(groups).replace("'", "")
|
||||||
|
|
||||||
random_types = {
|
random_types = {
|
||||||
'string': random_string,
|
'string': random_string,
|
||||||
'int': random_int,
|
'int': random_int,
|
||||||
|
@ -75,6 +90,9 @@ random_types = {
|
||||||
# can return a list of results (any result type) for a given query
|
# can return a list of results (any result type) for a given query
|
||||||
def answer(query):
|
def answer(query):
|
||||||
parts = query.query.split()
|
parts = query.query.split()
|
||||||
|
if len(parts) >= 4:
|
||||||
|
if parts[1] == 'groups':
|
||||||
|
return [{'answer': random_groups(int(parts[2]), parts[3:])}]
|
||||||
if len(parts) != 2:
|
if len(parts) != 2:
|
||||||
return []
|
return []
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue