-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcutemessages.py
More file actions
494 lines (469 loc) · 24.4 KB
/
Copy pathcutemessages.py
File metadata and controls
494 lines (469 loc) · 24.4 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
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
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
# ______ ___ ___ _ _
# ____ | ___ \ | \/ | | | | |
# / __ \| |_/ / _| . . | ___ __| |_ _| | ___
# / / _` | __/ | | | |\/| |/ _ \ / _` | | | | |/ _ \
# | | (_| | | | |_| | | | | (_) | (_| | |_| | | __/
# \ \__,_\_| \__, \_| |_/\___/ \__,_|\__,_|_|\___|
# \____/ __/ |
# |___/
# На модуль распространяется лицензия "GNU General Public License v3.0"
# https://github.com/all-licenses/GNU-General-Public-License-v3.0
# meta developer: @pymodule
# meta fhsdesc: fun, cute, message, love
import random
import re
import logging
from .. import loader, utils
from telethon.tl.types import Message
@loader.tds
class CuteMessages(loader.Module):
"""Makes your messages extra cute with adorable styles!"""
strings = {
"name": "CuteMessages",
"ENABLED": "✅ Cute messages enabled",
"DISABLED": "❌ Cute messages disabled",
"SETTINGS_UPDATED": "Settings updated! Use .cutemessages settings to view.",
"CURRENT_SETTINGS": "Current settings:\n{settings}",
"INVALID_SETTING": "Invalid setting or value! Use .cutemessages settings for available options.",
"SETTINGS_HEADER": "Cute Messages Settings",
"ENABLE_SWITCH": "Enable cute messages",
"IGNORE_DOT_COMMANDS_SWITCH": "Ignore dot-commands (.)",
"EMOJI_FREQUENCY": "Classic effects frequency",
"TEXT_STYLE": "Text style (classic)",
"FREQUENCY_VERY_LOW": "Very Low (10%)",
"FREQUENCY_LOW": "Low (25%)",
"FREQUENCY_MEDIUM": "Medium (50%)",
"FREQUENCY_HIGH": "High (75%)",
"FREQUENCY_MAX": "Maximum (100%)",
"STYLE_EMOJIS": "Emojis only",
"STYLE_KAOMOJI": "Kaomoji (◕‿◕)",
"STYLE_SPARKLES": "Sparkles ✨",
"STYLE_FULL_CLASSIC": "All classic effects",
"ENABLE_LOWERCASE_SWITCH": "Convert to lowercase",
"ENABLE_UWU_SPEAK_SWITCH": "Enable UwU-speak (r/l → w)",
"ENABLE_UWU_SUFFIXES_SWITCH": "Add UwU suffixes (nya, owo)",
"UWU_SUFFIXES_FREQUENCY": "UwU suffix frequency",
"ENABLE_STUTTERING_SWITCH": "Enable stuttering (h-hello)",
"STUTTERING_FREQUENCY": "Stuttering frequency",
"ENABLE_VOWEL_STRETCHING_SWITCH": "Stretch vowels (cuuute)",
"VOWEL_STRETCHING_FREQUENCY": "Vowel stretching frequency",
"VOWEL_STRETCHING_MAX_LENGTH": "Max stretched vowel length",
"MAX_LENGTH_2X": "Double (x2)",
"MAX_LENGTH_3X": "Triple (x3)",
"ENABLE_CUTE_ACTIONS_SWITCH": "Add cute actions (*hugs*)",
"CUTE_ACTIONS_FREQUENCY": "Cute actions frequency",
"ACTIONS_ON_NEW_LINE": "Actions on new line",
"ENABLE_CUTE_PUNCTUATION_SWITCH": "Cute punctuation (. → .~, ? → ?✨)",
"CUTE_PUNCTUATION_FREQUENCY": "Cute punctuation frequency",
"ENABLE_SOFT_SIGN_SWITCH": "Add soft sign ('ь') to word endings (kotikь)",
"SOFT_SIGN_FREQUENCY": "Soft sign frequency",
"ENABLE_TEXT_BORDERS": "Enable text borders",
"TEXT_BORDERS_FREQUENCY": "Text borders frequency",
"THEME_SELECTOR": "Theme selector",
"THEME_RANDOM": "Random",
"THEME_PASTEL": "Pastel",
"THEME_MAGICAL": "Magical",
"THEME_NATURE": "Nature",
"ERROR_MESSAGE_CUTE": "Oopsie! 🥺 Something went wrong while trying to make the message cute... Here's the original: {original}",
}
strings_ru = {
"name": "CuteMessages",
"ENABLED": "✅ Милые сообщения включены",
"DISABLED": "❌ Милые сообщения отключены",
"SETTINGS_UPDATED": "Настройки обновлены! Используйте .cutemessages settings для просмотра.",
"CURRENT_SETTINGS": "Текущие настройки:\n{settings}",
"INVALID_SETTING": "Неверная настройка или значение! Используйте .cutemessages settings для доступных опций.",
"SETTINGS_HEADER": "Настройки милых сообщений",
"ENABLE_SWITCH": "Включить милые сообщения",
"IGNORE_DOT_COMMANDS_SWITCH": "Игнорировать команды (.)",
"EMOJI_FREQUENCY": "Частота классических эффектов",
"TEXT_STYLE": "Стиль текста (классика)",
"FREQUENCY_VERY_LOW": "Очень низкая (10%)",
"FREQUENCY_LOW": "Низкая (25%)",
"FREQUENCY_MEDIUM": "Средняя (50%)",
"FREQUENCY_HIGH": "Высокая (75%)",
"FREQUENCY_MAX": "Максимальная (100%)",
"STYLE_EMOJIS": "Только эмодзи",
"STYLE_KAOMOJI": "Каомодзи (◕‿◕)",
"STYLE_SPARKLES": "Звездочки ✨",
"STYLE_FULL_CLASSIC": "Все классические эффекты",
"ENABLE_LOWERCASE_SWITCH": "Преобразовать в строчные буквы",
"ENABLE_UWU_SPEAK_SWITCH": "Включить UwU-стиль (р/л → в/w)",
"ENABLE_UWU_SUFFIXES_SWITCH": "Добавлять UwU-суффиксы (nya, owo)",
"UWU_SUFFIXES_FREQUENCY": "Частота UwU-суффиксов",
"ENABLE_STUTTERING_SWITCH": "Включить заикание (п-привет)",
"STUTTERING_FREQUENCY": "Частота заикания",
"ENABLE_VOWEL_STRETCHING_SWITCH": "Растягивать гласные (милооо)",
"VOWEL_STRETCHING_FREQUENCY": "Частота растягивания гласных",
"VOWEL_STRETCHING_MAX_LENGTH": "Макс. длина растянутой гласной",
"MAX_LENGTH_2X": "Двойная (x2)",
"MAX_LENGTH_3X": "Тройная (x3)",
"ENABLE_CUTE_ACTIONS_SWITCH": "Добавлять милые действия (*обнимает*)",
"CUTE_ACTIONS_FREQUENCY": "Частота милых действий",
"ACTIONS_ON_NEW_LINE": "Действия на новой строке",
"ENABLE_CUTE_PUNCTUATION_SWITCH": "Милая пунктуация (. → .~, ? → ?✨)",
"CUTE_PUNCTUATION_FREQUENCY": "Частота милой пунктуации",
"ENABLE_SOFT_SIGN_SWITCH": "Добавлять 'ь' в конце слов (котикь)",
"SOFT_SIGN_FREQUENCY": "Частота добавления 'ь'",
"ENABLE_TEXT_BORDERS": "Включить рамки текста",
"TEXT_BORDERS_FREQUENCY": "Частота рамок текста",
"THEME_SELECTOR": "Выбор темы",
"THEME_RANDOM": "Случайная",
"THEME_PASTEL": "Пастельная",
"THEME_MAGICAL": "Волшебная",
"THEME_NATURE": "Природная",
"ERROR_MESSAGE_CUTE": "Ой-ой! 🥺 Что-то пошло не так, когда я пытался сделать сообщение милым... Вот оригинал: {original}",
}
def __init__(self):
self.emojis = ["🥰", "😊", "💕", "💖", "💗", "🌸", "✨", "🦄", "🌈", "🍭", "🧸", "🌟", "💫", "🌻", "🍬", "🎀", "💝", "💓", "🍨", "🌷", "🦋", "🐇", "🐱", "🐶", "🦊", "🥺", "👉👈", "🍡", "🧁", "🍰", "🌺", "🌹", "💮", "🧚♀️", "💘", "💞", "🩷", "🩵", "🌞", "🫧", "🫶", "🦢", "🐹", "🐰", "🌼", "🧿"]
self.kaomojis = ["(◕‿◕)", "♡(˘▽˘)♡", "(つ≧▽≦)つ", "(≧◡≦)", "(*^ω^*)", "(っ˘ω˘ς)", "(´。• ω •。`)", "ʕ•ᴥ•ʔ", "(づ。◕‿‿◕。)づ", "ฅ^•ﻌ•^ฅ", "(*˘︶˘*)", "(*¯︶¯*)", "( ˘ ³˘)♥", "(っ•ᴗ•)っ", "ლ(╹◡╹ლ)", "(๑˃ᴗ˂)ﻭ", "(灬ºωº灬)♡", "૮₍˶ᵔ ᵕ ᵔ˶₎ა", "ฅ^•ﻌ•^ฅ", "(*ฅ́˘ฅ̀*)", "(●'◡'●)", "ฅ(^◕ᴥ◕^)ฅ", "(=^・ω・^=)", "ʕっ•ᴥ•ʔっ", "ʕ ꈍᴥꈍʔ", "ʕ´•ᴥ•`ʔ", "(◡ ω ◡)", "(◕ᴗ◕✿)", "꒰⑅ᵕ༚ᵕ꒱˖♡", "ପ(๑•ᴗ•๑)ଓ ♡", "(⁄ ⁄•⁄ω⁄•⁄ ⁄)"]
self.sparkles = ["✨", "⭐", "★", "☆", "₊˚⊹", "˚₊· ͟͟͞͞➳❥", "⋆。°✩", "☆彡", "⊰", "⊱", "✧・゚", "♡", "❀", "❁", "❃", "❋", "✿", "♫", "♪", "✧˖°", "⋆。˚", "⋆⭒˚。⋆", "✧*。", "⁺˚*•̩̩͙✩•̩̩͙*˚⁺", "‧₊˚✧", "ପ♡ଓ", "✩°。⋆⸜", "✮", "✩₊˚.⋆", "☽˚。⋆", "❥", "༘⋆", "⋆⭒˚。⋆", "✮.°:⋆ₓₒ", "✧・゚:✧・゚", "*ੈ✩‧₊˚", "┊͙ ˘͈ᵕ˘͈", "ೃ࿔₊", "˗ˏˋ ★ ˎˊ˗"]
self.uwu_suffixes = ["~", " nya~", " uwu", " owo", " >w<", " :3", " nyaaa", "σωσ", "◡ ω ◡", " OwO", " UwU~", " hehe~", " rawr~", " mew", " purr~", " ehehe", " uwu~", " (⁄ ⁄>⁄ω⁄<⁄ ⁄)", " kyaa~", " nyaa", " nyuu~", " mya~", " (◕ᴗ◕✿)", " teehee", " hehehe", " awoo~", " *blushes*", " purrr", " pwease", " nya?"]
self.extended_exclamations = ["~!", "!!", "!!!", "!~", "!❤", "!✨", "!💖", "!⭐", "!!!1!", "! nya~", "!?!?", "!!!💕", "~!!~", "! ꒰◍ᐡᐤᐡ◍꒱", "! ❁◕ ‿ ◕❁", "!!♡", "! (*ฅ́˘ฅ̀*)", "~✿!", "! ♡₊˚", "!⋆₊", "! 🎀", "! 🌸", "!🌟", "!☆"]
self.vowels_map = {
'ru': "аеёиоуыэюяАЕЁИОУЫЭЮЯ",
'en': "aeiouyAEIOUY"
}
self.letter_pattern = re.compile(r'^\w', re.UNICODE)
self.cute_actions_map = {
"ru": ["*обнимает*", "*нежно обнимает*", "*гладит по голове*", "*хихикает*", "*мурлычет*", "*улыбается*", "*подмигивает*", "*машет лапкой*", "*краснеет*", "*прыгает от радости*", "*делает большие глаза*", "*играет с волосами*", "*качает хвостиком*", "*делает милое личико*", "*танцует от счастья*", "*прячется за лапками*", "*радостно вздыхает*"],
"en": ["*hugs*", "*gentle hug*", "*pats head*", "*giggles*", "*purrs*", "*smiles*", "*winks*", "*waves paw*", "*blushes*", "*jumps with joy*", "*makes big eyes*", "*plays with hair*", "*wags tail*", "*makes cute face*", "*happy dance*", "*hides behind paws*", "*happy sigh*"]
}
self.cute_period_replacements = [".~", ".!", ".✨", ".🌸", ".💖", "~~", " ^^", "₊˚ʚ ᗢ₊˚✧", "✿", ".♡", ".˚ʚ♡ɞ˚", ".ᐟ", ".⋆", ".♬"]
self.cute_question_mark_replacements = ["?!!", "???", "❓💖", "?~", "❓✨", " uwu?", "?✧", "?🥺", "??♡", "??🌸", "?☆"]
self.consonants_ru = "бвгджзйклмнпрстфхцчшщ"
self.text_borders = [
["🌸 ", " 🌸"],
["✧・゚: ", " :・゚✧"],
["— ♡ ", " ♡ —"],
["꒩ ", " ꒪"],
["1", " 2"],
["⋆⠀", " ✩"]
]
self.themes = {
"pastel": {
"emojis": ["🌸", "🎀", "💖", "🧸"],
"words": ["cute", "sweet"],
"prefix": ["✿"],
"suffix": ["✧"]
},
"magical": {
"emojis": ["✨", "⭐", "🦄"],
"words": ["magic"],
"prefix": ["✧"],
"suffix": ["☆"]
},
"nature": {
"emojis": ["🌷", "🌱", "🦋"],
"words": ["flower", "bloom"],
"prefix": ["❀"],
"suffix": ["🌿"]
}
}
self.config = loader.ModuleConfig(
loader.ConfigValue(
"enabled",
False,
"Enable or disable cute message effects",
validator=loader.validators.Boolean(),
),
loader.ConfigValue(
"ignore_dot_commands",
True,
"Ignore messages starting with a dot (e.g., .command)",
validator=loader.validators.Boolean(),
),
loader.ConfigValue(
"emoji_frequency",
1,
"Frequency of classic effects (0: 10%, 1: 25%, 2: 50%, 3: 75%, 4: 100%)",
validator=loader.validators.Integer(minimum=0, maximum=4),
),
loader.ConfigValue(
"text_style",
0,
"Style of classic effects (0: emojis, 1: kaomoji, 2: sparkles, 3: all)",
validator=loader.validators.Choice([0, 1, 2, 3]),
),
loader.ConfigValue(
"enable_text_borders",
False,
"Enable text borders around messages",
validator=loader.validators.Boolean(),
),
loader.ConfigValue(
"text_borders_frequency",
2,
"Frequency of text borders (0: 10%, 1: 25%, 2: 50%, 3: 75%, 4: 100%)",
validator=loader.validators.Integer(minimum=0, maximum=4),
),
loader.ConfigValue(
"theme_selector",
0,
"Theme for messages (0: random, 1: pastel, 2: magical, 3: nature)",
validator=loader.validators.Choice([0, 1, 2, 3]),
),
loader.ConfigValue(
"enable_lowercase",
False,
"Convert messages to lowercase",
validator=loader.validators.Boolean(),
),
loader.ConfigValue(
"enable_uwu_speak",
False,
"Enable UwU-speak (r/l → w in English, р/л → в in Russian)",
validator=loader.validators.Boolean(),
),
loader.ConfigValue(
"enable_uwu_suffixes",
False,
"Add UwU suffixes (e.g., nya, owo)",
validator=loader.validators.Boolean(),
),
loader.ConfigValue(
"uwu_suffixes_frequency",
2,
"Frequency of UwU suffixes (0: 10%, 1: 25%, 2: 50%, 3: 75%, 4: 100%)",
validator=loader.validators.Integer(minimum=0, maximum=4),
),
loader.ConfigValue(
"enable_stuttering",
False,
"Enable stuttering effect (e.g., h-hello)",
validator=loader.validators.Boolean(),
),
loader.ConfigValue(
"stuttering_frequency",
1,
"Frequency of stuttering (0: 10%, 1: 25%, 2: 50%, 3: 75%, 4: 100%)",
validator=loader.validators.Integer(minimum=0, maximum=4),
),
loader.ConfigValue(
"enable_vowel_stretching",
False,
"Enable vowel stretching (e.g., cuuute)",
validator=loader.validators.Boolean(),
),
loader.ConfigValue(
"vowel_stretching_frequency",
2,
"Frequency of vowel stretching (0: 10%, 1: 25%, 2: 50%, 3: 75%, 4: 100%)",
validator=loader.validators.Integer(minimum=0, maximum=4),
),
loader.ConfigValue(
"vowel_stretching_max_length",
0,
"Max vowel stretch length (0: double, 1: triple)",
validator=loader.validators.Choice([0, 1]),
),
loader.ConfigValue(
"enable_cute_actions",
False,
"Add cute actions (e.g., *hugs*)",
validator=loader.validators.Boolean(),
),
loader.ConfigValue(
"cute_actions_frequency",
2,
"Frequency of cute actions (0: 10%, 1: 25%, 2: 50%, 3: 75%, 4: 100%)",
validator=loader.validators.Integer(minimum=0, maximum=4),
),
loader.ConfigValue(
"actions_on_new_line",
False,
"Place cute actions on a new line",
validator=loader.validators.Boolean(),
),
loader.ConfigValue(
"enable_cute_punctuation",
False,
"Use cute punctuation (e.g., . → .~, ? → ?✨)",
validator=loader.validators.Boolean(),
),
loader.ConfigValue(
"cute_punctuation_frequency",
1,
"Frequency of cute punctuation (0: 10%, 1: 25%, 2: 50%, 3: 75%, 4: 100%)",
validator=loader.validators.Integer(minimum=0, maximum=4),
),
loader.ConfigValue(
"enable_soft_sign",
False,
"Add soft sign ('ь') to Russian word endings (e.g., kotikь)",
validator=loader.validators.Boolean(),
),
loader.ConfigValue(
"soft_sign_frequency",
2,
"Frequency of soft sign (0: 10%, 1: 25%, 2: 50%, 3: 75%, 4: 100%)",
validator=loader.validators.Integer(minimum=0, maximum=4),
),
)
def _get_frequency_prob(self, key):
frequency_idx = self.config[key]
return {0: 0.10, 1: 0.25, 3: 0.75, 4: 1.00}.get(frequency_idx, 0.50)
def _is_russian(self, text):
return bool(re.search(r'[а-яА-Я]', text))
def _apply_lowercase(self, text):
if self.config["enable_lowercase"]:
return text.lower()
return text
def _apply_uwu_speak(self, text):
if not self.config["enable_uwu_speak"]:
return text
lang = 'ru' if self._is_russian(text) else 'en'
if lang == 'ru':
text = text.replace('р', 'в').replace('Р', 'В').replace('л', 'в').replace('Л', 'В')
else:
text = text.replace('r', 'w').replace('R', 'W').replace('l', 'w').replace('L', 'W')
return text
def _apply_uwu_suffixes(self, text):
if not self.config["enable_uwu_suffixes"]:
return text
prob = self._get_frequency_prob("uwu_suffixes_frequency")
if random.random() < prob:
return text + " " + random.choice(self.uwu_suffixes)
return text
def _apply_stuttering(self, text):
if not self.config["enable_stuttering"]:
return text
prob = self._get_frequency_prob("stuttering_frequency")
words = text.split()
new_words = []
for word in words:
if random.random() < prob and self.letter_pattern.match(word):
new_words.append(word[0] + '-' + word)
else:
new_words.append(word)
return ' '.join(new_words)
def _apply_vowel_stretching(self, text):
if not self.config["enable_vowel_stretching"]:
return text
prob = self._get_frequency_prob("vowel_stretching_frequency")
max_length = 3 if self.config["vowel_stretching_max_length"] else 2
lang = 'ru' if self._is_russian(text) else 'en'
vowels = self.vowels_map[lang]
words = text.split()
new_words = []
for word in words:
new_word = word
for vowel in vowels:
if random.random() < prob and vowel in new_word:
count = random.randint(1, max_length)
new_word = new_word.replace(vowel, vowel * (count + 1))
new_words.append(new_word)
return ' '.join(new_words)
def _apply_cute_actions(self, text):
if not self.config["enable_cute_actions"]:
return text
prob = self._get_frequency_prob("cute_actions_frequency")
lang = 'ru' if self._is_russian(text) else 'en'
if random.random() < prob:
action = random.choice(self.cute_actions_map[lang])
if self.config["actions_on_new_line"]:
return text + "\n" + action
else:
return text + " " + action
return text
def _apply_cute_punctuation(self, text):
if not self.config["enable_cute_punctuation"]:
return text
prob = self._get_frequency_prob("cute_punctuation_frequency")
if random.random() < prob:
text = text.replace('.', random.choice(self.cute_period_replacements))
text = text.replace('?', random.choice(self.cute_question_mark_replacements))
return text
def _apply_soft_sign(self, text):
if not self.config["enable_soft_sign"]:
return text
prob = self._get_frequency_prob("soft_sign_frequency")
if not self._is_russian(text):
return text
words = text.split()
new_words = []
for word in words:
if random.random() < prob and word and word[-1] not in self.consonants_ru:
new_words.append(word + 'ь')
else:
new_words.append(word)
return ' '.join(new_words)
def _apply_classic_effects(self, text):
if not self.config["enabled"]:
return text
style = self.config["text_style"]
prob = self._get_frequency_prob("emoji_frequency")
if style == 0 and random.random() < prob:
return text + " " + random.choice(self.emojis)
elif style == 1 and random.random() < prob:
return text + " " + random.choice(self.kaomojis)
elif style == 2 and random.random() < prob:
return text + " " + random.choice(self.sparkles)
elif style == 3 and random.random() < prob:
effect = random.choice(self.emojis + self.kaomojis + self.sparkles)
return text + " " + effect
return text
def _apply_text_borders(self, text):
if not self.config["enable_text_borders"]:
return text
prob = self._get_frequency_prob("text_borders_frequency")
if random.random() < prob:
border = random.choice(self.text_borders)
return border[0] + text + border[1]
return text
def _apply_theme(self, text):
theme_idx = self.config["theme_selector"]
if theme_idx == 0: # Random
theme_key = random.choice(["pastel", "magical", "nature"])
else:
theme_key = ["pastel", "magical", "nature"][theme_idx - 1]
theme = self.themes[theme_key]
if random.random() < 0.1:
return random.choice(theme["prefix"]) + " " + text + " " + random.choice(theme["suffix"])
return text
def make_cute(self, text):
try:
original = text
text = self._apply_lowercase(text)
text = self._apply_uwu_speak(text)
text = self._apply_uwu_suffixes(text)
text = self._apply_stuttering(text)
text = self._apply_vowel_stretching(text)
text = self._apply_cute_actions(text)
text = self._apply_cute_punctuation(text)
text = self._apply_soft_sign(text)
text = self._apply_classic_effects(text)
text = self._apply_text_borders(text)
text = self._apply_theme(text)
return text
except Exception as e:
logging.error(f"CuteMessages error: {str(e)}")
return self.strings.get("ERROR_MESSAGE_CUTE", "Oopsie! 🥺 Something went wrong... Here's the original: {original}").format(original=original)
@loader.watcher(out=True)
async def watcher(self, message: Message):
if not self.config["enabled"]:
return
if self.config["ignore_dot_commands"] and message.text.startswith(self.get_prefix()):
return
if not message.text:
return
try:
cute_text = self.make_cute(message.text)
await message.edit(cute_text)
except Exception as e:
logging.warning(f"Failed to edit message: {e}")
@loader.command(
doc="Toggle CuteMessages on or off.",
ru_doc="Включение или выключение CuteMessages.",
)
@loader.command()
async def cutemessages(self, message: Message):
"""Toggle CuteMessages on or off."""
self.config["enabled"] = not self.config["enabled"]
await message.edit(self.strings["ENABLED" if self.config["enabled"] else "DISABLED"])
@loader.command(
doc="View and modify settings for CuteMessages.",
ru_doc="Просмотр и изменение настроек CuteMessages.",
)
async def cutemessages_settings(self, message: Message):
await self.invoke("config", "CuteMessages", peer=message.peer_id)