diff --git a/ACKNOWLEDGEMENTS.txt b/ACKNOWLEDGEMENTS.txt
new file mode 100644
index 0000000..b34de64
--- /dev/null
+++ b/ACKNOWLEDGEMENTS.txt
@@ -0,0 +1,8 @@
+These are the open source libraries we use:
+- aiohttp (https://github.com/aio-libs/aiohttp)
+- typing_extensions (https://github.com/python/typing_extensions)
+- sphinx (https://github.com/sphinx-doc/sphinx)
+- furo (https://github.com/pradyunsg/furo)
+
+It is also important to note that some developments of Melisa (https://github.com/MelisaDev/melisa) were used in the development of the project.
+I would also like to express my gratitude to the former admin staff of the BotiCord service (until 06/02/2023) and the entire project community.
\ No newline at end of file
diff --git a/README.md b/README.md
index 0cf1b2f..fc3edaa 100644
--- a/README.md
+++ b/README.md
@@ -22,12 +22,12 @@
* Object-oriented
* Full BotiCord API Coverage
* Modern Pythonic API using `async`/`await` syntax
-* BotiCord Webhooks
+* BotiCord Websocket
* It is not necessary to use any particular library used to interact with the Discord API.
Installation
-Python 3.6 or newer is required.
+Python 3.8 or newer is required.
Enter one of these commands to install the library:
@@ -49,28 +49,33 @@ You can find other examples in an examples folder.
```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")
+ print("wow stats posting works")
-boticord_client = BoticordClient("your_api_token")
+
+boticord_client = BoticordClient(
+ "your_boticord_api_token", version=3
+) # <--- BotiCord API token
autopost = (
boticord_client.autopost()
.init_stats(get_stats)
.on_success(on_success_posting)
- .start()
+ .start("id_of_your_bot") # <--- ID of your bot
)
-bot.run("bot token")
+bot.run("bot token") # <--- Discord bot's token
+
```
Links
diff --git a/boticordpy/__init__.py b/boticordpy/__init__.py
index 422174b..596f461 100644
--- a/boticordpy/__init__.py
+++ b/boticordpy/__init__.py
@@ -10,7 +10,7 @@ __title__ = "boticordpy"
__author__ = "Marakarka"
__license__ = "MIT"
__copyright__ = "Copyright 2021 - 2023 Marakarka"
-__version__ = "3.0.0a"
+__version__ = "3.0.0"
from .client import BoticordClient
from .types import *
diff --git a/boticordpy/autopost.py b/boticordpy/autopost.py
index 5ac5697..321e050 100644
--- a/boticordpy/autopost.py
+++ b/boticordpy/autopost.py
@@ -199,9 +199,9 @@ class AutoPost:
task = asyncio.ensure_future(self._internal_loop())
self._task = task
-
+
_logger.info("Started autoposting")
-
+
return task
def stop(self) -> None:
diff --git a/boticordpy/client.py b/boticordpy/client.py
index fdfb9fc..aab9970 100644
--- a/boticordpy/client.py
+++ b/boticordpy/client.py
@@ -46,7 +46,7 @@ class BoticordClient:
ResourceBot object.
"""
_logger.info("Requesting information about bot")
-
+
response = await self.http.get_bot_info(bot_id)
return boticord_types.ResourceBot.from_dict(response)
@@ -75,7 +75,7 @@ class BoticordClient:
ResourceBot object.
"""
_logger.info("Posting bot stats")
-
+
response = await self.http.post_bot_stats(
bot_id, {"servers": servers, "shards": shards, "users": users}
)
@@ -95,7 +95,7 @@ class BoticordClient:
ResourceServer object.
"""
_logger.info("Requesting information about server")
-
+
response = await self.http.get_server_info(server_id)
return boticord_types.ResourceServer.from_dict(response)
@@ -113,7 +113,7 @@ class BoticordClient:
UserProfile object.
"""
_logger.info("Requesting information about user")
-
+
response = await self.http.get_user_info(user_id)
return boticord_types.UserProfile.from_dict(response)
diff --git a/boticordpy/http.py b/boticordpy/http.py
index 10689b8..4a62222 100644
--- a/boticordpy/http.py
+++ b/boticordpy/http.py
@@ -1,4 +1,3 @@
-from urllib.parse import urlparse
import asyncio
import typing
@@ -23,7 +22,7 @@ class HttpClient:
def __init__(self, auth_token: str = None, version: int = 3, **kwargs):
self.token = auth_token
- self.API_URL = f"https://api.arbuz.pro/"
+ self.API_URL = f"https://api.boticord.top/v{version}"
loop = kwargs.get("loop") or asyncio.get_event_loop()
diff --git a/boticordpy/websocket.py b/boticordpy/websocket.py
index 8ab5f72..3b2bb70 100644
--- a/boticordpy/websocket.py
+++ b/boticordpy/websocket.py
@@ -13,7 +13,7 @@ _logger = logging.getLogger("boticord.websocket")
class BotiCordWebsocket:
"""Represents a client that can be used to interact with the BotiCord by websocket connection."""
-
+
def __init__(self, token: str):
self.__session = None
self.loop = asyncio.get_event_loop()
@@ -25,17 +25,17 @@ class BotiCordWebsocket:
def listener(self):
"""Decorator to set the listener.
-
+
.. warning::
Callback functions must be a **coroutine**. If they aren't, then you might get unexpected
errors. In order to turn a function into a coroutine they must be ``async def``
functions.
-
+
For example:
-
+
.. code-block:: python
-
+
@websocket.listener()
async def comment_removed(data):
pass
@@ -58,7 +58,7 @@ class BotiCordWebsocket:
Type of notification (Check reference page)
callback (:obj:`function`)
Coroutine Callback Function
-
+
.. warning::
Callback functions must be a **coroutine**. If they aren't, then you might get unexpected
@@ -77,7 +77,7 @@ class BotiCordWebsocket:
try:
self.__session = aiohttp.ClientSession()
self.ws = await self.__session.ws_connect(
- "wss://gateway.arbuz.pro/websocket/",
+ "wss://gateway.boticord.top/websocket/",
timeout=30.0,
)
diff --git a/examples/stats_melisa.py b/examples/stats_melisa.py
new file mode 100644
index 0000000..a6bb181
--- /dev/null
+++ b/examples/stats_melisa.py
@@ -0,0 +1,16 @@
+import melisa
+from boticordpy import BoticordClient
+
+bot = melisa.Bot("your_discord_bot_token")
+
+boticord = BoticordClient("your_boticord_api_token")
+
+
+@bot.listen
+async def on_message_create(message):
+ if message.content.startswith("!guilds"):
+ data = await boticord.get_bot_info(bot.user.id)
+ await bot.rest.create_message(message.channel.id, data.guilds)
+
+
+bot.run_autosharded()
diff --git a/examples/websocket.py b/examples/websocket.py
new file mode 100644
index 0000000..7505050
--- /dev/null
+++ b/examples/websocket.py
@@ -0,0 +1,23 @@
+# 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 BotiCordWebsocket
+
+bot = commands.Bot(command_prefix="!")
+
+websocket = BotiCordWebsocket("your_boticord_api_token") # <--- BotiCord API token
+
+
+@websocket.listener()
+async def comment_removed(data):
+ print(data["payload"])
+
+
+@bot.event
+async def on_ready():
+ await websocket.connect()
+
+
+bot.run("bot token") # <--- Discord bot's token