dswebhook 0.2.2__tar.gz → 0.2.3__tar.gz

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.
@@ -0,0 +1,66 @@
1
+ Metadata-Version: 2.4
2
+ Name: dswebhook
3
+ Version: 0.2.3
4
+ Summary: Lib for easy use of discord webhook
5
+ Author: Beks1k
6
+ Requires-Python: >=3.8
7
+ Description-Content-Type: text/markdown
8
+ License-File: LICENSE
9
+ Requires-Dist: requests>=2.28.0
10
+ Dynamic: license-file
11
+
12
+ # Simple Multi-Webhook Wrapper
13
+
14
+ A minimal and efficient Python wrapper for managing and sending messages to multiple webhooks simultaneously using numeric or string IDs. It includes built-in safeguards, response flashing, and clean custom error descriptions.
15
+
16
+ ## Custom Exceptions
17
+
18
+ The module imports custom exceptions from an external `exceptions` file:
19
+
20
+ - **`InvalidURL`**: Raised if the URL string is empty or missing.
21
+ - **`AlreadyExists`**: Raised if you try to register a URL on an ID that is already taken.
22
+ - **`NoSuchID`**: Raised if you try to send a message using an uninitialized ID.
23
+ - **`ContentTooLarge`**: Raised if the text payload exceeds the 2000-character limit.
24
+ - **`ConnectionError`**: Network issues or host is completely unreachable.
25
+ - **`SchemaError`**: Raised when the URL format misses `http://` or `https://`.
26
+ - **`BadRequest`**: Server returned an explicit HTTP `400` error.
27
+ - **`InternalServerError`**: Server encountered a critical HTTP `500` error.
28
+ - **`HTTPError`**: Triggers for any other non-2xx server responses.
29
+
30
+ ## Core Functions
31
+
32
+ ### `init(url: str, id=1)`
33
+ Registers a webhook URL under a unique identifier.
34
+ - **Default ID:** `1`
35
+ - **Raises:** `InvalidURL` if the URL is empty, `AlreadyExists` if the ID is already registered.
36
+
37
+ ### `send(content: str, ids, statCode: bool = False, flush: bool = False)`
38
+ Dispatches a payload string to the webhook registered under the specified `ids`.
39
+ - **`ids`**: The target webhook identifier.
40
+ - **`statCode`**: If set to `True`, prints the server response status code in the console.
41
+ - **`flush`**: If set to `True`, prints the raw text/JSON response returned from the server endpoint.
42
+
43
+ ## Usage Example
44
+
45
+ ```python
46
+ import dswebhook as dsw
47
+
48
+ # 1. Initialize dswebhook with ID
49
+
50
+ dsw.init("https://discord.com...", id=1)dsw.init("https://discord.com...", "id="backup_channel")
51
+
52
+ # 2. Send logs with debugging features enabled
53
+ try:
54
+ # Sends a message and prints out status code and server raw response text
55
+ dsw.send("System updated successfully!", ids=1, statCode=True, flush=True)
56
+
57
+ # Sends a message to the second text channel using a string ID
58
+ dsw.send("Alert triggered.", ids="backup_channel")
59
+
60
+ except dsw.AlreadyExists as e:
61
+ print(f"Configuration conflict: {e}")
62
+ except dsw.NoSuchID as e:
63
+ print(f"Targeting error: {e}")
64
+ except dsw.HTTPError as e:
65
+ print(f"Server communication failed: {e}")
66
+ ```
@@ -4,7 +4,8 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "dswebhook"
7
- version = "0.2.2"
7
+ version = "0.2.3"
8
+ readme = "README.md"
8
9
  description = "Lib for easy use of discord webhook"
9
10
  requires-python = ">=3.8"
10
11
  authors = [
@@ -15,7 +15,7 @@ def init(url:str, id=1):
15
15
  raise AlreadyExists(f"{id} ALREADY EXSISTS")
16
16
  urlr[id] = url
17
17
 
18
- def send(content:str, ids, statCode:bool=False, flush:bool = False):
18
+ def send(content:str, ids, statCode:bool=False, flush:bool = False, customJSON = {}):
19
19
  '''Send content to specified webhook'''
20
20
  global urlr
21
21
  if not urlr:
@@ -25,6 +25,8 @@ def send(content:str, ids, statCode:bool=False, flush:bool = False):
25
25
  data = {
26
26
  "content":content
27
27
  }
28
+ if customJSON:
29
+ data = customJSON
28
30
  if urlr.get(ids) == None:
29
31
  raise NoSuchID(f"NOT FOUND {ids}")
30
32
  try:
@@ -0,0 +1,66 @@
1
+ Metadata-Version: 2.4
2
+ Name: dswebhook
3
+ Version: 0.2.3
4
+ Summary: Lib for easy use of discord webhook
5
+ Author: Beks1k
6
+ Requires-Python: >=3.8
7
+ Description-Content-Type: text/markdown
8
+ License-File: LICENSE
9
+ Requires-Dist: requests>=2.28.0
10
+ Dynamic: license-file
11
+
12
+ # Simple Multi-Webhook Wrapper
13
+
14
+ A minimal and efficient Python wrapper for managing and sending messages to multiple webhooks simultaneously using numeric or string IDs. It includes built-in safeguards, response flashing, and clean custom error descriptions.
15
+
16
+ ## Custom Exceptions
17
+
18
+ The module imports custom exceptions from an external `exceptions` file:
19
+
20
+ - **`InvalidURL`**: Raised if the URL string is empty or missing.
21
+ - **`AlreadyExists`**: Raised if you try to register a URL on an ID that is already taken.
22
+ - **`NoSuchID`**: Raised if you try to send a message using an uninitialized ID.
23
+ - **`ContentTooLarge`**: Raised if the text payload exceeds the 2000-character limit.
24
+ - **`ConnectionError`**: Network issues or host is completely unreachable.
25
+ - **`SchemaError`**: Raised when the URL format misses `http://` or `https://`.
26
+ - **`BadRequest`**: Server returned an explicit HTTP `400` error.
27
+ - **`InternalServerError`**: Server encountered a critical HTTP `500` error.
28
+ - **`HTTPError`**: Triggers for any other non-2xx server responses.
29
+
30
+ ## Core Functions
31
+
32
+ ### `init(url: str, id=1)`
33
+ Registers a webhook URL under a unique identifier.
34
+ - **Default ID:** `1`
35
+ - **Raises:** `InvalidURL` if the URL is empty, `AlreadyExists` if the ID is already registered.
36
+
37
+ ### `send(content: str, ids, statCode: bool = False, flush: bool = False)`
38
+ Dispatches a payload string to the webhook registered under the specified `ids`.
39
+ - **`ids`**: The target webhook identifier.
40
+ - **`statCode`**: If set to `True`, prints the server response status code in the console.
41
+ - **`flush`**: If set to `True`, prints the raw text/JSON response returned from the server endpoint.
42
+
43
+ ## Usage Example
44
+
45
+ ```python
46
+ import dswebhook as dsw
47
+
48
+ # 1. Initialize dswebhook with ID
49
+
50
+ dsw.init("https://discord.com...", id=1)dsw.init("https://discord.com...", "id="backup_channel")
51
+
52
+ # 2. Send logs with debugging features enabled
53
+ try:
54
+ # Sends a message and prints out status code and server raw response text
55
+ dsw.send("System updated successfully!", ids=1, statCode=True, flush=True)
56
+
57
+ # Sends a message to the second text channel using a string ID
58
+ dsw.send("Alert triggered.", ids="backup_channel")
59
+
60
+ except dsw.AlreadyExists as e:
61
+ print(f"Configuration conflict: {e}")
62
+ except dsw.NoSuchID as e:
63
+ print(f"Targeting error: {e}")
64
+ except dsw.HTTPError as e:
65
+ print(f"Server communication failed: {e}")
66
+ ```
dswebhook-0.2.2/PKG-INFO DELETED
@@ -1,9 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: dswebhook
3
- Version: 0.2.2
4
- Summary: Lib for easy use of discord webhook
5
- Author: Beks1k
6
- Requires-Python: >=3.8
7
- License-File: LICENSE
8
- Requires-Dist: requests>=2.28.0
9
- Dynamic: license-file
@@ -1,9 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: dswebhook
3
- Version: 0.2.2
4
- Summary: Lib for easy use of discord webhook
5
- Author: Beks1k
6
- Requires-Python: >=3.8
7
- License-File: LICENSE
8
- Requires-Dist: requests>=2.28.0
9
- Dynamic: license-file
File without changes
File without changes
File without changes
File without changes