mirror of
https://github.com/boticord/boticordpy.git
synced 2024-09-22 19:32:01 +03:00
2.2.2a version (test docs)
This commit is contained in:
parent
45b04409d4
commit
35dbb2a6b8
14 changed files with 147 additions and 212 deletions
|
@ -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
|
||||
|
|
|
@ -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 <https://docs.boticord.top/topics/v1vsv2/>`_
|
||||
|
||||
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 <https://docs.boticord.top/methods/servers/>`_
|
||||
|
||||
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.
|
||||
|
|
|
@ -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):
|
||||
|
|
|
@ -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"""
|
||||
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
sphinx_rtd_theme
|
||||
sphinxawesome_theme
|
||||
sphinx
|
|
@ -8,8 +8,6 @@ API Reference
|
|||
|
||||
API Reference for the boticordpy Module
|
||||
|
||||
Index:
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 2
|
||||
|
||||
|
|
|
@ -2,5 +2,7 @@
|
|||
Models API Reference
|
||||
####################
|
||||
|
||||
We recommend you to read the `boticordpy/types.py <https://github.com/boticord/boticordpy/blob/master/boticordpy/types.py>`_ file, because it is much easier to read than here.
|
||||
|
||||
.. automodule:: boticordpy.types
|
||||
:members:
|
||||
|
|
|
@ -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")
|
||||
|
|
|
@ -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"
|
||||
|
||||
|
||||
##################
|
||||
|
|
|
@ -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")
|
||||
|
||||
|
||||
..
|
||||
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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")
|
||||
|
|
26
setup.py
26
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
|
||||
|
||||
|
|
|
@ -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",
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue