mirror of
https://github.com/boticord/boticordpy.git
synced 2024-11-14 12:27:28 +03:00
commit
16fdb4d0ea
4 changed files with 25 additions and 23 deletions
|
@ -88,6 +88,22 @@ class BoticordClient:
|
||||||
response = await self.http.get_server_info(server_id)
|
response = await self.http.get_server_info(server_id)
|
||||||
return boticord_types.ResourceServer.from_dict(response)
|
return boticord_types.ResourceServer.from_dict(response)
|
||||||
|
|
||||||
|
async def get_user_info(
|
||||||
|
self, user_id: typing.Union[str, int]
|
||||||
|
) -> boticord_types.UserProfile:
|
||||||
|
"""Gets information about specified user.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
user_id (Union[:obj:`str`, :obj:`int`])
|
||||||
|
Id of the user
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
:obj:`~.types.UserProfile`:
|
||||||
|
UserProfile object.
|
||||||
|
"""
|
||||||
|
response = await self.http.get_user_info(user_id)
|
||||||
|
return boticord_types.UserProfile.from_dict(response)
|
||||||
|
|
||||||
def autopost(self) -> AutoPost:
|
def autopost(self) -> AutoPost:
|
||||||
"""Returns a helper instance for auto-posting.
|
"""Returns a helper instance for auto-posting.
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,7 @@ class HttpClient:
|
||||||
|
|
||||||
self.session = kwargs.get("session") or aiohttp.ClientSession(loop=loop)
|
self.session = kwargs.get("session") or aiohttp.ClientSession(loop=loop)
|
||||||
|
|
||||||
async def make_request(self, method: str, endpoint: str, **kwargs):
|
async def make_request(self, method: str, endpoint: str, **kwargs) -> dict:
|
||||||
"""Send requests to the API"""
|
"""Send requests to the API"""
|
||||||
|
|
||||||
kwargs["headers"] = {"Content-Type": "application/json"}
|
kwargs["headers"] = {"Content-Type": "application/json"}
|
||||||
|
@ -60,3 +60,7 @@ class HttpClient:
|
||||||
def get_server_info(self, server_id: typing.Union[str, int]):
|
def get_server_info(self, server_id: typing.Union[str, int]):
|
||||||
"""Get information about specified server"""
|
"""Get information about specified server"""
|
||||||
return self.make_request("GET", f"servers/{server_id}")
|
return self.make_request("GET", f"servers/{server_id}")
|
||||||
|
|
||||||
|
def get_user_info(self, user_id: typing.Union[str, int]):
|
||||||
|
"""Get information about specified user"""
|
||||||
|
return self.make_request("GET", f"users/{user_id}")
|
||||||
|
|
|
@ -401,12 +401,13 @@ class UserLinks(APIObjectBase):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
self: UserLinks = super().__new__(cls)
|
self: UserLinks = super().__new__(cls)
|
||||||
|
data = data or {}
|
||||||
|
|
||||||
self.vk = data.get("vk")
|
self.vk = data.get("vk")
|
||||||
self.telegram = data.get("telegram")
|
self.telegram = data.get("telegram")
|
||||||
self.donate = data.get("donate")
|
self.donate = data.get("donate")
|
||||||
self.git = data.get("git")
|
self.git = data.get("git")
|
||||||
self.custon = data.get("custom")
|
self.custom = data.get("custom")
|
||||||
|
|
||||||
return self
|
return self
|
||||||
|
|
||||||
|
@ -547,7 +548,7 @@ class PartialUser(APIObjectBase):
|
||||||
self.discriminator = data["discriminator"]
|
self.discriminator = data["discriminator"]
|
||||||
self.avatar = data.get("avatar")
|
self.avatar = data.get("avatar")
|
||||||
self.id = data["id"]
|
self.id = data["id"]
|
||||||
self.socials = UserLinks.from_dict(data["socials"])
|
self.socials = UserLinks.from_dict(data.get("socials", {}))
|
||||||
self.description = data.get("description")
|
self.description = data.get("description")
|
||||||
self.short_description = data.get("shortDescription")
|
self.short_description = data.get("shortDescription")
|
||||||
self.status = data.get("status")
|
self.status = data.get("status")
|
||||||
|
@ -647,6 +648,7 @@ class ResourceServer(APIObjectBase):
|
||||||
self.owner = data.get("owner")
|
self.owner = data.get("owner")
|
||||||
self.website = data.get("website")
|
self.website = data.get("website")
|
||||||
self.up_count = data.get("upCount")
|
self.up_count = data.get("upCount")
|
||||||
|
self.standart_banner_id = data.get("standartBannerID")
|
||||||
|
|
||||||
self.premium_active = data["premium"].get("active")
|
self.premium_active = data["premium"].get("active")
|
||||||
self.premium_splash_url = data["premium"].get("splashURL")
|
self.premium_splash_url = data["premium"].get("splashURL")
|
||||||
|
|
|
@ -1,20 +0,0 @@
|
||||||
# You can use any library to interact with the Discord API.
|
|
||||||
# This example uses discord.py.
|
|
||||||
# You can install it with `pip install discord.py`.
|
|
||||||
|
|
||||||
from discord.ext import commands
|
|
||||||
from boticordpy import webhook
|
|
||||||
|
|
||||||
bot = commands.Bot(command_prefix="!")
|
|
||||||
|
|
||||||
|
|
||||||
async def edit_bot_comment(data):
|
|
||||||
print(data.comment.new)
|
|
||||||
|
|
||||||
|
|
||||||
boticord_webhook = webhook.Webhook("x-hook-key", "bot").register_listener(
|
|
||||||
"edit_bot_comment", edit_bot_comment
|
|
||||||
)
|
|
||||||
boticord_webhook.start(5000)
|
|
||||||
|
|
||||||
bot.run("bot_token")
|
|
Loading…
Reference in a new issue