AdvancedTagScript 3.2.4__py3-none-any.whl → 3.2.5__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.
@@ -24,6 +24,7 @@ from .block import (
24
24
  helper_parse_if as helper_parse_if,
25
25
  helper_parse_list_if as helper_parse_list_if,
26
26
  helper_split as helper_split,
27
+ easier_helper_split as easier_helper_split,
27
28
  AllowedMentionsBlock as AllowedMentionsBlock,
28
29
  AllBlock as AllBlock,
29
30
  AnyBlock as AnyBlock,
@@ -55,6 +56,8 @@ from .block import (
55
56
  CountBlock as CountBlock,
56
57
  LengthBlock as LengthBlock,
57
58
  CooldownBlock as CooldownBlock,
59
+ JoinBlock as JoinBlock,
60
+
58
61
  )
59
62
  from .interface import (
60
63
  Adapter as Adapter,
@@ -97,6 +100,8 @@ __all__: Tuple[str, ...] = (
97
100
  "helper_parse_if",
98
101
  "helper_parse_list_if",
99
102
  "helper_split",
103
+ "easier_helper_split",
104
+ "AllowedMentionsBlock",
100
105
  "AllBlock",
101
106
  "AnyBlock",
102
107
  "AssignmentBlock",
@@ -127,6 +132,8 @@ __all__: Tuple[str, ...] = (
127
132
  "LowerBlock",
128
133
  "CountBlock",
129
134
  "LengthBlock",
135
+ "JoinBlock",
136
+
130
137
  "SafeObjectAdapter",
131
138
  "StringAdapter",
132
139
  "IntAdapter",
@@ -170,7 +177,7 @@ __all__: Tuple[str, ...] = (
170
177
  )
171
178
 
172
179
 
173
- __version__: Final[str] = "3.2.4"
180
+ __version__: Final[str] = "3.2.5"
174
181
 
175
182
 
176
183
  class VersionNamedTuple(NamedTuple):
@@ -89,6 +89,9 @@ from .count import (
89
89
  CountBlock as CountBlock,
90
90
  LengthBlock as LengthBlock,
91
91
  )
92
+ from .joinblock import (
93
+ JoinBlock as JoinBlock,
94
+ )
92
95
 
93
96
  __all__: Tuple[str, ...] = (
94
97
  "implicit_bool",
@@ -127,4 +130,5 @@ __all__: Tuple[str, ...] = (
127
130
  "LowerBlock",
128
131
  "CountBlock",
129
132
  "LengthBlock",
133
+ "JoinBlock",
130
134
  )
@@ -12,7 +12,7 @@ __all__: Tuple[str, ...] = ("UpperBlock", "LowerBlock")
12
12
  class UpperBlock(Block):
13
13
  """Converts the given text to uppercase.
14
14
 
15
- **Usage:** ``{upper([text]))}``
15
+ **Usage:** ``{upper([text])}``
16
16
 
17
17
  **Aliases:** ``uppercase, upper``
18
18
 
@@ -22,10 +22,10 @@ class UpperBlock(Block):
22
22
 
23
23
  **Examples:** ::
24
24
 
25
- The text is {lower(ThIs Is A TeXt)}!
25
+ The text is {upper(ThIs Is A TeXt)}!
26
26
  # The text is THIS IS A TEXT!
27
27
 
28
- You have entered {lower({args})}!
28
+ You have entered {upper({args})}!
29
29
  # You have entered HELLO WORLD!
30
30
  """
31
31
 
@@ -11,25 +11,35 @@ __all__: Tuple[str, ...] = ("CountBlock", "LengthBlock")
11
11
 
12
12
  class CountBlock(verb_required_block(True, payload=True)): # type: ignore
13
13
  """
14
- The count block will count how much of text is in message.
15
- This is case sensitive and will include substrings, if you
16
- don't provide a parameter, it will count the spaces in the
17
- message.
14
+ The count block counts occurrences of a substring within a message.
15
+ The search is case sensitive and includes overlapping substrings.
16
+
17
+ A payload (the message to search in) is **required**. Optionally,
18
+ pass the text to search for as a parameter. If no parameter is
19
+ provided, the block counts the number of words in the message
20
+ (spaces + 1).
18
21
 
19
22
  **Usage:** ``{count([text]):<message>}``
20
23
 
21
24
  **Aliases:** ``None``
22
25
 
23
- **Payload:** ``message``
26
+ **Payload:** ``message`` (required)
27
+
28
+ **Parameter:** ``text`` (optional, the substring to count)
24
29
 
25
- **Parameter:** text
30
+ **Examples:** ::
26
31
 
27
- .. tagscript::
28
32
  {count(Tag):TagScriptEngine}
29
33
  # 1
30
34
 
31
- {count(Tag): Tag Script Engine TagScriptEngine}
35
+ {count(Tag):Tag Script Engine TagScriptEngine}
32
36
  # 2
37
+
38
+ {count:hello world}
39
+ # 2 (word count: 1 space + 1)
40
+
41
+ {count(123)}
42
+ # Returns {count(123)} — rejected because no payload was provided
33
43
  """
34
44
 
35
45
  ACCEPTED_NAMES: Tuple[str, ...] = ("count",)
@@ -38,28 +48,28 @@ class CountBlock(verb_required_block(True, payload=True)): # type: ignore
38
48
  if ctx.verb.parameter:
39
49
  payload: str = cast(str, ctx.verb.payload)
40
50
  return str(payload.count(ctx.verb.parameter))
41
- return str(len(cast(str, ctx.verb.payload)) + 1)
51
+ return str(cast(str, ctx.verb.payload).count(" ") + 1)
42
52
 
43
53
 
44
- class LengthBlock(verb_required_block(True, payload=True)): # type: ignore
54
+ class LengthBlock(verb_required_block(True, parameter=True)): # type: ignore
45
55
  """
46
- The length block will check the length of the given String.
47
- If a parameter is passed in, the block will check the length
48
- based on what you passed in, w for word, s for spaces.
49
- If you provide an invalid parameter, the block will return -1.
56
+ The length block returns the character count of the given text.
50
57
 
51
58
  **Usage:** ``{length(<text>)}``
52
59
 
53
60
  **Aliases:** ``len``
54
61
 
55
- **Payload:** None
62
+ **Payload:** ``None``
63
+
64
+ **Parameter:** ``text`` (required)
56
65
 
57
- **Parameter:** ``text``
66
+ **Examples:** ::
58
67
 
59
- .. tagscript::
68
+ {len(TagScriptEngine)}
69
+ # 15
60
70
 
61
- {len("TagScriptEngine")}
62
- 15
71
+ {len(hello world)}
72
+ # 11
63
73
  """
64
74
 
65
75
  ACCEPTED_NAMES: Tuple[str, ...] = ("length", "len")
@@ -0,0 +1,43 @@
1
+ from __future__ import annotations
2
+
3
+ from typing import Optional, Tuple, cast
4
+
5
+ from ..interface import verb_required_block
6
+ from ..interpreter import Context
7
+
8
+
9
+ __all__: Tuple[str, ...] = ("JoinBlock",)
10
+
11
+
12
+ class JoinBlock(verb_required_block(False, payload=True, parameter=True)): # type: ignore
13
+ """
14
+ The join block replaces every space in the payload with the parameter string.
15
+ These blocks only function in Tags.
16
+
17
+ The parameter must be set, even if it is an empty string.
18
+ Cannot use the symbols ``)`` or ``}`` as parameters.
19
+
20
+ **Usage:** ``{join(<string>):<payload>}``
21
+
22
+ **Aliases:** ``None``
23
+
24
+ **Payload:** payload
25
+
26
+ **Parameter:** string (required, can be empty)
27
+
28
+ **Examples:** ::
29
+
30
+ {join(_):hello friends}
31
+ # hello_friends
32
+
33
+ {join():an example sentence}
34
+ # anexamplesentence
35
+
36
+ {join(-):one two three}
37
+ # one-two-three
38
+ """
39
+
40
+ ACCEPTED_NAMES: Tuple[str, ...] = ("join",)
41
+
42
+ def process(self, ctx: Context) -> Optional[str]:
43
+ return cast(str, ctx.verb.payload).replace(" ", cast(str, ctx.verb.parameter))
@@ -53,16 +53,19 @@ class PythonBlock(verb_required_block(True, payload=True, parameter=True)): # t
53
53
 
54
54
  The ``in`` alias checks if the parameter is anywhere in the payload.
55
55
 
56
- ``contain`` strictly checks if the parameter is the payload, split by whitespace.
56
+ The ``contains`` alias strictly checks if the parameter is in the payload, split by whitespace.
57
57
 
58
- ``index`` finds the location of the parameter in the payload, split by whitespace.
59
- If the parameter string is not found in the payload, it returns 1.
58
+ The ``index`` alias finds the location/index of the parameter in the payload, split by whitespace.
59
+ If the parameter string is not found in the payload, it returns -1.
60
60
 
61
- index is used to return the value of the string form the given list of
61
+ .. note::
62
+
63
+ Both ``contains`` and ``index`` perform **exact** matching on whitespace-split words.
64
+ For example, ``food`` will **not** match ``food.`` (with trailing punctuation).
62
65
 
63
66
  **Usage:** ``{in(<string>):<payload>}``
64
67
 
65
- **Aliases:** ``index``, ``contains``
68
+ **Aliases:** ``in``, ``contains``, ``index``
66
69
 
67
70
  **Payload:** payload
68
71
 
@@ -80,12 +83,16 @@ class PythonBlock(verb_required_block(True, payload=True, parameter=True)): # t
80
83
  {contains(mute):How does it feel to be muted?}
81
84
  # false
82
85
  {contains(muted?):How does it feel to be muted?}
83
- # false
86
+ # true
84
87
 
85
88
  {index(food):I love to eat food. everyone does.}
86
- # 4
87
- {index(pie):I love to eat food. everyone does.}
88
- # -1
89
+ # -1 # because of the period. "food" != "food."
90
+ {index(food):I love to eat food everyone does}
91
+ # 4 # because "food" is the 4th word in the payload
92
+ {index(love):I love to eat food}
93
+ # 1 # because "love" is the 2nd word in the payload
94
+ {index(pie):I love to eat food}
95
+ # -1 # because "pie" is not in the payload
89
96
  """
90
97
 
91
98
  def will_accept(self, ctx: Context) -> bool: # type: ignore
@@ -24,7 +24,7 @@ class StopBlock(verb_required_block(True, parameter=True)): # type: ignore
24
24
 
25
25
  **Parameter:** bool
26
26
 
27
- **Example:** ::
27
+ **Examples:** ::
28
28
 
29
29
  {stop({args}==):You must provide arguments for this tag.}
30
30
  # enforces providing arguments for a tag
@@ -16,7 +16,7 @@ class StrfBlock(Block):
16
16
  Two types of timestamps are supported: ISO and epoch.
17
17
  If a timestamp isn't passed, the current UTC time is used.
18
18
 
19
- Invoking this block with `unix` will return the current Unix timestamp.
19
+ Invoking this block with ``unix`` will return the current Unix timestamp.
20
20
 
21
21
  **Usage:** ``{strf([timestamp]):<format>}``
22
22
 
@@ -30,8 +30,8 @@ class URLEncodeBlock(verb_required_block(True, payload=True)): # type: ignore
30
30
 
31
31
  # the following tagscript can be used to search up tag blocks
32
32
  # assume {args} = "command block"
33
- # <https://seina-cogs.readthedocs.io/en/latest/search.html?q={urlencode(+):{args}}&check_keywords=yes&area=default>
34
- # <https://seina-cogs.readthedocs.io/en/latest/search.html?q=command+block&check_keywords=yes&area=default>
33
+ # <https://cool-cogs.readthedocs.io/en/latest/search.html?q={urlencode(+):{args}}&check_keywords=yes&area=default>
34
+ # <https://cool-cogs.readthedocs.io/en/latest/search.html?q=command+block&check_keywords=yes&area=default>
35
35
  """
36
36
 
37
37
  ACCEPTED_NAMES: Tuple[str, ...] = ("urlencode",)
@@ -1,15 +1,14 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: AdvancedTagScript
3
- Version: 3.2.4
3
+ Version: 3.2.5
4
4
  Summary: An easy drop in user-provided Templating system.
5
5
  Home-page: https://github.com/cool-aid-man/TagScriptEngine
6
6
  Author: cool-aid-man, inthedark.org, PhenoM4n4n
7
7
  Author-email: coolaid@duskybot.xyz
8
- License: Creative Commons Attribution 4.0 International License
8
+ License: CC-BY-4.0
9
9
  Keywords: tagscript,string-templating,discord.py
10
10
  Classifier: Development Status :: 5 - Production/Stable
11
11
  Classifier: Intended Audience :: Developers
12
- Classifier: License :: Freely Distributable
13
12
  Classifier: Natural Language :: English
14
13
  Classifier: Operating System :: OS Independent
15
14
  Classifier: Programming Language :: Python :: 3.8
@@ -41,7 +40,7 @@ Dynamic: license-file
41
40
  <img src="https://img.shields.io/pypi/v/AdvancedTagScript" alt="PyPI - Version">
42
41
  </a>
43
42
  <a href="https://advancedtagscript.readthedocs.io/en/latest/?badge=latest">
44
- <img src="https://readthedocs.org/projects/tagscriptengine/badge/?version=latest" alt="Documentation Status" />
43
+ <img src="https://readthedocs.org/projects/AdvancedTagScript/badge/?version=latest" alt="Documentation Status" />
45
44
  </a>
46
45
  <a href="https://pypi.python.org/pypi/AdvancedTagScript/">
47
46
  <img src="https://img.shields.io/pypi/dm/AdvancedTagScript" alt="PyPI - Downloads" />
@@ -1,4 +1,4 @@
1
- TagScriptEngine/__init__.py,sha256=PEJ3kfpYf2UUBeQCP_GNjLWQlSmSHo5kLKPMH_2QYQw,5911
1
+ TagScriptEngine/__init__.py,sha256=X27OiTa2SvbM_SmT0rETVxgXJD_baJ6HLqE6X9AnKeE,6068
2
2
  TagScriptEngine/_warnings.py,sha256=pfMXaEVGpIue0eqgzZ6HkLXEka1UGl61-yuH9uEnVe4,2662
3
3
  TagScriptEngine/exceptions.py,sha256=lhvskKi2AySE5pul_iAA251jdMv-92QkjodR4X-G27Y,2833
4
4
  TagScriptEngine/interpreter.py,sha256=oiyKNXgZCsMmcCTkRnszVIqG_to7PmQKomCn_pX5sb8,16604
@@ -12,37 +12,37 @@ TagScriptEngine/adapter/intadapter.py,sha256=jENx5ah8k0U1PjJccV0NiYFsWFU9ZXTFgz3
12
12
  TagScriptEngine/adapter/objectadapter.py,sha256=7bW-Qd6gujq2ALdK3p0ONoCSPWCTv6srkkDNjzkvDEU,1017
13
13
  TagScriptEngine/adapter/redbotadapters.py,sha256=AFCu4QZGSHAMwyDFHBPT9XS5aaWVzj9Hu-pwI87DXi8,5934
14
14
  TagScriptEngine/adapter/stringadapter.py,sha256=VaJzkm1b8b7w1T90DjR3gOH0DIsZlWtcFe1YG7DOqBQ,1710
15
- TagScriptEngine/block/__init__.py,sha256=pWsnL9GJ69UmZf-VCxwdAb9Kv89KNyVw_fFM7MV0NkM,2994
15
+ TagScriptEngine/block/__init__.py,sha256=JPyfutqST14cpSE8YgeY9PsM9cY2s5CkoNBMf3h5bmE,3070
16
16
  TagScriptEngine/block/allowedmentions.py,sha256=WMGWi1Fe0U_vUBsc4uyiX1XfQjGkhpdlyvq3HhCCLd4,2219
17
17
  TagScriptEngine/block/assign.py,sha256=l3DO41BVoXZbGSHsscSdNiSLddT7ggt1bPQoJdM1Iuo,1202
18
18
  TagScriptEngine/block/breakblock.py,sha256=nt3T7fDhTxH0jpO8lu0_3oC4XwVuKKg9cmkdLsZwzL8,1288
19
- TagScriptEngine/block/case.py,sha256=0DDWG9iN1uI5kE_NaZ2Ewfwg5Ki0nph0jHL2W1YQqdY,1442
19
+ TagScriptEngine/block/case.py,sha256=KAayT5RGLOMV7g6glu9AV9DijErdT-2ph7yIleGLjZw,1441
20
20
  TagScriptEngine/block/command.py,sha256=1ljbZd_Mgg6Woqi6giz26coCRej-jyh4ENY_cdTwjK8,4307
21
- TagScriptEngine/block/comment.py,sha256=wsie7-PTupqDcuHNCflYiVip4sehR7S28GQzuXIJOQo,675
22
21
  TagScriptEngine/block/control.py,sha256=tALrHN0vbEXheMhoQOI_C0X_WjL3c-Qqd2zEd0rAZrE,5699
23
22
  TagScriptEngine/block/cooldown.py,sha256=F4HmFoIlxIhDWw8Z8PFZqP1FoEEBmAW4aipByZKZocY,4022
24
- TagScriptEngine/block/count.py,sha256=J_9t1N7huGktOvJTvs9jxS9z8ayK3BpB35MWbmuba2s,1867
23
+ TagScriptEngine/block/count.py,sha256=URa5xadQ56X7uaBkhMew6KyMdlZDwuj3xKjIH_PK37U,2135
25
24
  TagScriptEngine/block/embedblock.py,sha256=NbudZCln0lEKO8WD5Zmh3W56E5jzmwBMezEaIbGcyqU,11008
26
25
  TagScriptEngine/block/fiftyfifty.py,sha256=QjQP96vpQPRVpuVcF5iI1kTCkM54vUBpKgK2TEZU6vQ,827
27
26
  TagScriptEngine/block/helpers.py,sha256=Zevy0tWzDAUKSD9hc6-nW7WTreRhqENgalfySwqhF7U,4386
27
+ TagScriptEngine/block/joinblock.py,sha256=-TlxO-q8clBZIu0TJg7qT2i2ti6nLAVsev_zz0lGrI4,1096
28
28
  TagScriptEngine/block/loosevariablegetter.py,sha256=ym6u9HTWKN-Cgk6OQH5FVIiGnxsND2g5o4r3kRBGH9M,1231
29
29
  TagScriptEngine/block/mathblock.py,sha256=r69oCNUAjcGNO0QFBG7w9XCv7mvMrq__GoyhR7pW6fA,5802
30
30
  TagScriptEngine/block/randomblock.py,sha256=udC7mCGYrtN_Exg1XZZvqvvi8KkGNnRyTkuh-6rbeSo,1594
31
31
  TagScriptEngine/block/range.py,sha256=3dz6jgTIBloZyXgN7eXGsB7SBjK3Y-OJROmHOeOaJT4,1836
32
32
  TagScriptEngine/block/redirect.py,sha256=BobWl6xKqVV4FZlihmJoLPwI_i0P6Sn6G6fWFf9d8CE,1140
33
- TagScriptEngine/block/replaceblock.py,sha256=JbW-TEIQO4EgeZ3KKPKY2oIKKkVOq-syI4sIzN--OVk,3372
33
+ TagScriptEngine/block/replaceblock.py,sha256=NXx6wdgI4r3MOw-E5oIbtrMEc9BdxpM9RipNRAkVhQU,3821
34
34
  TagScriptEngine/block/require_blacklist.py,sha256=3jFK8Ap_ataHZrqF3MWrmXrBI5CkIXq8G6QMEq0QQXY,2810
35
35
  TagScriptEngine/block/shortcutredirect.py,sha256=2F20L_7hYMxJY9s02XwxJQIWXaBQM_dwBNZKsOJQsk8,683
36
- TagScriptEngine/block/stopblock.py,sha256=eqNmy9ZUgstU-D7Vg5E5aOXxQSD1Dd1D1wH4rcXQEZQ,1090
37
- TagScriptEngine/block/strf.py,sha256=xL5HL8ADRnb2bYTCaRjZkV4K4y6ZMIb_HEONfTCdT4k,2048
36
+ TagScriptEngine/block/stopblock.py,sha256=C10JCaajiVetEwnP_1T7SwhT8UmBQzWCPpdtDF16nZY,1091
37
+ TagScriptEngine/block/strf.py,sha256=54oVyt8zVlnBWa9iSXtV7szc4eFcY-hUpjRSewzkm7M,2050
38
38
  TagScriptEngine/block/strictvariablegetter.py,sha256=XMwqGad3iy5esB2aTiD5v1EaCLGDFMvB1RF11G0-l2M,1251
39
39
  TagScriptEngine/block/substr.py,sha256=QNtoOIBBC-tD2v4vT1NzmrSA5THJ_pOqQLezxWED8ek,835
40
- TagScriptEngine/block/urlencodeblock.py,sha256=NlCSAbAgfPvG4Jh0L1ct8VyS9i4ow6V_5VXKsM36mNk,1398
40
+ TagScriptEngine/block/urlencodeblock.py,sha256=sWqdSBk-uTZZjebKhAFmlROvnQvLcjvyISPTiWb4nwM,1396
41
41
  TagScriptEngine/interface/__init__.py,sha256=37lAOMONKmWDLiC5Ox9Y3TNQUQbzW54oUugbQe0e9gc,341
42
42
  TagScriptEngine/interface/adapter.py,sha256=4jBBz7hc-8fsRSZ5DWOrUxrhXqS0SvJCdW57TZl8sQo,1967
43
43
  TagScriptEngine/interface/block.py,sha256=S0hWRH6uqBz_cYRIh3LGMyo63UK6gNidtf6EiLUKL0c,3653
44
- advancedtagscript-3.2.4.dist-info/licenses/LICENSE,sha256=NvdimESU3jrNgd_8E4i-eTecQ_jGegRrrWk1v2gOnHY,252
45
- advancedtagscript-3.2.4.dist-info/METADATA,sha256=qa42aduC-bFUe0vJJUaBXSqdycyD_V4QpEkE_UZPafU,3653
46
- advancedtagscript-3.2.4.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
47
- advancedtagscript-3.2.4.dist-info/top_level.txt,sha256=6lY4lZDvWxraERrit1lvDsCCDdfo9e83kk_tBemAJCo,16
48
- advancedtagscript-3.2.4.dist-info/RECORD,,
44
+ advancedtagscript-3.2.5.dist-info/licenses/LICENSE,sha256=NvdimESU3jrNgd_8E4i-eTecQ_jGegRrrWk1v2gOnHY,252
45
+ advancedtagscript-3.2.5.dist-info/METADATA,sha256=oAjLywIMfGdHeRzKxJJkHQn-I11q8ya5haXYGylIe_Y,3565
46
+ advancedtagscript-3.2.5.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
47
+ advancedtagscript-3.2.5.dist-info/top_level.txt,sha256=6lY4lZDvWxraERrit1lvDsCCDdfo9e83kk_tBemAJCo,16
48
+ advancedtagscript-3.2.5.dist-info/RECORD,,
@@ -1,29 +0,0 @@
1
- from typing import Optional, Tuple
2
- from ..interface import Block
3
- from ..interpreter import Context
4
-
5
-
6
- class CommentBlock(Block):
7
- """
8
- The comment block is just for comments, it will not be parsed,
9
- however it will be removed from your tag's output.
10
-
11
- **Usage:** ``{comment([other]):[text]}``
12
-
13
- **Aliases:** /, Comment, comment, //, #
14
-
15
- **Payload:** ``text``
16
-
17
- **Parameter:** ``other``
18
-
19
- .. tagscript::
20
-
21
- {#:Comment!}
22
-
23
- {Comment(Something):Comment!}
24
- """
25
-
26
- ACCEPTED_NAMES: Tuple[str, ...] = ("/", "Comment", "comment", "//", "#")
27
-
28
- def process(self, ctx: Context) -> Optional[str]:
29
- return ""