randydev commited on
Commit
5d15d18
·
verified ·
1 Parent(s): 2599960

Create prefixes.py

Browse files
Files changed (1) hide show
  1. akn/Akeno/prefixes.py +63 -0
akn/Akeno/prefixes.py ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import re
2
+ from config import *
3
+ from Akeno.utils.handler import *
4
+ from Akeno.utils.base_sqlite import *
5
+ from pyrogram.enums import MessageEntityType
6
+ from pyrogram import Client, filters
7
+ from akn.utils.prefixprem import command
8
+ from akn.utils.handler import *
9
+ from pyrogram.types import *
10
+
11
+ def add_space_between_emojies(text):
12
+ EMOJI_PATTERN = re.compile(
13
+ "(["
14
+ "\U0001F1E0-\U0001F1FF" # flags (iOS)
15
+ "\U0001F300-\U0001F5FF" # symbols & pictographs
16
+ "\U0001F600-\U0001F64F" # emoticons
17
+ "\U0001F680-\U0001F6FF" # transport & map symbols
18
+ "\U0001F700-\U0001F77F" # alchemical symbols
19
+ "\U0001F780-\U0001F7FF" # Geometric Shapes Extended
20
+ "\U0001F800-\U0001F8FF" # Supplemental Arrows-C
21
+ "\U0001F900-\U0001F9FF" # Supplemental Symbols and Pictographs
22
+ "\U0001FA00-\U0001FA6F" # Chess Symbols
23
+ "\U0001FA70-\U0001FAFF" # Symbols and Pictographs Extended-A
24
+ "\U00002702-\U000027B0" # Dingbats
25
+ "])"
26
+ )
27
+ return re.sub(EMOJI_PATTERN, r' \1 ', text)
28
+
29
+ def convert_u_plus_notation(text):
30
+ return re.sub(r'\\U\+([A-Fa-f0-9]{4,6})', lambda x: chr(int(x.group(1), 16)), text)
31
+
32
+ @Akeno(
33
+ ~filters.scheduled
34
+ & command(["setprefix"])
35
+ & filters.me
36
+ & ~filters.forwarded
37
+ )
38
+ async def set_prefix(client: Client, message: Message):
39
+ user_id = message.from_user.id
40
+ if not message.text or len(message.text.split()) < 2:
41
+ await message.reply_text("Usage: ?setprefix emoji or None")
42
+ return
43
+ new_prefix_text = message.text.split(maxsplit=1)[1]
44
+ if new_prefix_text in add_space_between_emojies(new_prefix_text):
45
+ return await message.reply_text("Not allowed emoji normal only emoji premium support!")
46
+
47
+ if message.entities:
48
+ for entity in message.entities:
49
+ if entity.type == MessageEntityType.CUSTOM_EMOJI and entity.offset >= len(message.text.split()[0]) + 1:
50
+ custom_emoji_id = entity.custom_emoji_id
51
+ set_prefix_in_db(user_id, custom_emoji_id)
52
+ await message.reply_text(f"Custom emoji prefix set to: <emoji id={custom_emoji_id}>🗿</emoji>")
53
+ return
54
+
55
+ if new_prefix_text.lower() == "none":
56
+ set_prefix_in_db(user_id, "None")
57
+ await message.reply_text("Prefix removed.")
58
+ else:
59
+ set_prefix_in_db(user_id, new_prefix_text)
60
+ await message.reply_text(f"Prefix set to: {new_prefix_text}")
61
+
62
+ module = modules_help.add_module("prefixes", __file__)
63
+ module.add_command("setprefix", "Emoji or None.")