fixed start after move
This commit is contained in:
@@ -1,5 +0,0 @@
|
||||
"""
|
||||
integral_lib
|
||||
~~~~~~~~~~~~~
|
||||
Some libs for the bot which help him
|
||||
"""
|
||||
@@ -1,5 +1,5 @@
|
||||
__version__ = '0.0.7'
|
||||
__title__ = "bot"
|
||||
__title__ = "src"
|
||||
__author__ = "baconborn"
|
||||
|
||||
from typing import NamedTuple, Literal
|
||||
@@ -11,7 +11,7 @@ from integral_lib.Logger import logger
|
||||
|
||||
class Admin(commands.Cog, name='Admin'):
|
||||
def __init__(self, bot: commands.Bot):
|
||||
self.bot = bot # a defining bot as global var in class
|
||||
self.bot = bot # a defining src as global var in class
|
||||
|
||||
@commands.Cog.listener() # this is a decorator for events/listeners
|
||||
async def on_ready(self):
|
||||
@@ -54,7 +54,7 @@ class Admin(commands.Cog, name='Admin'):
|
||||
async def on_member_join(self, member):
|
||||
await fill_bd(member.name, member.id, member.bot, member.nick, member.guild.id)
|
||||
|
||||
bot_role = read_json(member.guild.id, 'bot_role') # Get bot role
|
||||
bot_role = read_json(member.guild.id, 'bot_role') # Get src role
|
||||
guest_role = read_json(member.guild.id, 'guest_role') # Get guest role
|
||||
|
||||
if bot_role or guest_role:
|
||||
@@ -67,7 +67,7 @@ class Admin(commands.Cog, name='Admin'):
|
||||
|
||||
@commands.slash_command(
|
||||
name="set_default_role",
|
||||
description=Localized("Set Default bot role", key="DEF_ROLE"),
|
||||
description=Localized("Set Default src role", key="DEF_ROLE"),
|
||||
options=[
|
||||
Option("role",
|
||||
"Specify role",
|
||||
@@ -78,7 +78,7 @@ class Admin(commands.Cog, name='Admin'):
|
||||
@commands.has_permissions(administrator=True)
|
||||
async def set_guest_role(self, inter: disnake.ApplicationCommandInteraction, role):
|
||||
await write_json(inter.guild.id, "guest_role", role.id)
|
||||
await inter.response.send_message(f"Set up bot role to: `{role.name}`", ephemeral=True)
|
||||
await inter.response.send_message(f"Set up src role to: `{role.name}`", ephemeral=True)
|
||||
|
||||
@commands.command(name="set_prefix")
|
||||
@commands.has_permissions(administrator=True)
|
||||
@@ -89,7 +89,7 @@ class Admin(commands.Cog, name='Admin'):
|
||||
@commands.guild_only()
|
||||
@commands.slash_command(
|
||||
name="set_prefix",
|
||||
description="Setting up bot prefix",
|
||||
description="Setting up src prefix",
|
||||
options=[
|
||||
Option("prefix",
|
||||
"Specify prefix",
|
||||
@@ -106,7 +106,7 @@ class Admin(commands.Cog, name='Admin'):
|
||||
@commands.has_permissions(administrator=True)
|
||||
@commands.slash_command(
|
||||
name="set_trigger_role",
|
||||
description=Localized("Setting up role to trigger bot", key="KEY_ROLE"),
|
||||
description=Localized("Setting up role to trigger src", key="KEY_ROLE"),
|
||||
options=[
|
||||
Option("role",
|
||||
Localized("Specify role", key="SETUP_ROLE"),
|
||||
@@ -120,7 +120,7 @@ class Admin(commands.Cog, name='Admin'):
|
||||
|
||||
@commands.slash_command(
|
||||
name="set_bot_role",
|
||||
description=Localized("Set bot role", key="BOT_ROLE"),
|
||||
description=Localized("Set src role", key="BOT_ROLE"),
|
||||
options=[
|
||||
Option("role",
|
||||
Localized("Specify role", key="SETUP_ROLE"),
|
||||
@@ -134,7 +134,7 @@ class Admin(commands.Cog, name='Admin'):
|
||||
await write_json(ctx.guild.id,
|
||||
"bot_role",
|
||||
role.id)
|
||||
await ctx.send(f"Set up bot role to: `{role.name}`", ephemeral=True)
|
||||
await ctx.send(f"Set up src role to: `{role.name}`", ephemeral=True)
|
||||
|
||||
@set_bot_role.error
|
||||
@set_trigger_role.error
|
||||
@@ -27,7 +27,7 @@ class Audio(commands.Cog, name='Audio'):
|
||||
logger.info('Skip playing by Game')
|
||||
else:
|
||||
# Prepare list of audio
|
||||
from bot.integral_lib.Comands import read_json
|
||||
from src.integral_lib.Comands import read_json
|
||||
_role = await read_json(member.guild.id, 'tigger_role')
|
||||
audio: list = []
|
||||
for _a in ListGenerator('audio'):
|
||||
@@ -10,7 +10,7 @@ from integral_lib.Logger import logger
|
||||
|
||||
class Fun(commands.Cog, name='Fun'):
|
||||
def __init__(self, bot: commands.Bot):
|
||||
self.bot = bot # defining bot as global var in class
|
||||
self.bot = bot # defining src as global var in class
|
||||
|
||||
@commands.Cog.listener() # this is a decorator for events/listeners
|
||||
async def on_ready(self):
|
||||
@@ -19,7 +19,7 @@ class Fun(commands.Cog, name='Fun'):
|
||||
@commands.has_permissions(administrator=True)
|
||||
@commands.slash_command(
|
||||
name="set_bot_channel",
|
||||
description="Set channel which iterate with bot",
|
||||
description="Set channel which iterate with src",
|
||||
|
||||
)
|
||||
async def set_bot_channel(self, inter: disnake.ApplicationCommandInteraction, channel: str):
|
||||
@@ -8,7 +8,7 @@ from integral_lib.Logger import logger
|
||||
|
||||
class Testing(commands.Cog, name='Testing'):
|
||||
def __init__(self, bot: commands.Bot):
|
||||
self.bot = bot # defining bot as global var in class
|
||||
self.bot = bot # defining src as global var in class
|
||||
|
||||
@commands.Cog.listener() # this is a decorator for events/listeners
|
||||
async def on_ready(self):
|
||||
@@ -7,7 +7,7 @@ from integral_lib.Logger import logger
|
||||
|
||||
class General(commands.Cog):
|
||||
def __init__(self, bot: commands.Bot):
|
||||
self.bot = bot # defining bot as global var in class
|
||||
self.bot = bot # defining src as global var in class
|
||||
|
||||
@commands.Cog.listener() # this is a decorator for events/listeners
|
||||
async def on_ready(self):
|
||||
@@ -12,20 +12,20 @@ from integral_lib.Logger import logger
|
||||
|
||||
class BotInfo(commands.Cog, name='Bot Info'):
|
||||
def __init__(self, bot: commands.Bot):
|
||||
self.bot = bot # defining bot as global var in class
|
||||
self.bot = bot # defining src as global var in class
|
||||
|
||||
@commands.Cog.listener() # this is a decorator for events/listeners
|
||||
async def on_ready(self):
|
||||
logger.info(f'Cog {__name__.split(".")[1]} is ready!.')
|
||||
|
||||
@commands.slash_command(name="info_bot",
|
||||
description='Shows general info about bot') # this is for making a command
|
||||
description='Shows general info about src') # this is for making a command
|
||||
async def info_bot(self, inter: ApplicationCommandInteraction):
|
||||
_pid = os.getpid()
|
||||
_process = psutil.Process(_pid)
|
||||
emb = disnake.Embed(
|
||||
title="General information",
|
||||
description="General information on about bot",
|
||||
description="General information on about src",
|
||||
)
|
||||
emb.set_thumbnail(self.bot.user.avatar.url)
|
||||
emb.add_field(name="System info:", value=f"Memory Usage: {round(_process.memory_info().rss / 2 ** 20, 2)} Mb\n"
|
||||
@@ -38,7 +38,7 @@ def work_with_cogs(what_do: str,
|
||||
Perform the specified action on the given cog or list of cogs.
|
||||
Args:
|
||||
what_do (str): The action to perform (load, unload, reload, disable, enable).
|
||||
bot (InteractionBotBase): The bot instance to work with.
|
||||
src (InteractionBotBase): The src instance to work with.
|
||||
cog (str | list): The name of the cog or a list of cogs to work with.
|
||||
Raises:
|
||||
ValueError: If the action is not recognized.
|
||||
@@ -66,7 +66,7 @@ async def write_json(guild: int, param_name: str, param: str or int):
|
||||
|
||||
def determine_prefix(bot: commands.Bot, msg):
|
||||
"""
|
||||
Determine the per-server bot prefix based on the given message object.
|
||||
Determine the per-server src prefix based on the given message object.
|
||||
|
||||
:param bot: Disnake Bot object
|
||||
:param msg: Disnake msg object
|
||||
5
src/integral_lib/__init__.py
Normal file
5
src/integral_lib/__init__.py
Normal file
@@ -0,0 +1,5 @@
|
||||
"""
|
||||
integral_lib
|
||||
~~~~~~~~~~~~~
|
||||
Some libs for the src which help him
|
||||
"""
|
||||
@@ -1,14 +1,17 @@
|
||||
import sys
|
||||
|
||||
import pytest
|
||||
from disnake.ext.commands.common_bot_base import CommonBotBase
|
||||
from mock import mock
|
||||
|
||||
from integral_lib.CogsPrep import cog_list, work_with_cogs
|
||||
sys.path.append('src')
|
||||
from integral_lib import CogsPrep
|
||||
|
||||
|
||||
def test_cog_list():
|
||||
with mock.patch('integral_lib.CogsPrep.listdir') as MockClass:
|
||||
MockClass.return_value = ['cog1.py', 'cog2.py']
|
||||
result = cog_list()
|
||||
result = CogsPrep.cog_list()
|
||||
assert result == ['cog1', 'cog2']
|
||||
|
||||
|
||||
@@ -18,7 +21,7 @@ def test_work_with_cogs(what_do, cog):
|
||||
with mock.patch('integral_lib.CogsPrep.rename') as mock_rename:
|
||||
mock_rename.return_value = None
|
||||
mock_bot = mock.MagicMock(spec=CommonBotBase)
|
||||
result = work_with_cogs(what_do, mock_bot, cog)
|
||||
result = CogsPrep.work_with_cogs(what_do, mock_bot, cog)
|
||||
if what_do in ['load', 'enable']:
|
||||
assert mock_bot.load_extension.called
|
||||
elif what_do in ['unload', 'disable']:
|
||||
|
||||
Reference in New Issue
Block a user