-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrandomizer.py
More file actions
121 lines (99 loc) · 5.07 KB
/
randomizer.py
File metadata and controls
121 lines (99 loc) · 5.07 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
# ---------------------------------------------------------------------------------
#░█▀▄░▄▀▀▄░█▀▄░█▀▀▄░█▀▀▄░█▀▀▀░▄▀▀▄░░░█▀▄▀█
#░█░░░█░░█░█░█░█▄▄▀░█▄▄█░█░▀▄░█░░█░░░█░▀░█
#░▀▀▀░░▀▀░░▀▀░░▀░▀▀░▀░░▀░▀▀▀▀░░▀▀░░░░▀░░▒▀
# Name: randomizer
# Description: Random it your life!
# Author: @codrago_m
# ---------------------------------------------------------------------------------
# 🔒 Licensed under the GNU AGPLv3
# 🌐 https://www.gnu.org/licenses/agpl-3.0.html
# ---------------------------------------------------------------------------------
# Author: @codrago
# Commands: id, chatid, userid
# scope: hikka_only
# meta developer: @codrago_m
# meta banner: https://raw.githubusercontent.com/coddrago/modules/refs/heads/main/banner.png
# meta pic: https://envs.sh/HJy.webp
# ---------------------------------------------------------------------------------
__version__ = (1, 0, 0)
from .. import loader, utils
import random
from telethon.tl.types import InputPeerChannel
@loader.tds
class Randomizer(loader.Module):
"""Random - it's life!"""
strings = {
"name": "Randomizer",
"not_args": "<emoji document_id=5328145443106873128>✖️</emoji> Your arguments were not stated.",
"Num1": "Number 1 for RandomCMD",
"Num2": "Number 2 for RandomCMD",
"Not_chat": "<emoji document_id=5328145443106873128>✖️</emoji> This is not a chat!",
"Error_num": "<emoji document_id=5328145443106873128>✖️</emoji> Error with numbers! Check your config",
}
strings_ru = {
"not_args": "<emoji document_id=5328145443106873128>✖️</emoji> Ваши аргументы не были указаны.",
"Num1": "Число 1 для RandomCMD",
"Num2": "Число 2 для RandomCMD",
"Not_chat": "<emoji document_id=5328145443106873128>✖️</emoji> Это не чат!",
"Error_num": "<emoji document_id=5328145443106873128>✖️</emoji> Ошибка с числами! Проверьте ваш конфиг",
}
def __init__(self):
self.config = loader.ModuleConfig(
loader.ConfigValue(
"Num_1",
1,
lambda: self.strings["Num1"],
),
loader.ConfigValue(
"Num_2",
10,
lambda: self.strings["Num2"],
),
)
async def chancecmd(self, message):
"""[args] | A chance for your success!"""
args = utils.get_args_raw(message)
chance = random.randint(1, 100)
if not args:
await utils.answer(message, self.strings["not_args"])
else:
await utils.answer(message, f"<emoji document_id=5298620403395074835>🤩</emoji> The chance that {args} is equal to {chance}%!")
async def randomcmd(self, message):
"""!cfg | random number"""
min_num = min(self.config["Num_1"], self.config["Num_2"])
max_num = max(self.config["Num_1"], self.config["Num_2"])
random_num = random.randint(min_num, max_num)
if min_num >= max_num:
await utils.answer(message, self.strings["Error_Num"])
else:
await utils.answer(message, f"<emoji document_id=5406611523487411073>😇</emoji> Your random number in the range {min_num} - {max_num}: {random_num}")
async def shipcmd(self, message):
"""| Ship from iris?"""
chat = message.peer_id
channel = await self.client.get_entity(chat)
participants = await self.client.get_participants(channel)
random_user = random.choice(participants)
random_user2 = random.choice(participants)
user = random_user.id
user_name = random_user.first_name
user2 = random_user2.id
user_name2 = random_user2.first_name
loh_a = f'<a href = "tg://user?id={user}">{user_name}</a>'
loh_b = f'<a href = "tg://user?id={user2}">{user_name2}</a>'
if message.is_private:
await utils.answer(message, self.strings["Not_chat"])
else:
await utils.answer(message, f'<emoji document_id=5341674117642854617>❤️</emoji> Random ship: {loh_a} + {loh_b}\n\n<emoji document_id=5341364514925321015>🌹</emoji> Love and appreciate each other!')
async def randusercmd(self, message):
"""| Random user!"""
chat = message.peer_id
channel = await self.client.get_entity(chat)
participants = await self.client.get_participants(channel)
random_user = random.choice(participants)
user = random_user.id
user_name = random_user.first_name
if message.is_private:
await utils.answer(message, self.strings["Not_chat"])
else:
await utils.answer(message, f'<emoji document_id=5287404392654319394>🔥</emoji> Your random user: <a href = "tg://user?id={user}">{user_name}</a>')