crxsnake 1.3.6__tar.gz → 1.3.8__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.1
2
2
  Name: crxsnake
3
- Version: 1.3.6
3
+ Version: 1.3.8
4
4
  Home-page: https://discord.gg/EEp67FWQDP
5
5
  Author: CRX-DEV
6
6
  Author-email: cherniq66@gmail.com
@@ -2,6 +2,7 @@ from .logger import logger
2
2
  from .cogs import load_cogs
3
3
  from .files import read_json, write_json
4
4
  from .tortoise import Database
5
+ from .embed import EmbedMessage
5
6
 
6
7
  from .utils.misc import *
7
8
  from .utils.hotline import IssueHotline
@@ -17,4 +18,7 @@ __all__ = [
17
18
  "Database",
18
19
  "IssueHotline",
19
20
  "IssueCRX",
21
+ "EmbedMessage",
22
+ "steam_to_be_guid",
23
+ "steam_to_dayz_guid"
20
24
  ]
@@ -0,0 +1,90 @@
1
+ from typing import Optional, Dict, Any
2
+
3
+ from disnake import Embed, Forbidden, Colour
4
+ from disnake.ext import commands
5
+ from crxsnake.utils.misc import trans
6
+
7
+
8
+ class EmbedMessage:
9
+
10
+ def __init__(self, bot: commands.Bot):
11
+ self.bot = bot
12
+
13
+ async def send_channel(
14
+ self,
15
+ channel_id: int,
16
+ title: Optional[str] = None,
17
+ description: Optional[str] = None,
18
+ color: Optional[Colour] = trans,
19
+ url: Optional[str] = None,
20
+ image: Optional[str] = None,
21
+ footer: Optional[str] = None,
22
+ fields: Optional[Dict[str, Any]] = None
23
+ ) -> None:
24
+ """Send an Embed message to the channel"""
25
+ channel = await self.bot.fetch_channel(channel_id)
26
+ if channel:
27
+ embed = self.__create_embed(
28
+ title,
29
+ description,
30
+ color,
31
+ url,
32
+ image,
33
+ footer,
34
+ fields
35
+ )
36
+ await channel.send(embed=embed)
37
+
38
+ async def send_user(
39
+ self,
40
+ user_id: int,
41
+ title: Optional[str] = None,
42
+ description: Optional[str] = None,
43
+ color: Optional[Colour] = trans,
44
+ url: Optional[str] = None,
45
+ image: Optional[str] = None,
46
+ footer: Optional[str] = None,
47
+ fields: Optional[Dict[str, Any]] = None
48
+ ) -> None:
49
+ """Send an Embed message to the user"""
50
+ try:
51
+ user = await self.bot.fetch_user(user_id)
52
+ if user:
53
+ embed = self.__create_embed(
54
+ title,
55
+ description,
56
+ color,
57
+ url,
58
+ image,
59
+ footer,
60
+ fields
61
+ )
62
+ await user.send(embed=embed)
63
+ except Forbidden:
64
+ pass
65
+
66
+ @staticmethod
67
+ def __create_embed(
68
+ title: Optional[str] = None,
69
+ description: Optional[str] = None,
70
+ color: Optional[Colour] = trans,
71
+ url: Optional[str] = None,
72
+ image: Optional[str] = None,
73
+ footer: Optional[str] = None,
74
+ fields: Optional[Dict[str, Any]] = None
75
+ ) -> Embed:
76
+ """Return Embed"""
77
+ embed = Embed(
78
+ title=title if title else "Без названия",
79
+ description=description if description else "Описание отсутствует",
80
+ url=url,
81
+ color=color
82
+ )
83
+ if image:
84
+ embed.set_image(url=image)
85
+ if footer:
86
+ embed.set_footer(text=footer)
87
+ if fields:
88
+ for name, value in fields.items():
89
+ embed.add_field(name=name, value=value, inline=False)
90
+ return embed
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: crxsnake
3
- Version: 1.3.6
3
+ Version: 1.3.8
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.3.6",
20
+ version="1.3.8",
21
21
  long_description=long_description,
22
22
  long_description_content_type="text/markdown",
23
23
  author="CRX-DEV",
@@ -1,26 +0,0 @@
1
- from disnake import Embed, Forbidden, Color
2
- from disnake.ext import commands
3
-
4
-
5
- class Embed:
6
-
7
- def __init__(self, bot: commands.Bot):
8
- self.bot = bot
9
-
10
- async def send_channel(self, channel_id: int, title: str, desc: str, color: Color):
11
- channel = await self.bot.fetch_channel(channel_id)
12
- if channel:
13
- embed = self.__create_embed(title, desc, color)
14
- await channel.send(embed=embed)
15
-
16
- async def send_user(self, user_id: int, title: str, desc: str, color: Color):
17
- try:
18
- user = await self.bot.fetch_user(user_id)
19
- if user:
20
- embed = self.__create_embed(title, desc, color)
21
- await user.send(embed=embed)
22
- except Forbidden:
23
- pass
24
-
25
- def __create_embed(self, title: str, desc: str, color: Color):
26
- return Embed(title=title, description=desc, color=color)
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes