dshellInterpreter 0.2.18.0__py3-none-any.whl → 0.2.18.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of dshellInterpreter might be problematic. Click here for more details.

@@ -14,12 +14,12 @@ __all__ = [
14
14
  'dshell_delete_message',
15
15
  'dshell_purge_message',
16
16
  'dshell_edit_message',
17
- 'dshell_get_hystory_messages',
18
- 'dshell_research_regex_in_content',
17
+ 'dshell_get_history_messages',
19
18
  'dshell_add_reactions',
20
19
  'dshell_remove_reactions',
21
20
  'dshell_clear_message_reactions',
22
- 'dshell_clear_one_reactions'
21
+ 'dshell_clear_one_reactions',
22
+ 'dshell_get_content_message'
23
23
  ]
24
24
 
25
25
 
@@ -167,7 +167,7 @@ async def dshell_edit_message(ctx: Message, message, new_content=None, embeds=No
167
167
  return edit_message.id
168
168
 
169
169
 
170
- async def dshell_get_hystory_messages(ctx: Message, channel=None, limit=None) -> "ListNode":
170
+ async def dshell_get_history_messages(ctx: Message, channel=None, limit=None) -> "ListNode":
171
171
  """
172
172
  Searches for messages matching a regex in a channel
173
173
  """
@@ -184,7 +184,7 @@ async def dshell_get_hystory_messages(ctx: Message, channel=None, limit=None) ->
184
184
 
185
185
  messages = ListNode([])
186
186
  async for message in search_channel.history(limit=limit):
187
- messages.add(message)
187
+ messages.add(message.id)
188
188
 
189
189
  if not messages:
190
190
  raise commands.CommandError(f"No messages in {search_channel.mention}.")
@@ -192,19 +192,6 @@ async def dshell_get_hystory_messages(ctx: Message, channel=None, limit=None) ->
192
192
  return messages
193
193
 
194
194
 
195
- async def dshell_research_regex_in_content(ctx: Message, regex, content=None):
196
- """
197
- Searches for a regex in a specific message content
198
- """
199
-
200
- if not isinstance(regex, str):
201
- raise Exception(f"Regex must be a string, not {type(regex)}!")
202
-
203
- if not search(regex, str(content) if content is not None else ctx.content):
204
- return False
205
-
206
- return True
207
-
208
195
 
209
196
  async def dshell_add_reactions(ctx: Message, reactions, message=None):
210
197
  """
@@ -257,3 +244,14 @@ async def dshell_clear_one_reactions(ctx: Message, message, emoji):
257
244
  target_message = ctx if message is None else utils_get_message(ctx, message)
258
245
 
259
246
  await target_message.clear_reaction(emoji)
247
+
248
+ async def dshell_get_content_message(ctx: Message, message=None):
249
+ """
250
+ Get the content of a message
251
+ """
252
+
253
+ target_message = ctx if message is None else utils_get_message(ctx, message)
254
+
255
+ return target_message.content
256
+
257
+
@@ -4,10 +4,14 @@ __all__ = [
4
4
  "utils_lower_string",
5
5
  "utils_title_string",
6
6
  "utils_strip_string",
7
- "utils_replace_string"
7
+ "utils_replace_string",
8
+ "utils_regex_findall",
9
+ "utils_regex_sub",
10
+ "utils_regex_search"
8
11
  ]
9
12
 
10
13
  from discord import Message
14
+ from re import search, findall, sub
11
15
 
12
16
  async def utils_split_string(ctx: Message, value: str, separator: str = ' ') -> "ListNode":
13
17
  """
@@ -93,4 +97,59 @@ async def utils_replace_string(ctx: Message, value: str, old: str, new: str) ->
93
97
  if not isinstance(new, str):
94
98
  raise TypeError(f"new must be a str in replace command, not {type(new)}")
95
99
 
96
- return value.replace(old, new)
100
+ return value.replace(old, new)
101
+
102
+ async def utils_regex_findall(ctx: Message, regex: str, content: str = None) -> "ListNode":
103
+ """
104
+ Find all occurrences of a regex in a string.
105
+ :param regex:
106
+ :param content:
107
+ :return:
108
+ """
109
+
110
+ if not isinstance(regex, str):
111
+ raise Exception(f"Regex must be a string, not {type(regex)}!")
112
+
113
+ if content is not None and not isinstance(content, str):
114
+ raise Exception(f"Content must be a string, not {type(content)}!")
115
+
116
+ from ..._DshellParser.ast_nodes import ListNode
117
+
118
+ return ListNode(findall(regex, content if content is not None else ctx.content))
119
+
120
+
121
+ async def utils_regex_sub(ctx: Message, regex: str, replace: str, content: str = None) -> str:
122
+ """
123
+ Replace all occurrences of a regex in a string with a replacement string.
124
+ :param regex:
125
+ :param replace:
126
+ :param content:
127
+ :return:
128
+ """
129
+
130
+ if not isinstance(regex, str):
131
+ raise Exception(f"Regex must be a string, not {type(regex)}!")
132
+
133
+ if not isinstance(replace, str):
134
+ raise Exception(f"Replacement must be a string, not {type(replace)}!")
135
+
136
+ if content is not None and not isinstance(content, str):
137
+ raise Exception(f"Content must be a string, not {type(content)}!")
138
+
139
+ return sub(regex, replace, content if content is not None else ctx.content)
140
+
141
+ async def utils_regex_search(ctx: Message, regex: str, content: str = None) -> bool:
142
+ """
143
+ Search for a regex in a string.
144
+ :param regex:
145
+ :param content:
146
+ :return:
147
+ """
148
+
149
+ if not isinstance(regex, str):
150
+ raise Exception(f"Regex must be a string, not {type(regex)}!")
151
+
152
+ if content is not None and not isinstance(content, str):
153
+ raise Exception(f"Content must be a string, not {type(content)}!")
154
+
155
+ return bool(search(regex, content if content is not None else ctx.content))
@@ -62,6 +62,7 @@ class DshellInterpreteur:
62
62
  '__message_content__': message.content,
63
63
  '__message_id__': message.id,
64
64
  '__message_url__': message.jump_url if hasattr(message, 'jump_url') else None,
65
+ '__last_message__': message.channel.last_message_id,
65
66
 
66
67
  '__channel__': message.channel.id,
67
68
  '__channel_name__': message.channel.name,
@@ -51,6 +51,9 @@ dshell_commands: dict[str, Callable] = {
51
51
  'title': utils_title_string,
52
52
  'strip': utils_strip_string,
53
53
  'replace': utils_replace_string,
54
+ 'regex_findall': utils_regex_findall,
55
+ 'regex_sub': utils_regex_sub,
56
+ 'regex': utils_regex_search,
54
57
 
55
58
  ## Discord utils
56
59
  'name': utils_get_name, # get the name from id (channel, role, member)
@@ -70,6 +73,8 @@ dshell_commands: dict[str, Callable] = {
70
73
  "dm": dshell_delete_message,
71
74
  "pm": dshell_purge_message,
72
75
  "em": dshell_edit_message, # edit message
76
+ "mh": dshell_get_history_messages, # get message history
77
+ "gcm": dshell_get_content_message, # get content of a message
73
78
 
74
79
  "sri": dshell_respond_interaction, # respond to an interaction
75
80
  "sdi": dshell_defer_interaction, # defer an interaction
@@ -99,9 +104,6 @@ dshell_commands: dict[str, Callable] = {
99
104
  "gmr": dshell_give_member_roles, # give roles
100
105
  "rmr": dshell_remove_member_roles, # remove roles
101
106
 
102
- "ghm": dshell_get_hystory_messages, # research regex in message
103
- "src": dshell_research_regex_in_content, # research regex in content
104
-
105
107
  "ec": dshell_edit_text_channel, # edit text channel
106
108
  "evc": dshell_edit_voice_channel, # edit voice channel
107
109
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dshellInterpreter
3
- Version: 0.2.18.0
3
+ Version: 0.2.18.1
4
4
  Summary: A Discord bot interpreter for creating custom commands and automations.
5
5
  Home-page: https://github.com/BOXERRMD/Dshell_Interpreter
6
6
  Author: Chronos
@@ -4,7 +4,7 @@ Dshell/DISCORD_COMMANDS/__init__.py,sha256=87-YpGU74m-m7AqUQni7PGbw73JRlioQkywW_
4
4
  Dshell/DISCORD_COMMANDS/dshell_channel.py,sha256=PDXpxrRRWPSucdp_3ITJk0Ur3coneRJKWEl2i7GZ2EM,15696
5
5
  Dshell/DISCORD_COMMANDS/dshell_interaction.py,sha256=5FA8JZ2_v98ZzOZl6EKyjo_fUQC7FuK6C6hij6ZSP30,3495
6
6
  Dshell/DISCORD_COMMANDS/dshell_member.py,sha256=5Iw-2dydhYMZOw2nx0svZP9JpZWHOXC0qkL9tClJHtw,8840
7
- Dshell/DISCORD_COMMANDS/dshell_message.py,sha256=zcWl6Y1W31h9MTHS-j9tLDwcrRiE_wGOu78zu2k0y9I,9101
7
+ Dshell/DISCORD_COMMANDS/dshell_message.py,sha256=Vzk4EsAvXNaPGTtS8t-Zvr_IwUONlafzN2EfMO6FS_0,8954
8
8
  Dshell/DISCORD_COMMANDS/dshell_pastbin.py,sha256=H0tUJOwdzYBXvxqipK3mzoNZUKrSLcVm4EZlWbBRScs,796
9
9
  Dshell/DISCORD_COMMANDS/dshell_role.py,sha256=t_yRZRD0FKE2gT4dIDIsHz2PSZZztDVEkkqkG_OkNh4,5002
10
10
  Dshell/DISCORD_COMMANDS/utils/__init__.py,sha256=-amNcYysjgx3YDpDSnbQmJhnm3lbJere9K9aDH-YnJg,115
@@ -13,20 +13,20 @@ Dshell/DISCORD_COMMANDS/utils/utils_list.py,sha256=zqImMWvD-1UnbPP1TZewnvZpq7qs1
13
13
  Dshell/DISCORD_COMMANDS/utils/utils_member.py,sha256=1EoHooxwijc7AFJGnuae3ccjQk0x69MELtZ5ES5abLY,1165
14
14
  Dshell/DISCORD_COMMANDS/utils/utils_message.py,sha256=cQvJ15f49ddOjybARwkJKNFe3ITYQciF-pZHERFPkr0,2964
15
15
  Dshell/DISCORD_COMMANDS/utils/utils_permissions.py,sha256=Gi6vpCA2yXUZ20OCay5dkX6HeN4LglVROwcvTWVCsKg,3600
16
- Dshell/DISCORD_COMMANDS/utils/utils_string.py,sha256=wElUdUn3nEeR_ZiJZZDonlCFukBrar8Bxy9-bVlZAvE,2686
16
+ Dshell/DISCORD_COMMANDS/utils/utils_string.py,sha256=WyTJJXjHwxs_76PKclRErjK8b6CFYpZhbZbAlr259HA,4667
17
17
  Dshell/DISCORD_COMMANDS/utils/utils_thread.py,sha256=tVl4msEwrWHY-0AytI6eY3JSs-eIFUigDSJfK9mT1ww,1457
18
18
  Dshell/_DshellInterpreteur/__init__.py,sha256=jl_gH8MoqerW--I-IHXwUZTo80JOtfr7AOA57xVgeGQ,58
19
- Dshell/_DshellInterpreteur/dshell_interpreter.py,sha256=PcwfNPz44v6gsl-xNcvNwV5lcLhpJ6yDdjwHHnE6OUE,29493
19
+ Dshell/_DshellInterpreteur/dshell_interpreter.py,sha256=wX7P7MwJ0O6I5mZ5FJG7qoH8qfObGuxPUVjerhRPYtM,29559
20
20
  Dshell/_DshellInterpreteur/errors.py,sha256=0PJz_VYZfNZeKR_PEHxw3tRkgKNNUerV0wwrq2r1luA,250
21
21
  Dshell/_DshellParser/__init__.py,sha256=ONDfhZMvClqP_6tE8SLjp-cf3pXL-auQYnfYRrHZxC4,56
22
22
  Dshell/_DshellParser/ast_nodes.py,sha256=RLlylX9bvbJEG3BDMGS4mnMxU8ufnZYIF59NVf_pW7A,18883
23
23
  Dshell/_DshellParser/dshell_parser.py,sha256=cpukpWFJlioP1pIZZMGg24GrXfnnz1nuPCIKRNsxAcE,18949
24
24
  Dshell/_DshellTokenizer/__init__.py,sha256=LIQSRhDx2B9pmPx5ADMwwD0Xr9ybneVLhHH8qrJWw_s,172
25
- Dshell/_DshellTokenizer/dshell_keywords.py,sha256=hW9ajfKMXN2XNwOnibW5Vn2XhgMfu1hUqUy1WdDQSTs,7123
25
+ Dshell/_DshellTokenizer/dshell_keywords.py,sha256=TI5O6y6gAXpM_dKxCW9Fk0H8VR-gmyxxKKOURgcHsCg,7219
26
26
  Dshell/_DshellTokenizer/dshell_token_type.py,sha256=gYIb2XN2YcgeRgmar_rBDS5CGmwfmxihu8mOW_d6lbE,1533
27
27
  Dshell/_DshellTokenizer/dshell_tokenizer.py,sha256=AJnUocD6hbU6wvjRAN5uDha5QQieTwXlHzZVtgRGaZQ,7307
28
- dshellinterpreter-0.2.18.0.dist-info/licenses/LICENSE,sha256=lNgcw1_xb7QENAQi3uHGymaFtbs0RV-ihiCd7AoLQjA,1082
29
- dshellinterpreter-0.2.18.0.dist-info/METADATA,sha256=e4rNTDr91A1ug4oFQk1Shx4Y15MOC9buN5qzbVPL0Bw,1151
30
- dshellinterpreter-0.2.18.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
31
- dshellinterpreter-0.2.18.0.dist-info/top_level.txt,sha256=B4CMhtmchGwPQJLuqUy0GhRG-0cUGxKL4GqEbCiB_vE,7
32
- dshellinterpreter-0.2.18.0.dist-info/RECORD,,
28
+ dshellinterpreter-0.2.18.1.dist-info/licenses/LICENSE,sha256=lNgcw1_xb7QENAQi3uHGymaFtbs0RV-ihiCd7AoLQjA,1082
29
+ dshellinterpreter-0.2.18.1.dist-info/METADATA,sha256=2G017CKReQAhq-2HowFAt1jg9yPxNVWhl5iF-25OCco,1151
30
+ dshellinterpreter-0.2.18.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
31
+ dshellinterpreter-0.2.18.1.dist-info/top_level.txt,sha256=B4CMhtmchGwPQJLuqUy0GhRG-0cUGxKL4GqEbCiB_vE,7
32
+ dshellinterpreter-0.2.18.1.dist-info/RECORD,,