mirror of
https://github.com/boticord/boticordpy.git
synced 2024-09-22 19:32:01 +03:00
Made project ready to release
This commit is contained in:
parent
783c6cb9de
commit
f036b31f21
9 changed files with 74 additions and 23 deletions
8
ACKNOWLEDGEMENTS.txt
Normal file
8
ACKNOWLEDGEMENTS.txt
Normal file
|
@ -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.
|
19
README.md
19
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.
|
||||
|
||||
<h2>Installation</h2>
|
||||
|
||||
<b>Python 3.6 or newer is required.</b>
|
||||
<b>Python 3.8 or newer is required.</b>
|
||||
|
||||
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
|
||||
|
||||
```
|
||||
|
||||
<h2>Links</h2>
|
||||
|
|
|
@ -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 *
|
||||
|
|
|
@ -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()
|
||||
|
||||
|
|
|
@ -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,
|
||||
)
|
||||
|
||||
|
|
16
examples/stats_melisa.py
Normal file
16
examples/stats_melisa.py
Normal file
|
@ -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()
|
23
examples/websocket.py
Normal file
23
examples/websocket.py
Normal file
|
@ -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
|
Loading…
Reference in a new issue