From 71863f05d503beda432812ff8a5fde45e0833b0a Mon Sep 17 00:00:00 2001 From: Victor Kotlin Date: Sat, 11 Sep 2021 16:10:17 +0300 Subject: [PATCH] some new examples --- README.md | 34 +++++++++++++++++++++++++++++- boticordpy.egg-info/PKG-INFO | 36 ++++++++++++++++++++++++++++++-- docs/conf.py | 2 +- docs/quickstart.rst | 40 +++++++++++++++++++++++++++++++++--- examples/example_cog.py | 23 +++++++++++++++++++++ setup.py | 2 +- 6 files changed, 129 insertions(+), 8 deletions(-) create mode 100644 examples/example_cog.py diff --git a/README.md b/README.md index 82523ef..39a83b1 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,8 @@ ### Примеры -Публикуем статистику нашего бота в Boticord. +#### Без Когов +Публикуем статистику при запуске бота. ```Python from discord.ext import commands @@ -33,3 +34,34 @@ async def on_ready(): bot.run("your-bot-token") ``` + +#### С Когами + +Ког с автоматической публикацией статистики раз в 15 минут + команда для публикации статистики для владельца бота. + +```python +from discord.ext import commands + +from boticordpy import BoticordClient + + +class BoticordCog(commands.Cog): + def __init__(self, bot): + self.bot = bot + self.boticord = BoticordClient(self.bot, "your-boticord-token") + self.boticord.start_loop() + + @commands.command(name="boticord-update") + @commands.is_owner() + async def boticord_update(self, ctx): + """ + This commands can be used by owner to post stats to boticord + """ + stats = {"servers": len(self.bot.guilds), "shards": 0, "users": len(self.bot.users)} + await self.boticord.Bots.postStats(stats) + + +def setup(bot): + bot.add_cog(BoticordCog(bot)) + +``` diff --git a/boticordpy.egg-info/PKG-INFO b/boticordpy.egg-info/PKG-INFO index e8ff6d8..ed54312 100644 --- a/boticordpy.egg-info/PKG-INFO +++ b/boticordpy.egg-info/PKG-INFO @@ -1,6 +1,6 @@ Metadata-Version: 2.1 Name: boticordpy -Version: 1.3.6 +Version: 1.3.7 Summary: Simple Python Module for boticord api Home-page: https://github.com/grey-cat-1908/boticordpy Author: KerdokuCat @@ -29,7 +29,8 @@ License-File: LICENSE.txt ### Примеры -Публикуем статистику нашего бота в Boticord. +#### Без Когов +Публикуем статистику при запуске бота. ```Python from discord.ext import commands @@ -49,4 +50,35 @@ async def on_ready(): bot.run("your-bot-token") ``` +#### С Когами + +Ког с автоматической публикацией статистики раз в 15 минут + команда для публикации статистики для владельца бота. + +```python +from discord.ext import commands + +from boticordpy import BoticordClient + + +class BoticordCog(commands.Cog): + def __init__(self, bot): + self.bot = bot + self.boticord = BoticordClient(self.bot, "your-boticord-token") + self.boticord.start_loop() + + @commands.command(name="boticord-update") + @commands.is_owner() + async def boticord_update(self, ctx): + """ + This commands can be used by owner to post stats to boticord + """ + stats = {"servers": len(self.bot.guilds), "shards": 0, "users": len(self.bot.users)} + await self.boticord.Bots.postStats(stats) + + +def setup(bot): + bot.add_cog(BoticordCog(bot)) + +``` + diff --git a/docs/conf.py b/docs/conf.py index 07ca79c..42e3888 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -22,7 +22,7 @@ copyright = '2021, Grey Cat' author = 'Grey Cat' # The full version, including alpha/beta/rc tags -release = '1.3.6' +release = '1.3.7' # -- General configuration --------------------------------------------------- diff --git a/docs/quickstart.rst b/docs/quickstart.rst index 14aec5c..47c806a 100644 --- a/docs/quickstart.rst +++ b/docs/quickstart.rst @@ -24,10 +24,12 @@ Or just clone the repo: https://github.com/grey-cat-1908/boticordpy -Post Bot Stats +Examples ------------------------- -Let's post our bot's stats to Boticord. +**Without Using Cogs System** + +Post bot stats when bot is ready. :: @@ -47,4 +49,36 @@ Let's post our bot's stats to Boticord. bot.run("your-bot-token") -.. \ No newline at end of file +.. + +**Using Cogs System** + +Cog with automatically stats post (every 15 minutes) + bot's owner command that can be used to post stats. + +:: + + from discord.ext import commands + + from boticordpy import BoticordClient + + + class BoticordCog(commands.Cog): + def __init__(self, bot): + self.bot = bot + self.boticord = BoticordClient(self.bot, "your-boticord-token") + self.boticord.start_loop() + + @commands.command(name="boticord-update") + @commands.is_owner() + async def boticord_update(self, ctx): + """ + This commands can be used by owner to post stats to boticord + """ + stats = {"servers": len(self.bot.guilds), "shards": 0, "users": len(self.bot.users)} + await self.boticord.Bots.postStats(stats) + + + def setup(bot): + bot.add_cog(BoticordCog(bot)) + +.. diff --git a/examples/example_cog.py b/examples/example_cog.py new file mode 100644 index 0000000..0836d0f --- /dev/null +++ b/examples/example_cog.py @@ -0,0 +1,23 @@ +from discord.ext import commands + +from boticordpy import BoticordClient + + +class BoticordCog(commands.Cog): + def __init__(self, bot): + self.bot = bot + self.boticord = BoticordClient(self.bot, "your-boticord-token") + self.boticord.start_loop() + + @commands.command(name="boticord-update") + @commands.is_owner() + async def boticord_update(self, ctx): + """ + This commands can be used by owner to post stats to boticord + """ + stats = {"servers": len(self.bot.guilds), "shards": 0, "users": len(self.bot.users)} + await self.boticord.Bots.postStats(stats) + + +def setup(bot): + bot.add_cog(BoticordCog(bot)) diff --git a/setup.py b/setup.py index fbc5c42..5a9f01a 100644 --- a/setup.py +++ b/setup.py @@ -12,7 +12,7 @@ README = (HERE / "README.md").read_text(encoding="utf8") setup( name="boticordpy", packages = ['boticordpy', 'boticordpy.modules'], - version="1.3.6", + version="1.3.7", description="Simple Python Module for boticord api", long_description=README, long_description_content_type="text/markdown",