crxsnake 1.4.4__tar.gz → 1.4.5__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: crxsnake
3
- Version: 1.4.4
3
+ Version: 1.4.5
4
4
  Home-page: https://discord.gg/EEp67FWQDP
5
5
  Author: CRX-DEV
6
6
  Author-email: cherniq66@gmail.com
@@ -0,0 +1,77 @@
1
+ from typing import Optional, Tuple, List, NoReturn
2
+ from disnake import TextChannel, User, Embed, Forbidden, HTTPException
3
+
4
+
5
+ class EmbedLog:
6
+
7
+ @classmethod
8
+ def build_embed(
9
+ cls,
10
+ title: Optional[str] = None,
11
+ color: Optional[int] = None,
12
+ fields: Optional[List[Tuple[str, str, bool]]] = None,
13
+ desc: Optional[str] = None,
14
+ url: Optional[str] = None,
15
+ thumbnail: Optional[str] = None,
16
+ image: Optional[str] = None,
17
+ footer: Optional[str] = None,
18
+ ) -> Embed:
19
+ """Создает Embed с заданными параметрами."""
20
+ embed = Embed(title=title, description=desc, color=color, url=url)
21
+
22
+ if fields:
23
+ for name, value, inline in fields:
24
+ embed.add_field(name=name, value=value, inline=inline)
25
+
26
+ if thumbnail:
27
+ embed.set_thumbnail(url=thumbnail)
28
+ if image:
29
+ embed.set_image(url=image)
30
+ if footer:
31
+ embed.set_footer(text=footer)
32
+
33
+ return embed
34
+
35
+ async def send_channel(
36
+ self,
37
+ channel: TextChannel,
38
+ title: Optional[str] = None,
39
+ color: Optional[int] = None,
40
+ fields: Optional[List[Tuple[str, str, bool]]] = None,
41
+ desc: Optional[str] = None,
42
+ url: Optional[str] = None,
43
+ thumbnail: Optional[str] = None,
44
+ image: Optional[str] = None,
45
+ footer: Optional[str] = None,
46
+ custom_embed: Optional[Embed] = None,
47
+ ) -> None:
48
+ embed = custom_embed or self.build_embed(
49
+ title, color, fields, desc, url, thumbnail, image, footer
50
+ )
51
+ try:
52
+ await channel.send(embed=embed)
53
+ except Forbidden:
54
+ print(f"[Ошибка] Нет прав на отправку сообщений в канал {channel.name}")
55
+ except HTTPException as e:
56
+ print(f"[Ошибка] Не удалось отправить сообщение: {e}")
57
+
58
+ async def send_user(
59
+ self,
60
+ user: User,
61
+ title: Optional[str] = None,
62
+ color: Optional[int] = None,
63
+ fields: Optional[List[Tuple[str, str, bool]]] = None,
64
+ desc: Optional[str] = None,
65
+ url: Optional[str] = None,
66
+ thumbnail: Optional[str] = None,
67
+ image: Optional[str] = None,
68
+ footer: Optional[str] = None,
69
+ custom_embed: Optional[Embed] = None,
70
+ ) -> None:
71
+ embed = custom_embed or self.build_embed(
72
+ title, color, fields, desc, url, thumbnail, image, footer
73
+ )
74
+ try:
75
+ await user.send(embed=embed)
76
+ except Exception:
77
+ pass
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: crxsnake
3
- Version: 1.4.4
3
+ Version: 1.4.5
4
4
  Home-page: https://discord.gg/EEp67FWQDP
5
5
  Author: CRX-DEV
6
6
  Author-email: cherniq66@gmail.com
@@ -17,7 +17,7 @@ urls = {
17
17
 
18
18
  setup(
19
19
  name="crxsnake",
20
- version="1.4.4",
20
+ version="1.4.5",
21
21
  long_description=long_description,
22
22
  long_description_content_type="text/markdown",
23
23
  author="CRX-DEV",
@@ -1,48 +0,0 @@
1
- from typing import Optional, Tuple, List
2
- from disnake import TextChannel, User, Embed, Forbidden, HTTPException
3
-
4
-
5
- class EmbedLog:
6
-
7
- @staticmethod
8
- def build_embed(
9
- title: Optional[str] = None,
10
- color: Optional[int] = None,
11
- fields: Optional[List[Tuple[str, str, bool]]] = None,
12
- desc: Optional[str] = None,
13
- url: Optional[str] = None,
14
- thumbnail: Optional[str] = None,
15
- image: Optional[str] = None,
16
- footer: Optional[str] = None,
17
- ) -> Embed:
18
-
19
- embed = Embed(title=title, description=desc, color=color, url=url)
20
-
21
- if fields:
22
- for name, value, inline in fields:
23
- embed.add_field(name=name, value=value, inline=inline)
24
-
25
- if thumbnail:
26
- embed.set_thumbnail(url=thumbnail)
27
- if image:
28
- embed.set_image(url=image)
29
- if footer:
30
- embed.set_footer(text=footer)
31
-
32
- return embed
33
-
34
- async def send_channel(self, channel: TextChannel, **kwargs) -> None:
35
- embed = self.build_embed(**kwargs)
36
- try:
37
- await channel.send(embed=embed)
38
- except Forbidden:
39
- print(f"[Ошибка] Нет прав на отправку сообщений в канал {channel.name}.")
40
- except HTTPException as e:
41
- print(f"[Ошибка] Не удалось отправить сообщение: {e}")
42
-
43
- async def send_user(self, user: User, **kwargs) -> None:
44
- embed = self.build_embed(**kwargs)
45
- try:
46
- await user.send(embed=embed)
47
- except Exception:
48
- pass
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes