Skip to content

Commit

Permalink
2.2.2a version (test docs)
Browse files Browse the repository at this point in the history
  • Loading branch information
grey-cat-1908 committed Sep 10, 2022
1 parent 45b0440 commit 35dbb2a
Show file tree
Hide file tree
Showing 14 changed files with 148 additions and 213 deletions.
2 changes: 1 addition & 1 deletion boticordpy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
__author__ = "Marakarka"
__license__ = "MIT"
__copyright__ = "Copyright 2022 Marakarka"
__version__ = "2.2.1"
__version__ = "2.2.2a"

from .client import BoticordClient
from .webhook import Webhook
Expand Down
16 changes: 11 additions & 5 deletions boticordpy/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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`)
Expand Down Expand Up @@ -111,6 +111,8 @@ async def get_server_comments(self, server_id: int) -> list:

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`)
Expand Down Expand Up @@ -183,7 +185,9 @@ async def get_my_shorted_links(self, *, code: str = None):
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:
Expand All @@ -202,7 +206,9 @@ async def create_shorted_link(self, *, code: str, link: str, domain: boticord_ty

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:
Expand All @@ -217,7 +223,7 @@ async def delete_shorted_link(self, code: str, domain: boticord_types.LinkDomain
"""
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.
Expand Down
4 changes: 3 additions & 1 deletion boticordpy/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,9 @@ def get_my_shorted_links(self, code: str = None):
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):
Expand Down
3 changes: 0 additions & 3 deletions boticordpy/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"""

Expand Down
2 changes: 1 addition & 1 deletion docs-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
sphinx_rtd_theme
sphinxawesome_theme
sphinx
2 changes: 0 additions & 2 deletions docs/source/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ API Reference

API Reference for the boticordpy Module

Index:

.. toctree::
:maxdepth: 2

Expand Down
2 changes: 2 additions & 0 deletions docs/source/api/types.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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:
20 changes: 9 additions & 11 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@

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 ---------------------------------------------------
Expand All @@ -44,7 +44,7 @@
]

# 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.
Expand All @@ -62,17 +62,15 @@
# 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")
35 changes: 16 additions & 19 deletions docs/source/other.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,22 @@ Other Information
Listeners
##########

List of listeners for webhooks

+------------------------+----------------------------------+
| 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 |
+------------------------+----------------------------------+
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:

.. 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"


##################
Expand Down
62 changes: 1 addition & 61 deletions docs/source/quickstart.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
------------
Expand All @@ -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")


..

11 changes: 7 additions & 4 deletions examples/autopost.py
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
12 changes: 8 additions & 4 deletions examples/webhooks.py
Original file line number Diff line number Diff line change
@@ -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="!")
Expand All @@ -10,7 +11,10 @@
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 changes: 17 additions & 9 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,32 @@

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

Expand Down
Loading

0 comments on commit 35dbb2a

Please sign in to comment.