This commit is contained in:
MadCat9958 2023-06-03 23:12:20 +03:00
parent cf683fa14f
commit ba766161dc
3 changed files with 54 additions and 113 deletions

View file

@ -20,7 +20,7 @@ class HttpClient:
loop: `asyncio loop` loop: `asyncio loop`
""" """
def __init__(self, auth_token: str, version: int = 1, **kwargs): def __init__(self, auth_token: str, version: int = 3, **kwargs):
self.token = auth_token self.token = auth_token
self.API_URL = f"https://api.boticord.top/v{version}/" self.API_URL = f"https://api.boticord.top/v{version}/"
@ -60,56 +60,26 @@ class HttpClient:
def get_bot_info(self, bot_id: int): def get_bot_info(self, bot_id: int):
"""Get information about the specified bot""" """Get information about the specified bot"""
return self.make_request("GET", f"bot/{bot_id}") return self.make_request("GET", f"bots/{bot_id}")
# TODO
def get_bot_comments(self, bot_id: int): def get_bot_comments(self, bot_id: int):
"""Get list of specified bot comments""" """Get list of specified bot comments"""
return self.make_request("GET", f"bot/{bot_id}/comments") return self.make_request("GET", f"bot/{bot_id}/comments")
def post_bot_stats(self, stats: dict): def post_bot_stats(self, bot_id: int, stats: dict):
"""Post bot's stats""" """Post bot's stats"""
return self.make_request("POST", "stats", json=stats) return self.make_request("POST", f"bots/{bot_id}", json=stats)
def get_server_info(self, server_id: int): def get_server_info(self, server_id: int):
"""Get information about specified server""" """Get information about specified server"""
return self.make_request("GET", f"server/{server_id}") return self.make_request("GET", f"servers/{server_id}")
# TODO
def get_server_comments(self, server_id: int): def get_server_comments(self, server_id: int):
"""Get list of specified server comments""" """Get list of specified server comments"""
return self.make_request("GET", f"server/{server_id}/comments") return self.make_request("GET", f"server/{server_id}/comments")
def post_server_stats(self, payload: dict):
"""Post server's stats"""
return self.make_request("POST", "server", json=payload)
def get_user_info(self, user_id: int): def get_user_info(self, user_id: int):
"""Get information about the user""" """Get information about the user"""
return self.make_request("GET", f"profile/{user_id}") return self.make_request("GET", f"users/{user_id}")
def get_user_comments(self, user_id: int):
"""Get specified user's comments"""
return self.make_request("GET", f"user/{user_id}/comments")
def get_user_bots(self, user_id: int):
"""Get bots of specified user"""
return self.make_request("GET", f"bots/{user_id}")
def get_my_shorted_links(self, code: str = None):
"""Get shorted links of an authorized user"""
body = {"code": code} if code is not None else {}
return self.make_request("POST", "links/get", json=body)
def create_shorted_link(self, code: str, link: str, *, domain: LinkDomain = 1):
"""Create new shorted link"""
return self.make_request(
"POST",
"links/create",
json={"code": code, "link": link, "domain": int(domain)},
)
def delete_shorted_link(self, code: str, domain: LinkDomain = 1):
"""Delete shorted link"""
return self.make_request(
"POST", "links/delete", json={"code": code, "domain": int(domain)}
)

View file

@ -98,105 +98,74 @@ class Bot(ApiData):
id: str id: str
"""Bot's Id""" """Bot's Id"""
short_code: typing.Optional[str] name: str
"""Bot's page short code""" """Bot's name"""
page_links: list shortDescription: str
"""List of bot's page urls"""
server: dict
"""Bot's support server"""
bumps: int
"""Bumps count"""
added: str
"""How many times users have added the bot?"""
prefix: str
"""Bot's commands prefix"""
permissions: int
"""Bot's permissions"""
tags: list
"""Bot's search-tags"""
developers: list
"""List of bot's developers Ids"""
links: typing.Optional[dict]
"""Bot's social medias"""
library: typing.Optional[str]
"""Bot's library"""
short_description: typing.Optional[str]
"""Bot's short description""" """Bot's short description"""
long_description: typing.Optional[str] description: str
"""Bot's long description""" """Bot's long description"""
badge: typing.Optional[str] avatar: typing.Optional[str]
"""Bot's badge""" """Bot's avatar"""
stats: dict shortLink: typing.Optional[str]
"""Bot's stats""" """Bot's page short code"""
status: str inviteLink: str
"""Bot's approval status""" """Bot's invite link"""
def __init__(self, **kwargs): premiumActive: bool
super().__init__(**parse_with_information_dict(kwargs)) """Bot's premium status"""
premiumSplashURL: typing.Optional[str]
"""Bot's splash URL"""
class Server(ApiData): premiumAutoFetch: typing.Optional[bool]
"""This model represents a server, returned from the Boticord API""" """Bot's auto fetch status"""
id: str standardBannerID: int
"""Server's Id""" """Bot's standart banner ID"""
short_code: typing.Optional[str] premiumBannerURL: typing.Optional[str]
"""Server's page short code""" """Bot's premium banner URL"""
status: str owner: str
"""Server's approval status""" """Bot's owner"""
page_links: list status: int
"""List of server's page urls""" """Bot's status"""
bot: dict prefix: str
"""Bot where this server is used for support users""" """Bot's prefix"""
name: str discriminator: str
"""Name of the server""" """Bot's discriminator (soon deprecated)"""
avatar: str createdDate: str
"""Server's avatar""" """Bot's creation date"""
members: list supportServerInviteLink: typing.Optional[str]
"""Members counts - `[all, online]`""" """Bot's support server"""
owner: typing.Optional[str] library: typing.Optional[int]
"""Server's owner Id""" """Bot's library"""
bumps: int guilds: typing.Optional[int]
"""Bumps count""" """Bot's guilds count"""
tags: list shards: typing.Optional[int]
"""Server's search-tags""" """Bot's shards count"""
links: dict members: typing.Optional[int]
"""Server's social medias""" """Bot's members count"""
short_description: typing.Optional[str] website: typing.Optional[str]
"""Server's short description""" """Bot's website"""
long_description: typing.Optional[str] upCount: int
"""Server's long description""" """Bot's up count"""
badge: typing.Optional[str]
"""Server's badge"""
def __init__(self, **kwargs): def __init__(self, **kwargs):
super().__init__(**parse_with_information_dict(kwargs)) super().__init__(**parse_with_information_dict(kwargs))

View file

@ -11,6 +11,8 @@ class Webhook:
"""Represents a client that can be used to work with BotiCord Webhooks. """Represents a client that can be used to work with BotiCord Webhooks.
IP of the server - your machine IP. (`0.0.0.0`) IP of the server - your machine IP. (`0.0.0.0`)
Note: you need to have IPV6 support to use this
Args: Args:
x_hook_key (:obj:`str`) x_hook_key (:obj:`str`)
X-hook-key to check the auth of incoming request. X-hook-key to check the auth of incoming request.