-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrandomizer.py
More file actions
44 lines (36 loc) · 1.57 KB
/
Copy pathrandomizer.py
File metadata and controls
44 lines (36 loc) · 1.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# На модуль распространяется лицензия "GNU General Public License v3.0"
# https://github.com/all-licenses/GNU-General-Public-License-v3.0
# scope: hikka_only
# meta developer: @pymodule
# meta fhsdesc: tool, tools, random
from .. import loader, utils
import random
from hikkatl.types import Message
@loader.tds
class RandomizerMod(loader.Module):
"""Randomly selects one of the comma-separated values."""
strings = {
"name": "Randomizer",
"too_few_values": "Please provide at least two values separated by commas.",
"result": "Random choice: {result}"
}
strings_ru = {
"name": "Рандомайзер",
"too_few_values": "Укажи хотя бы два значения через запятую.",
"result": "Случайный выбор: {result}"
}
@loader.command(
doc="Picks a random value from those listed (comma-separated)",
ru_doc="Выбирает случайное значение из перечисленных через запятую"
)
async def randomizecmd(self, message: Message):
args = utils.get_args_raw(message)
if not args:
await utils.answer(message, self.strings("too_few_values"))
return
items = [item.strip() for item in args.split(",") if item.strip()]
if len(items) < 2:
await utils.answer(message, self.strings("too_few_values"))
return
result = random.choice(items)
await utils.answer(message, self.strings("result").format(result=result))