diff --git a/boticordpy/__init__.py b/boticordpy/__init__.py
index af7cc30..8789273 100644
--- a/boticordpy/__init__.py
+++ b/boticordpy/__init__.py
@@ -10,7 +10,7 @@ __title__ = "boticordpy"
__author__ = "Marakarka"
__license__ = "MIT"
__copyright__ = "Copyright 2022 Marakarka"
-__version__ = "2.2.1"
+__version__ = "2.2.2a"
from .client import BoticordClient
from .webhook import Webhook
diff --git a/boticordpy/client.py b/boticordpy/client.py
index 5c48461..84473ee 100644
--- a/boticordpy/client.py
+++ b/boticordpy/client.py
@@ -11,10 +11,10 @@ class BoticordClient:
.. warning::
In BotiCord API v2 there are some changes with token.
- [Read more here](https://docs.boticord.top/topics/v1vsv2/)
+ `Read more here `_
Note:
- Remember that every http method can return http exception.
+ Remember that every http method can return an http exception.
Args:
token (:obj:`str`)
@@ -111,6 +111,8 @@ class BoticordClient:
async def post_server_stats(self, payload: dict) -> dict:
"""Post Server's stats. You must be Boticord-Service bot.
+ Payload is raw, because if you use it - you know what you are doing.
+ You can find more information about payload `in BotiCord API Docs `_
Args:
payload (:obj:`dict`)
@@ -183,7 +185,9 @@ class BoticordClient:
else boticord_types.ShortedLink(**response[0])
)
- async def create_shorted_link(self, *, code: str, link: str, domain: boticord_types.LinkDomain = 1):
+ async def create_shorted_link(
+ self, *, code: str, link: str, domain: boticord_types.LinkDomain = 1
+ ):
"""Creates new shorted link
Args:
@@ -202,7 +206,9 @@ class BoticordClient:
return boticord_types.ShortedLink(**response)
- async def delete_shorted_link(self, code: str, domain: boticord_types.LinkDomain = 1):
+ async def delete_shorted_link(
+ self, code: str, domain: boticord_types.LinkDomain = 1
+ ):
"""Deletes shorted link
Args:
@@ -217,7 +223,7 @@ class BoticordClient:
"""
response = await self.http.delete_shorted_link(code, domain)
- return response.get('ok', False)
+ return response.get("ok", False)
def autopost(self) -> AutoPost:
"""Returns a helper instance for auto-posting.
diff --git a/boticordpy/http.py b/boticordpy/http.py
index 7124a86..c8ca187 100644
--- a/boticordpy/http.py
+++ b/boticordpy/http.py
@@ -103,7 +103,9 @@ class HttpClient:
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)}
+ "POST",
+ "links/create",
+ json={"code": code, "link": link, "domain": int(domain)},
)
def delete_shorted_link(self, code: str, domain: LinkDomain = 1):
diff --git a/boticordpy/types.py b/boticordpy/types.py
index cbd1c8b..8998a36 100644
--- a/boticordpy/types.py
+++ b/boticordpy/types.py
@@ -348,9 +348,6 @@ class LinkDomain(IntEnum):
BCORD_CC = 1
"""``bcord.cc`` domain, default"""
- MYSERVERS_ME = 2
- """``myservers.me`` domain"""
-
DISCORD_CAMP = 3
"""``discord.camp`` domain"""
diff --git a/docs-requirements.txt b/docs-requirements.txt
index e1aaddb..2ae7816 100644
--- a/docs-requirements.txt
+++ b/docs-requirements.txt
@@ -1,2 +1,2 @@
-sphinx_rtd_theme
+sphinxawesome_theme
sphinx
\ No newline at end of file
diff --git a/docs/source/api.rst b/docs/source/api.rst
index cf0c356..706644a 100644
--- a/docs/source/api.rst
+++ b/docs/source/api.rst
@@ -8,8 +8,6 @@ API Reference
API Reference for the boticordpy Module
-Index:
-
.. toctree::
:maxdepth: 2
diff --git a/docs/source/api/types.rst b/docs/source/api/types.rst
index 3fc4460..dc0a263 100644
--- a/docs/source/api/types.rst
+++ b/docs/source/api/types.rst
@@ -2,5 +2,7 @@
Models API Reference
####################
+We recommend you to read the `boticordpy/types.py `_ file, because it is much easier to read than here.
+
.. automodule:: boticordpy.types
:members:
diff --git a/docs/source/conf.py b/docs/source/conf.py
index 01bed7b..632e3f3 100644
--- a/docs/source/conf.py
+++ b/docs/source/conf.py
@@ -22,12 +22,12 @@ import os
sys.path.insert(0, os.path.abspath("../.."))
-project = 'BoticordPY'
-copyright = '2022, Victor Kotlin (Marakarka)'
-author = 'Victor Kotlin (Marakarka)'
+project = "BoticordPY"
+copyright = "2022, Victor Kotlin (Marakarka)"
+author = "Victor Kotlin (Marakarka)"
# The full version, including alpha/beta/rc tags
-release = '2.0.0'
+release = "2.2.2a"
# -- General configuration ---------------------------------------------------
@@ -44,7 +44,7 @@ extensions = [
]
# Add any paths that contain templates here, relative to this directory.
-templates_path = ['_templates']
+templates_path = ["_templates"]
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
@@ -62,17 +62,15 @@ intersphinx_mapping = {
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
-html_theme = "sphinx_rtd_theme"
+html_theme = "sphinxawesome_theme"
-html_theme_options = {
-
-}
+html_theme_options = {}
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "custom.css" will overwrite the builtin "custom.css".
-html_static_path = ['_static']
+html_static_path = ["_static"]
def setup(app):
- app.add_css_file('custom.css')
+ app.add_css_file("custom.css")
diff --git a/docs/source/other.rst b/docs/source/other.rst
index 0e9eede..eb26853 100644
--- a/docs/source/other.rst
+++ b/docs/source/other.rst
@@ -9,25 +9,22 @@ Other Information
Listeners
##########
-List of listeners for webhooks
+When you work with BotiCord Webhooks you may receive a lot of events.
+To make it easier to handle them there is a list of the events you can receive:
-+------------------------+----------------------------------+
-| Boticord Events | Meaning |
-+========================+==================================+
-| new_bot_comment | On new bot comment |
-+------------------------+----------------------------------+
-| edit_bot_comment | On bot comment edit |
-+------------------------+----------------------------------+
-| delete_bot_comment | On bot comment delete |
-+------------------------+----------------------------------+
-| new_bot_bump | On new bot bump |
-+------------------------+----------------------------------+
-| new_server_comment | On new server comment |
-+------------------------+----------------------------------+
-| edit_server_comment | On server comment edit |
-+------------------------+----------------------------------+
-| delete_server_comment | On server comment delete |
-+------------------------+----------------------------------+
+.. csv-table::
+ :header: "BotiCord Events", "Meaning"
+ :widths: 20, 20
+
+ "test_webhook_message", "Test message."
+ "new_bot_comment", "On new bot comment"
+ "edit_bot_comment", "On bot comment edit"
+ "delete_bot_comment", "On bot comment delete"
+ "new_bot_bump", "On new bot bump"
+ "new_server_comment", "On new server comment"
+ "edit_server_comment", "On server comment edit"
+ "delete_server_comment", "On server comment delete"
+ "new_server_bump", "On new server bump"
##################
diff --git a/docs/source/quickstart.rst b/docs/source/quickstart.rst
index c6aa9f2..1fd5061 100644
--- a/docs/source/quickstart.rst
+++ b/docs/source/quickstart.rst
@@ -5,7 +5,7 @@
Quickstart
==========
-**For more examples or information about other features check Github-Repo.**
+**For some examples or information about other features check our Github-Repo.**
Installation
------------
@@ -24,63 +24,3 @@ Enter one of these commands to install the library:
Or just clone the repo: https://github.com/boticord/boticordpy
-
-
-Examples
--------------------------
-
-**Discord.py Autopost example**
-
-::
-
- from discord.ext import commands
-
- from boticordpy import BoticordClient
-
- bot = commands.Bot(command_prefix="!")
-
-
- async def get_stats():
- return {"servers": len(bot.guilds), "shards": 0, "users": len(bot.users)}
-
-
- async def on_success_posting():
- print("stats posting successfully")
-
- boticord_client = BoticordClient("your_api_token")
- autopost = (
- boticord_client.autopost()
- .init_stats(get_stats)
- .on_success(on_success_posting)
- .start()
- )
-
- bot.run("bot token")
-
-
-..
-
-
-**Discord.py Webhooks example**
-
-::
-
- 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")
-
-
-..
-
-
diff --git a/examples/autopost.py b/examples/autopost.py
index 0557059..fa903ac 100644
--- a/examples/autopost.py
+++ b/examples/autopost.py
@@ -1,21 +1,24 @@
-# You can use disnake or nextcord or something like this.
-# (THIS EXAMPLE IS NOT TESTED. IF YOU HAVE ANY PROBLEMS - ASK DEVELOPER PLEASE)
+# 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 BoticordClient
bot = commands.Bot(command_prefix="!")
+# Function that will return the current bot's stats.
async def get_stats():
return {"servers": len(bot.guilds), "shards": 0, "users": len(bot.users)}
+# Function that will be called if stats are posted successfully.
async def on_success_posting():
print("stats posting successfully")
-boticord_client = BoticordClient("your_api_token")
+
+boticord_client = BoticordClient("your_api_token", version=2)
autopost = (
boticord_client.autopost()
.init_stats(get_stats)
diff --git a/examples/webhooks.py b/examples/webhooks.py
index 79c675a..5b937a6 100644
--- a/examples/webhooks.py
+++ b/examples/webhooks.py
@@ -1,7 +1,8 @@
-# You can use disnake or nextcord or something like this.
+# 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="!")
@@ -10,7 +11,10 @@ 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 = webhook.Webhook("x-hook-key", "bot").register_listener(
+ "edit_bot_comment", edit_bot_comment
+)
boticord_webhook.start(5000)
-bot.run("bot token")
+bot.run("bot_token")
diff --git a/setup.py b/setup.py
index 7d5bd1b..b0b7a5b 100644
--- a/setup.py
+++ b/setup.py
@@ -5,24 +5,32 @@ import re
HERE = pathlib.Path(__file__).parent
-with open('boticordpy/__init__.py') as f:
- version = re.search(r'^__version__\s*=\s*[\'"]([^\'"]*)[\'"]', f.read(), re.MULTILINE).group(1)
+with open("boticordpy/__init__.py") as f:
+ version = re.search(
+ r'^__version__\s*=\s*[\'"]([^\'"]*)[\'"]', f.read(), re.MULTILINE
+ ).group(1)
-if version.endswith(('a', 'b', 'rc')):
+if version.endswith(("a", "b", "rc")):
# append version identifier based on commit count
try:
import subprocess
- p = subprocess.Popen(['git', 'rev-list', '--count', 'HEAD'],
- stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+ p = subprocess.Popen(
+ ["git", "rev-list", "--count", "HEAD"],
+ stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE,
+ )
out, err = p.communicate()
if out:
- version += out.decode('utf-8').strip()
- p = subprocess.Popen(['git', 'rev-parse', '--short', 'HEAD'],
- stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+ version += out.decode("utf-8").strip()
+ p = subprocess.Popen(
+ ["git", "rev-parse", "--short", "HEAD"],
+ stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE,
+ )
out, err = p.communicate()
if out:
- version += '+g' + out.decode('utf-8').strip()
+ version += "+g" + out.decode("utf-8").strip()
except Exception:
pass
diff --git a/tests/test_converting.py b/tests/test_converting.py
index eec857c..5073fe9 100644
--- a/tests/test_converting.py
+++ b/tests/test_converting.py
@@ -7,111 +7,91 @@ single_comment_dict = {
"text": "aboba",
"vote": 1,
"isUpdated": False,
- "createdAt": 1644388399
+ "createdAt": 1644388399,
}
bot_data_dict = {
- "id": "724663360934772797",
- "shortCode": "kerdoku",
- "links": ["https://boticord.top/bot/724663360934772797",
- "https://bcord.cc/b/724663360934772797",
- "https://myservers.me/b/724663360934772797",
- "https://boticord.top/bot/kerdoku",
- "https://bcord.cc/b/kerdoku",
- "https://myservers.me/b/kerdoku"],
- "server": {
- "id": "724668798874943529",
- "approved": True
- },
- "information": {
- "bumps": 37,
- "added": 1091,
- "prefix": "?",
- "permissions": 1544023111,
- "tags": [
- "комбайн",
- "экономика",
- "модерация",
- "приветствия"
- ],
- "developers": ["585766846268047370"],
- "links": {
- "discord": "5qXgJvr",
- "github": None,
- "site": "https://kerdoku.top"
- },
- "library": "discordpy",
- "shortDescription": "Удобный и дружелюбный бот, который имеет крутой функционал!",
- "longDescription": "wow",
- "badge": None,
- "stats": {
- "servers": 2558,
- "shards": 3,
- "users": 348986
- },
- "status": "APPROVED"
- }
+ "id": "724663360934772797",
+ "shortCode": "kerdoku",
+ "links": [
+ "https://boticord.top/bot/724663360934772797",
+ "https://bcord.cc/b/724663360934772797",
+ "https://myservers.me/b/724663360934772797",
+ "https://boticord.top/bot/kerdoku",
+ "https://bcord.cc/b/kerdoku",
+ "https://myservers.me/b/kerdoku",
+ ],
+ "server": {"id": "724668798874943529", "approved": True},
+ "information": {
+ "bumps": 37,
+ "added": 1091,
+ "prefix": "?",
+ "permissions": 1544023111,
+ "tags": ["комбайн", "экономика", "модерация", "приветствия"],
+ "developers": ["585766846268047370"],
+ "links": {"discord": "5qXgJvr", "github": None, "site": "https://kerdoku.top"},
+ "library": "discordpy",
+ "shortDescription": "Удобный и дружелюбный бот, который имеет крутой функционал!",
+ "longDescription": "wow",
+ "badge": None,
+ "stats": {"servers": 2558, "shards": 3, "users": 348986},
+ "status": "APPROVED",
+ },
}
server_data_dict = {
- "id": "722424773233213460",
- "shortCode": "boticord",
- "status": "ACCEPT_MEMBERS",
- "links": [
- "https://boticord.top/server/722424773233213460",
- "https://bcord.cc/s/722424773233213460",
- "https://myservers.me/s/722424773233213460",
- "https://boticord.top/server/boticord",
- "https://bcord.cc/s/boticord",
- "https://myservers.me/s/boticord"
- ],
- "bot": {
- "id": None,
- "approved": False
- },
- "information": {
- "name": "BotiCord Community",
- "avatar": "https://cdn.discordapp.com/icons/722424773233213460/060188f770836697846710b109272e4c.webp",
- "members": [
- 438,
- 0
- ],
- "bumps": 62,
- "tags": [
- "аниме",
- "игры",
- "поддержка",
- "комьюнити",
- "сообщество",
- "discord",
- "дискорд сервера",
- "дискорд боты"
- ],
- "links": {
- "invite": "hkHjW8a",
- "site": "https://boticord.top/",
- "youtube": None,
- "twitch": None,
- "steam": None,
- "vk": None
- },
- "shortDescription": "short text",
- "longDescription": "long text",
- "badge": "STAFF"
- }
+ "id": "722424773233213460",
+ "shortCode": "boticord",
+ "status": "ACCEPT_MEMBERS",
+ "links": [
+ "https://boticord.top/server/722424773233213460",
+ "https://bcord.cc/s/722424773233213460",
+ "https://myservers.me/s/722424773233213460",
+ "https://boticord.top/server/boticord",
+ "https://bcord.cc/s/boticord",
+ "https://myservers.me/s/boticord",
+ ],
+ "bot": {"id": None, "approved": False},
+ "information": {
+ "name": "BotiCord Community",
+ "avatar": "https://cdn.discordapp.com/icons/722424773233213460/060188f770836697846710b109272e4c.webp",
+ "members": [438, 0],
+ "bumps": 62,
+ "tags": [
+ "аниме",
+ "игры",
+ "поддержка",
+ "комьюнити",
+ "сообщество",
+ "discord",
+ "дискорд сервера",
+ "дискорд боты",
+ ],
+ "links": {
+ "invite": "hkHjW8a",
+ "site": "https://boticord.top/",
+ "youtube": None,
+ "twitch": None,
+ "steam": None,
+ "vk": None,
+ },
+ "shortDescription": "short text",
+ "longDescription": "long text",
+ "badge": "STAFF",
+ },
}
user_profile_dict = {
- "id": '178404926869733376',
+ "id": "178404926869733376",
"status": '"Если вы не разделяете мою точку зрения, поздравляю — вам больше достанется." © Артемий Лебедев',
- "badge": 'STAFF',
- "shortCode": 'cipherka',
- "site": 'https://sqdsh.top/',
+ "badge": "STAFF",
+ "shortCode": "cipherka",
+ "site": "https://sqdsh.top/",
"vk": None,
- "steam": 'sadlycipherka',
+ "steam": "sadlycipherka",
"youtube": None,
"twitch": None,
- "git": 'https://git.sqdsh.top/me'
+ "git": "https://git.sqdsh.top/me",
}