Added cpl-discord project

This commit is contained in:
2022-07-16 12:12:52 +02:00
parent 2ab1576230
commit a79358725c
11 changed files with 133 additions and 6 deletions

View File

@@ -0,0 +1 @@
# imports

View File

View File

@@ -0,0 +1,11 @@
from abc import ABC, abstractmethod
from discord.ext import commands
from commands_meta import CommandsMeta
class CommandABC(ABC, commands.Cog, metaclass=CommandsMeta):
@abstractmethod
def __init__(self): pass

View File

@@ -0,0 +1,5 @@
from abc import ABCMeta
from discord.ext import commands
class CommandsMeta(ABCMeta, commands.CogMeta): pass

View File

@@ -0,0 +1 @@
# imports

View File

@@ -0,0 +1,29 @@
import traceback
from cpl_core.configuration.configuration_model_abc import ConfigurationModelABC
from cpl_core.console import Console
class BotSettings(ConfigurationModelABC):
def __init__(self):
ConfigurationModelABC.__init__(self)
self._token = ''
self._prefix = ''
@property
def token(self) -> str:
return self._token
@property
def prefix(self) -> str:
return self._prefix
def from_dict(self, settings: dict):
try:
self._token = settings['Token']
self._prefix = settings['Prefix']
except Exception as e:
Console.error(f'[ ERROR ] [ {__name__} ]: Reading error in {__name__} settings')
Console.error(f'[ EXCEPTION ] [ {__name__} ]: {e} -> {traceback.format_exc()}')

View File

@@ -0,0 +1,48 @@
{
"ProjectSettings": {
"Name": "cpl-discord",
"Version": {
"Major": "2022",
"Minor": "7",
"Micro": "0"
},
"Author": "Sven Heidemann",
"AuthorEmail": "sven.heidemann@sh-edraft.de",
"Description": "sh-edraft Common Python library Discord",
"LongDescription": "sh-edraft Common Python library link between discord.py and CPL",
"URL": "https://www.sh-edraft.de",
"CopyrightDate": "2021 - 2022",
"CopyrightName": "sh-edraft.de",
"LicenseName": "MIT",
"LicenseDescription": "MIT, see LICENSE for more details.",
"Dependencies": [
"cpl-core>=2022.7.0",
"discord.py==1.7.3",
"cpl-query==2022.6.0"
],
"DevDependencies": [
"cpl-cli>=2022.7.0"
],
"PythonVersion": ">=3.10.4",
"PythonPath": {
"linux": ""
},
"Classifiers": []
},
"BuildSettings": {
"ProjectType": "library",
"SourcePath": "",
"OutputPath": "../../dist",
"Main": "cpl_discord.main",
"EntryPoint": "cpl-discord",
"IncludePackageData": false,
"Included": [],
"Excluded": [
"*/__pycache__",
"*/logs",
"*/tests"
],
"PackageData": {},
"ProjectReferences": []
}
}

View File

View File

View File

@@ -0,0 +1,16 @@
from abc import ABC, abstractmethod
import discord
from discord.ext import commands
class BotServiceABC(ABC, commands.Bot):
def __init__(self):
ABC.__init__(self)
@abstractmethod
async def start_async(self): pass
@abstractmethod
async def stop_async(self): pass