-
Notifications
You must be signed in to change notification settings - Fork 85
/
Copy pathamongus.py
262 lines (250 loc) · 9.88 KB
/
amongus.py
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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
import asyncio
import os
import re
from io import BytesIO
from random import choice, randint
from textwrap import wrap
from PIL import Image, ImageDraw, ImageFont
from requests import get
from telethon.utils import get_display_name
from userbot import catub
from userbot.Config import Config
from userbot.core.managers import edit_or_reply
from userbot.helpers.utils import get_user_from_event, reply_id
from userbot.plugins import ALIVE_NAME, mention
plugin_category = "extra"
async def amongus_gen(text: str, clr: int) -> str:
url = (
"https://github.com/TgCatUB/CatUserbot-Resources/raw/master/Resources/Amongus/"
)
font = ImageFont.truetype(
BytesIO(
get(
"https://github.com/TgCatUB/CatUserbot-Resources/raw/master/Resources/fonts/bold.ttf"
).content
),
60,
)
imposter = Image.open(BytesIO(get(f"{url}{clr}.png").content))
text_ = "\n".join("\n".join(wrap(part, 30)) for part in text.split("\n"))
w, h = ImageDraw.Draw(Image.new("RGB", (1, 1))).multiline_textsize(
text_, font, stroke_width=2
)
text = Image.new("RGBA", (w + 30, h + 30))
ImageDraw.Draw(text).multiline_text(
(15, 15), text_, "#FFF", font, stroke_width=2, stroke_fill="#000"
)
w = imposter.width + text.width + 10
h = max(imposter.height, text.height)
image = Image.new("RGBA", (w, h))
image.paste(imposter, (0, h - imposter.height), imposter)
image.paste(text, (w - text.width, 0), text)
image.thumbnail((512, 512))
output = BytesIO()
output.name = "imposter.webp"
webp_file = os.path.join(Config.TEMP_DIR, output.name)
image.save(webp_file, "WebP")
return webp_file
async def get_imposter_img(text: str) -> str:
background = get(
f"https://github.com/TgCatUB/CatUserbot-Resources/raw/master/Resources/imposter/impostor{randint(1,22)}.png"
).content
font = get(
"https://github.com/TgCatUB/CatUserbot-Resources/raw/master/Resources/fonts/roboto_regular.ttf"
).content
font = BytesIO(font)
font = ImageFont.truetype(font, 30)
image = Image.new("RGBA", (1, 1), (0, 0, 0, 0))
draw = ImageDraw.Draw(image)
w, h = draw.multiline_textsize(text=text, font=font)
image = Image.open(BytesIO(background))
x, y = image.size
draw = ImageDraw.Draw(image)
draw.multiline_text(
((x - w) // 2, (y - h) // 2), text=text, font=font, fill="white", align="center"
)
output = BytesIO()
output.name = "impostor.png"
webp_file = os.path.join(Config.TEMP_DIR, output.name)
image.save(webp_file, "png")
return webp_file
@catub.cat_cmd(
pattern="amongus(?:\s|$)([\s\S]*)",
command=("amongus", plugin_category),
info={
"header": "Create a Sticker based on the popular game Among Us",
"flags": {
"1": "red",
"2": "lime",
"3": "green",
"4": "blue",
"5": "cyan",
"6": "brown",
"7": "purple",
"8": "pink",
"9": "orange",
"10": "yellow",
"11": "white",
"12": "black",
},
"usage": [
"{tr}amongus <text/reply>",
"{tr}amongus -c<colur number> <text/reply>",
],
"examples": [
"{tr}amongus gather around",
"{tr}amongus -c3 gather around",
],
},
)
async def sayliecmd(event):
text = event.pattern_match.group(1)
reply_to = await reply_id(event)
reply = await event.get_reply_message()
if not text and reply:
text = reply.raw_text
clr = re.findall(r"-c\d+", text)
try:
clr = clr[0]
clr = clr.replace("-c", "")
text = text.replace(f"-c{clr}", "")
clr = int(clr)
if clr > 12 or clr < 1:
clr = randint(1, 12)
except IndexError:
clr = randint(1, 12)
if not text:
if not reply:
return await edit_or_reply(event, f"{mention} Was a traitor!")
if not reply.text:
return await edit_or_reply(
event,
f"{_format.mentionuser(get_display_name(reply.sender) ,reply.sender.id)} Was a traitor!",
)
imposter_file = await amongus_gen(text, clr)
await event.delete()
await event.client.send_file(event.chat_id, imposter_file, reply_to=reply_to)
@catub.cat_cmd(
pattern="imposter(?:\s|$)([\s\S]*)",
command=("imposter", plugin_category),
info={
"header": "Fun images for imposter ",
"usage": "{tr}imposter <username/userid/reply>",
},
)
async def procces_img(event):
"Fun images for imposter"
remain = randint(1, 2)
imps = ["wasn`t the impostor", "was the impostor"]
text2 = f"\n{remain} impostor(s) remain."
reply_to = await reply_id(event)
user, reason = await get_user_from_event(event, noedits=True)
reply = await event.get_reply_message()
args = event.pattern_match.group(1)
if not user:
try:
if args or reply:
user = await event.client.get_entity(args or reply.sender_id)
else:
user = await event.client.get_me()
text = f"{get_display_name(user)} {choice(imps)}."
text += text2
except Exception:
text = args
else:
text = f"{get_display_name(user)} {choice(imps)}."
text += text2
imposter_file = await get_imposter_img(text)
await event.delete()
await event.client.send_file(event.chat_id, imposter_file, reply_to=reply_to)
@catub.cat_cmd(
pattern="imp(|n) ([\s\S]*)",
command=("imp", plugin_category),
info={
"header": "Find imposter with stickers animation.",
"description": "Imp for imposter impn for not imposter",
"usage": ["{tr}imp <name>", "{tr}impn <name>"],
"examples": ["{tr}imp blabla", "{tr}impn blabla"],
},
)
async def _(event):
"Find imposter with stickers animation."
USERNAME = f"tg://user?id={event.client.uid}"
name = event.pattern_match.group(2)
cmd = event.pattern_match.group(1).lower()
text1 = await edit_or_reply(event, "Uhmm... Something is wrong here!!")
await asyncio.sleep(2)
await text1.delete()
stcr1 = await event.client.send_file(
event.chat_id, "CAADAQADRwADnjOcH98isYD5RJTwAg"
)
text2 = await event.reply(
f"**[{ALIVE_NAME}]({USERNAME}) :** I have to call discussion"
)
await asyncio.sleep(3)
await stcr1.delete()
await text2.delete()
stcr2 = await event.client.send_file(
event.chat_id, "CAADAQADRgADnjOcH9odHIXtfgmvAg"
)
text3 = await event.reply(
f"**[{ALIVE_NAME}]({USERNAME}) :** We have to eject the imposter or will lose "
)
await asyncio.sleep(3)
await stcr2.delete()
await text3.delete()
stcr3 = await event.client.send_file(
event.chat_id, "CAADAQADOwADnjOcH77v3Ap51R7gAg"
)
text4 = await event.reply("**Others :** Where??? ")
await asyncio.sleep(2)
await text4.edit("**Others :** Who?? ")
await asyncio.sleep(2)
await text4.edit(
f"**[{ALIVE_NAME}]({USERNAME}) :** Its {name} , I saw {name} using vent,"
)
await asyncio.sleep(3)
await text4.edit(f"**Others :**Okay.. Vote {name} ")
await asyncio.sleep(2)
await stcr3.delete()
await text4.delete()
stcr4 = await event.client.send_file(
event.chat_id, "CAADAQADLwADnjOcH-wxu-ehy6NRAg"
)
catevent = await event.reply(f"{name} is ejected.......")
await asyncio.sleep(2)
await catevent.edit("ඞㅤㅤㅤㅤ ㅤㅤㅤㅤ")
await asyncio.sleep(0.5)
await catevent.edit("ㅤඞㅤㅤㅤㅤ ㅤㅤㅤ")
await asyncio.sleep(0.5)
await catevent.edit("ㅤㅤ ඞㅤㅤㅤㅤㅤㅤ")
await asyncio.sleep(0.5)
await catevent.edit("ㅤㅤㅤ ඞㅤㅤㅤㅤㅤ")
await asyncio.sleep(0.5)
await catevent.edit("ㅤㅤㅤㅤ ඞㅤㅤㅤㅤ")
await asyncio.sleep(0.5)
await catevent.edit("ㅤㅤㅤㅤㅤ ඞㅤㅤㅤ")
await asyncio.sleep(0.5)
await catevent.edit("ㅤㅤㅤㅤㅤㅤ ඞㅤㅤ")
await asyncio.sleep(0.5)
await catevent.edit("ㅤㅤㅤㅤㅤㅤㅤ ඞㅤ")
await asyncio.sleep(0.5)
await catevent.edit("ㅤㅤㅤㅤㅤㅤㅤㅤ ඞ")
await asyncio.sleep(0.5)
await catevent.edit("ㅤㅤㅤㅤㅤㅤㅤㅤ ㅤ")
await asyncio.sleep(0.2)
await stcr4.delete()
if cmd == "":
await catevent.edit(
f". 。 • ゚ 。 .\n . . 。 。 . \n\n . 。 ඞ 。 . • •\n\n ゚{name} was an Imposter. 。 . 。 . 。 . \n . 。 . \n ' 0 Impostor remains 。 . . 。 . 。 . 。 . . . , 。\n ゚ . . , 。 . . 。"
)
await asyncio.sleep(4)
await catevent.delete()
await event.client.send_file(event.chat_id, "CAADAQADLQADnjOcH39IqwyR6Q_0Ag")
elif cmd == "n":
await catevent.edit(
f". 。 • ゚ 。 .\n . . 。 。 . \n\n . 。 ඞ 。 . • •\n\n ゚{name} was not an Imposter. 。 . 。 . 。 . \n . 。 . \n ' 1 Impostor remains 。 . . 。 . 。 . 。 . . . , 。\n ゚ . . , 。 . . 。"
)
await asyncio.sleep(4)
await catevent.delete()
await event.client.send_file(event.chat_id, "CAADAQADQAADnjOcH-WOkB8DEctJAg")