Compare commits
77 Commits
ee503f76f2
...
1.0.2
| Author | SHA1 | Date | |
|---|---|---|---|
| 91034cee09 | |||
| a4d3cffa93 | |||
| 809c6d4cb9 | |||
| 2fecbf2c31 | |||
| c439d5925f | |||
| 1777a32899 | |||
| 3e5301b2d8 | |||
| 653562b908 | |||
| 8025c31339 | |||
| ccf41bec79 | |||
| f75d8f2068 | |||
| da02aca7e4 | |||
| 3762f16c7e | |||
| b3099121ab | |||
| 6a750ee31b | |||
| 3c371ec074 | |||
| d818eafb9d | |||
| b4a5fdb258 | |||
| cf69436168 | |||
| ccf171e876 | |||
| 5a312bf660 | |||
| 0003255d7c | |||
| 27a4c140e4 | |||
| 3183461195 | |||
| cb4f8d870c | |||
| 7c447bb0f2 | |||
| 4debe4e2ba | |||
| 3cd3df3e5f | |||
| b4a631d4e4 | |||
| 7ba0247519 | |||
| 209e75fdcc | |||
| 3bca3f86eb | |||
| 657a8fa586 | |||
| 3c8a092f40 | |||
| 61bf508cea | |||
| 75ad07477a | |||
| 132d41f0a2 | |||
| 707a835672 | |||
| f56dbf8e2a | |||
| c311e534d7 | |||
| 87b277515c | |||
| e6c614dfdc | |||
| 24d5bbf4d8 | |||
| 52035af0cc | |||
| fdc9a118c8 | |||
| ba1f4ee955 | |||
| 35d161c080 | |||
| 818163cbed | |||
| 468ebb5f79 | |||
| 085726bf60 | |||
| 223abbe66f | |||
| 4c5a8baed5 | |||
| 59162408e5 | |||
| 634b81d23b | |||
| c0cd5bb70e | |||
| cc0a0a5c69 | |||
| 4420c0e11c | |||
| 7be40ed236 | |||
| ff415c354d | |||
| 283eaabef6 | |||
| b7e72888f7 | |||
| b29227e8d5 | |||
| 9f57182fc1 | |||
| 699377be54 | |||
| efba1a4ce8 | |||
| 68fa1b8c2d | |||
| 8b79d69e41 | |||
| c1b75dff78 | |||
| 5f284597aa | |||
| e1b1a68b07 | |||
| b1a0115e8b | |||
| ad00dce5d9 | |||
| e3c47ce5b1 | |||
| 68026e4b47 | |||
| e1c89814da | |||
| 53cdaf3fa0 | |||
| b11ce18ac9 |
@@ -14,6 +14,7 @@
|
||||
"level": "src/modules/level/level.json",
|
||||
"permission": "src/modules/permission/permission.json",
|
||||
"technician": "src/modules/technician/technician.json",
|
||||
"checks": "tools/checks/checks.json",
|
||||
"get-version": "tools/get_version/get-version.json",
|
||||
"post-build": "tools/post_build/post-build.json",
|
||||
"set-version": "tools/set_version/set-version.json"
|
||||
|
||||
Submodule kdb-bot/docker updated: 22b8bce69b...62475d6546
@@ -15,4 +15,7 @@ RUN apk add nano
|
||||
RUN pip install -r requirements.txt --extra-index-url https://pip.sh-edraft.de
|
||||
RUN pip install flask[async]
|
||||
|
||||
# RUN pip install dnspython==2.2.1 # https://stackoverflow.com/questions/75137717/eventlet-dns-python-attribute-error-module-dns-rdtypes-has-no-attribute-any
|
||||
# ^ probably fixed py package updates
|
||||
|
||||
CMD [ "bash", "/app/bot/bot"]
|
||||
|
||||
@@ -15,7 +15,7 @@ __title__ = "bot"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.0.0rc1"
|
||||
__version__ = "1.0.2"
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
@@ -23,4 +23,4 @@ from collections import namedtuple
|
||||
# imports:
|
||||
|
||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||
version_info = VersionInfo(major="1", minor="0", micro="0.rc1")
|
||||
version_info = VersionInfo(major="1", minor="0", micro="2")
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
"Version": {
|
||||
"Major": "1",
|
||||
"Minor": "0",
|
||||
"Micro": "0.rc1"
|
||||
"Micro": "2"
|
||||
},
|
||||
"Author": "Sven Heidemann",
|
||||
"AuthorEmail": "sven.heidemann@sh-edraft.de",
|
||||
@@ -19,6 +19,7 @@
|
||||
"cpl-core==2022.12.1.post3",
|
||||
"cpl-translation==2022.12.1",
|
||||
"cpl-query==2022.12.2.post2",
|
||||
"cpl-discord==2022.12.2.post1",
|
||||
"Flask==2.2.2",
|
||||
"Flask-Classful==0.14.2",
|
||||
"Flask-Cors==3.0.10",
|
||||
@@ -28,8 +29,7 @@
|
||||
"eventlet==0.33.3",
|
||||
"requests-oauthlib==1.3.1",
|
||||
"icmplib==3.0.3",
|
||||
"ariadne==0.17.1",
|
||||
"cpl-discord==2022.12.2"
|
||||
"ariadne==0.17.1"
|
||||
],
|
||||
"DevDependencies": [
|
||||
"cpl-cli==2022.12.1.post3",
|
||||
|
||||
Submodule kdb-bot/src/bot/config updated: 781aa3f6ab...0c94637537
@@ -15,7 +15,7 @@ __title__ = "bot.extension"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.0.0rc1"
|
||||
__version__ = "1.0.2"
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
@@ -23,4 +23,4 @@ from collections import namedtuple
|
||||
# imports:
|
||||
|
||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||
version_info = VersionInfo(major="1", minor="0", micro="0.rc1")
|
||||
version_info = VersionInfo(major="1", minor="0", micro="2")
|
||||
|
||||
@@ -86,10 +86,10 @@
|
||||
"no_permission_message": "Nein!\nIch höre nicht auf dich ¯\\_(ツ)_/¯",
|
||||
"not_implemented_yet": "Ey Alter, das kann ich noch nicht...",
|
||||
"presence": {
|
||||
"booting": "{} Ich fahre gerade hoch...",
|
||||
"restart": "{} Muss neue Kekse holen...",
|
||||
"running": "{} Ich esse Kekse :D",
|
||||
"shutdown": "{} Ich werde bestimmt wieder kommen..."
|
||||
"booting": "Ich fahre gerade hoch...",
|
||||
"restart": "Muss neue Kekse holen...",
|
||||
"running": "Ich esse Kekse :D",
|
||||
"shutdown": "Ich werde bestimmt wieder kommen..."
|
||||
}
|
||||
},
|
||||
"modules": {
|
||||
|
||||
@@ -15,7 +15,7 @@ __title__ = "bot_api"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.0.0rc1"
|
||||
__version__ = "1.0.2"
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
@@ -23,4 +23,4 @@ from collections import namedtuple
|
||||
# imports:
|
||||
|
||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||
version_info = VersionInfo(major="1", minor="0", micro="0.rc1")
|
||||
version_info = VersionInfo(major="1", minor="0", micro="2")
|
||||
|
||||
@@ -15,7 +15,7 @@ __title__ = "bot_api.abc"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.0.0rc1"
|
||||
__version__ = "1.0.2"
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
@@ -23,4 +23,4 @@ from collections import namedtuple
|
||||
# imports:
|
||||
|
||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||
version_info = VersionInfo(major="1", minor="0", micro="0.rc1")
|
||||
version_info = VersionInfo(major="1", minor="0", micro="2")
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
"Version": {
|
||||
"Major": "1",
|
||||
"Minor": "0",
|
||||
"Micro": "0.rc1"
|
||||
"Micro": "2"
|
||||
},
|
||||
"Author": "",
|
||||
"AuthorEmail": "",
|
||||
|
||||
@@ -15,7 +15,7 @@ __title__ = "bot_api.configuration"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.0.0rc1"
|
||||
__version__ = "1.0.2"
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
@@ -23,4 +23,4 @@ from collections import namedtuple
|
||||
# imports
|
||||
|
||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||
version_info = VersionInfo(major="1", minor="0", micro="0.rc1")
|
||||
version_info = VersionInfo(major="1", minor="0", micro="2")
|
||||
|
||||
@@ -15,7 +15,7 @@ __title__ = "bot_api.controller"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.0.0rc1"
|
||||
__version__ = "1.0.2"
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
@@ -23,4 +23,4 @@ from collections import namedtuple
|
||||
# imports:
|
||||
|
||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||
version_info = VersionInfo(major="1", minor="0", micro="0.rc1")
|
||||
version_info = VersionInfo(major="1", minor="0", micro="2")
|
||||
|
||||
@@ -129,7 +129,6 @@ class AuthController:
|
||||
return "", 200
|
||||
|
||||
@Route.post(f"{BasePath}/refresh")
|
||||
@Route.authorize
|
||||
async def refresh(self) -> Response:
|
||||
dto: TokenDTO = JSONProcessor.process(TokenDTO, request.get_json(force=True, silent=True))
|
||||
result = await self._auth_service.refresh_async(dto)
|
||||
|
||||
@@ -15,7 +15,7 @@ __title__ = "bot_api.event"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.0.0rc1"
|
||||
__version__ = "1.0.2"
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
@@ -23,4 +23,4 @@ from collections import namedtuple
|
||||
# imports:
|
||||
|
||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||
version_info = VersionInfo(major="1", minor="0", micro="0.rc1")
|
||||
version_info = VersionInfo(major="1", minor="0", micro="2")
|
||||
|
||||
@@ -15,7 +15,7 @@ __title__ = "bot_api.exception"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.0.0rc1"
|
||||
__version__ = "1.0.2"
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
@@ -23,4 +23,4 @@ from collections import namedtuple
|
||||
# imports:
|
||||
|
||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||
version_info = VersionInfo(major="1", minor="0", micro="0.rc1")
|
||||
version_info = VersionInfo(major="1", minor="0", micro="2")
|
||||
|
||||
@@ -15,7 +15,7 @@ __title__ = "bot_api.filter"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.0.0rc1"
|
||||
__version__ = "1.0.2"
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
@@ -23,4 +23,4 @@ from collections import namedtuple
|
||||
# imports:
|
||||
|
||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||
version_info = VersionInfo(major="1", minor="0", micro="0.rc1")
|
||||
version_info = VersionInfo(major="1", minor="0", micro="2")
|
||||
|
||||
@@ -15,7 +15,7 @@ __title__ = "bot_api.filter.discord"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.0.0rc1"
|
||||
__version__ = "1.0.2"
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
@@ -23,4 +23,4 @@ from collections import namedtuple
|
||||
# imports:
|
||||
|
||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||
version_info = VersionInfo(major="1", minor="0", micro="0.rc1")
|
||||
version_info = VersionInfo(major="1", minor="0", micro="2")
|
||||
|
||||
@@ -15,7 +15,7 @@ __title__ = "bot_api.logging"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.0.0rc1"
|
||||
__version__ = "1.0.2"
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
@@ -23,4 +23,4 @@ from collections import namedtuple
|
||||
# imports:
|
||||
|
||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||
version_info = VersionInfo(major="1", minor="0", micro="0.rc1")
|
||||
version_info = VersionInfo(major="1", minor="0", micro="2")
|
||||
|
||||
@@ -15,7 +15,7 @@ __title__ = "bot_api.model"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.0.0rc1"
|
||||
__version__ = "1.0.2"
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
@@ -23,4 +23,4 @@ from collections import namedtuple
|
||||
# imports:
|
||||
|
||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||
version_info = VersionInfo(major="1", minor="0", micro="0.rc1")
|
||||
version_info = VersionInfo(major="1", minor="0", micro="2")
|
||||
|
||||
@@ -15,7 +15,7 @@ __title__ = "bot_api.model.discord"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.0.0rc1"
|
||||
__version__ = "1.0.2"
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
@@ -23,4 +23,4 @@ from collections import namedtuple
|
||||
# imports:
|
||||
|
||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||
version_info = VersionInfo(major="1", minor="0", micro="0.rc1")
|
||||
version_info = VersionInfo(major="1", minor="0", micro="2")
|
||||
|
||||
@@ -15,7 +15,7 @@ __title__ = "bot_api.route"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.0.0rc1"
|
||||
__version__ = "1.0.2"
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
@@ -23,4 +23,4 @@ from collections import namedtuple
|
||||
# imports:
|
||||
|
||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||
version_info = VersionInfo(major="1", minor="0", micro="0.rc1")
|
||||
version_info = VersionInfo(major="1", minor="0", micro="2")
|
||||
|
||||
@@ -15,7 +15,7 @@ __title__ = "bot_api.service"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.0.0rc1"
|
||||
__version__ = "1.0.2"
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
@@ -23,4 +23,4 @@ from collections import namedtuple
|
||||
# imports
|
||||
|
||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||
version_info = VersionInfo(major="1", minor="0", micro="0.rc1")
|
||||
version_info = VersionInfo(major="1", minor="0", micro="2")
|
||||
|
||||
@@ -483,18 +483,19 @@ class AuthService(AuthServiceABC):
|
||||
if user_dto is None:
|
||||
raise ServiceException(ServiceErrorCode.InvalidData, "User not set")
|
||||
|
||||
members = self._users.get_users_by_discord_id(dc_id)
|
||||
if members.count() == 0:
|
||||
raise ServiceException(ServiceErrorCode.InvalidUser, f"Member not found")
|
||||
|
||||
added_user = False
|
||||
db_user = self._auth_users.find_auth_user_by_email(user_dto.email)
|
||||
if db_user is None:
|
||||
self.add_auth_user(user_dto)
|
||||
added_user = True
|
||||
# raise ServiceException(ServiceErrorCode.InvalidUser, f'User not found')
|
||||
|
||||
db_user = self._auth_users.get_auth_user_by_email(user_dto.email)
|
||||
if db_user.users.count() == 0:
|
||||
self._users.get_users_by_discord_id(dc_id).for_each(
|
||||
lambda x: self._auth_users.add_auth_user_user_rel(AuthUserUsersRelation(db_user, x))
|
||||
)
|
||||
members.for_each(lambda x: self._auth_users.add_auth_user_user_rel(AuthUserUsersRelation(db_user, x)))
|
||||
|
||||
if db_user.confirmation_id is not None and not added_user:
|
||||
raise ServiceException(ServiceErrorCode.Forbidden, "E-Mail not verified")
|
||||
|
||||
@@ -15,7 +15,7 @@ __title__ = "bot_api.transformer"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.0.0rc1"
|
||||
__version__ = "1.0.2"
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
@@ -23,4 +23,4 @@ from collections import namedtuple
|
||||
# imports:
|
||||
|
||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||
version_info = VersionInfo(major="1", minor="0", micro="0.rc1")
|
||||
version_info = VersionInfo(major="1", minor="0", micro="2")
|
||||
|
||||
@@ -15,7 +15,7 @@ __title__ = "bot_core"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.0.0rc1"
|
||||
__version__ = "1.0.2"
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
@@ -23,4 +23,4 @@ from collections import namedtuple
|
||||
# imports
|
||||
|
||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||
version_info = VersionInfo(major="1", minor="0", micro="0.rc1")
|
||||
version_info = VersionInfo(major="1", minor="0", micro="2")
|
||||
|
||||
@@ -15,7 +15,7 @@ __title__ = "bot_core.abc"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.0.0rc1"
|
||||
__version__ = "1.0.2"
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
@@ -23,4 +23,4 @@ from collections import namedtuple
|
||||
# imports:
|
||||
|
||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||
version_info = VersionInfo(major="1", minor="0", micro="0.rc1")
|
||||
version_info = VersionInfo(major="1", minor="0", micro="2")
|
||||
|
||||
@@ -2,9 +2,11 @@ from abc import ABC, abstractmethod
|
||||
from datetime import datetime
|
||||
from typing import Callable
|
||||
|
||||
import discord
|
||||
from cpl_query.extension import List
|
||||
from discord.ext.commands import Context
|
||||
|
||||
from bot_data.model.auto_role_rule import AutoRoleRule
|
||||
from bot_data.model.user import User
|
||||
from modules.base.configuration.base_server_settings import BaseServerSettings
|
||||
|
||||
@@ -59,3 +61,9 @@ class ClientUtilsABC(ABC):
|
||||
@abstractmethod
|
||||
def get_ontime_for_user(self, user: User) -> float:
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
async def react_to_message_by_auto_role_rule(
|
||||
self, discord_channel_id: int, discord_message_id: int, rule: AutoRoleRule, guild: discord.Guild
|
||||
):
|
||||
pass
|
||||
|
||||
@@ -25,7 +25,9 @@ class MessageServiceABC(ABC):
|
||||
self,
|
||||
channel: discord.TextChannel,
|
||||
message: Union[str, discord.Embed],
|
||||
without_tracking=True,
|
||||
is_persistent: bool = False,
|
||||
wait_before_delete: int = None,
|
||||
without_tracking=False,
|
||||
):
|
||||
pass
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
"Version": {
|
||||
"Major": "1",
|
||||
"Minor": "0",
|
||||
"Micro": "0.rc1"
|
||||
"Micro": "2"
|
||||
},
|
||||
"Author": "Sven Heidemann",
|
||||
"AuthorEmail": "sven.heidemann@sh-edraft.de",
|
||||
|
||||
@@ -15,7 +15,7 @@ __title__ = "bot_core.configuration"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.0.0rc1"
|
||||
__version__ = "1.0.2"
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
@@ -23,4 +23,4 @@ from collections import namedtuple
|
||||
# imports:
|
||||
|
||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||
version_info = VersionInfo(major="1", minor="0", micro="0.rc1")
|
||||
version_info = VersionInfo(major="1", minor="0", micro="2")
|
||||
|
||||
@@ -10,11 +10,12 @@ class FeatureFlagsEnum(Enum):
|
||||
boot_log_module = "BootLogModule"
|
||||
core_module = "CoreModule"
|
||||
core_extension_module = "CoreExtensionModule"
|
||||
data_module = ("DataModule",)
|
||||
database_module = ("DatabaseModule",)
|
||||
data_module = "DataModule"
|
||||
database_module = "DatabaseModule"
|
||||
level_module = "LevelModule"
|
||||
moderator_module = "ModeratorModule"
|
||||
permission_module = "PermissionModule"
|
||||
# features
|
||||
api_only = "ApiOnly"
|
||||
presence = "Presence"
|
||||
version_in_presence = "VersionInPresence"
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import traceback
|
||||
from typing import Optional, Callable
|
||||
|
||||
from cpl_core.configuration.configuration_model_abc import ConfigurationModelABC
|
||||
from cpl_core.console import Console
|
||||
@@ -27,6 +26,7 @@ class FeatureFlagsSettings(ConfigurationModelABC):
|
||||
# features
|
||||
FeatureFlagsEnum.api_only.value: False, # 13.10.2022 #70
|
||||
FeatureFlagsEnum.presence.value: True, # 03.10.2022 #56
|
||||
FeatureFlagsEnum.version_in_presence.value: False, # 21.03.2023 #253
|
||||
}
|
||||
|
||||
def get_flag(self, key: FeatureFlagsEnum) -> bool:
|
||||
|
||||
@@ -15,7 +15,7 @@ __title__ = "bot_core.core_extension"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.0.0rc1"
|
||||
__version__ = "1.0.2"
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
@@ -23,4 +23,4 @@ from collections import namedtuple
|
||||
# imports:
|
||||
|
||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||
version_info = VersionInfo(major="1", minor="0", micro="0.rc1")
|
||||
version_info = VersionInfo(major="1", minor="0", micro="2")
|
||||
|
||||
@@ -15,7 +15,7 @@ __title__ = "bot_core.events"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.0.0rc1"
|
||||
__version__ = "1.0.2"
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
@@ -23,4 +23,4 @@ from collections import namedtuple
|
||||
# imports:
|
||||
|
||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||
version_info = VersionInfo(major="1", minor="0", micro="0.rc1")
|
||||
version_info = VersionInfo(major="1", minor="0", micro="2")
|
||||
|
||||
@@ -15,7 +15,7 @@ __title__ = "bot_core.exception"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.0.0rc1"
|
||||
__version__ = "1.0.2"
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
@@ -23,4 +23,4 @@ from collections import namedtuple
|
||||
# imports:
|
||||
|
||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||
version_info = VersionInfo(major="1", minor="0", micro="0.rc1")
|
||||
version_info = VersionInfo(major="1", minor="0", micro="2")
|
||||
|
||||
@@ -15,7 +15,7 @@ __title__ = "bot_core.helper"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.0.0rc1"
|
||||
__version__ = "1.0.2"
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
@@ -23,4 +23,4 @@ from collections import namedtuple
|
||||
# imports:
|
||||
|
||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||
version_info = VersionInfo(major="1", minor="0", micro="0.rc1")
|
||||
version_info = VersionInfo(major="1", minor="0", micro="2")
|
||||
|
||||
@@ -15,7 +15,7 @@ __title__ = "bot_core.logging"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.0.0rc1"
|
||||
__version__ = "1.0.2"
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
@@ -23,4 +23,4 @@ from collections import namedtuple
|
||||
# imports
|
||||
|
||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||
version_info = VersionInfo(major="1", minor="0", micro="0.rc1")
|
||||
version_info = VersionInfo(major="1", minor="0", micro="2")
|
||||
|
||||
@@ -15,7 +15,7 @@ __title__ = "bot_core.pipes"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.0.0rc1"
|
||||
__version__ = "1.0.2"
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
@@ -23,4 +23,4 @@ from collections import namedtuple
|
||||
# imports
|
||||
|
||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||
version_info = VersionInfo(major="1", minor="0", micro="0.rc1")
|
||||
version_info = VersionInfo(major="1", minor="0", micro="2")
|
||||
|
||||
@@ -15,7 +15,7 @@ __title__ = "bot_core.service"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.0.0rc1"
|
||||
__version__ = "1.0.2"
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
@@ -23,4 +23,4 @@ from collections import namedtuple
|
||||
# imports:
|
||||
|
||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||
version_info = VersionInfo(major="1", minor="0", micro="0.rc1")
|
||||
version_info = VersionInfo(major="1", minor="0", micro="2")
|
||||
|
||||
@@ -9,6 +9,7 @@ from cpl_core.time import TimeFormatSettings
|
||||
from cpl_discord.service import DiscordBotServiceABC
|
||||
from cpl_query.extension import List
|
||||
from cpl_translation import TranslatePipe
|
||||
from discord import Guild
|
||||
from discord.ext.commands import Context
|
||||
|
||||
from bot_core.abc.client_utils_abc import ClientUtilsABC
|
||||
@@ -23,6 +24,7 @@ from bot_data.abc.user_joined_voice_channel_repository_abc import (
|
||||
from bot_data.abc.user_message_count_per_hour_repository_abc import (
|
||||
UserMessageCountPerHourRepositoryABC,
|
||||
)
|
||||
from bot_data.model.auto_role_rule import AutoRoleRule
|
||||
from bot_data.model.user import User
|
||||
from bot_data.model.user_message_count_per_hour import UserMessageCountPerHour
|
||||
from modules.base.configuration.base_server_settings import BaseServerSettings
|
||||
@@ -111,7 +113,11 @@ class ClientUtilsService(ClientUtilsABC):
|
||||
|
||||
import bot
|
||||
|
||||
name = self._t.transform(t_key).format(bot.__version__)
|
||||
if self._feature_flags.get_flag(FeatureFlagsEnum.version_in_presence):
|
||||
name = f"{bot.__version__} {self._t.transform(t_key)}"
|
||||
else:
|
||||
name = self._t.transform(t_key)
|
||||
|
||||
await self._bot.change_presence(activity=discord.Game(name=name))
|
||||
self._logger.info(__name__, f"Set presence {name}")
|
||||
|
||||
@@ -188,3 +194,27 @@ class ClientUtilsService(ClientUtilsABC):
|
||||
.sum(lambda join: (join.leaved_on - join.joined_on).total_seconds() / 3600),
|
||||
2,
|
||||
)
|
||||
|
||||
async def react_to_message_by_auto_role_rule(
|
||||
self, discord_channel_id: int, discord_message_id: int, rule: AutoRoleRule, guild: discord.Guild
|
||||
):
|
||||
try:
|
||||
guild: Guild = self._bot.guilds.where(lambda g: g == guild).single()
|
||||
channel = guild.get_channel(discord_channel_id)
|
||||
message = await channel.fetch_message(discord_message_id)
|
||||
emoji = List(discord.Emoji, guild.emojis).where(lambda x: x.name == rule.emoji_name).single()
|
||||
|
||||
if emoji is None:
|
||||
self._logger.debug(__name__, f"Emoji {rule.emoji_name} not found")
|
||||
return
|
||||
await message.add_reaction(emoji)
|
||||
self._logger.debug(
|
||||
__name__,
|
||||
f"Added reaction {rule.emoji_name} to message: {discord_message_id}",
|
||||
)
|
||||
except Exception as e:
|
||||
self._logger.error(
|
||||
__name__,
|
||||
f"Cannot add reaction {rule.emoji_name} to message: {discord_message_id}",
|
||||
e,
|
||||
)
|
||||
|
||||
@@ -15,7 +15,7 @@ __title__ = "bot_data"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.0.0rc1"
|
||||
__version__ = "1.0.2"
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
@@ -23,4 +23,4 @@ from collections import namedtuple
|
||||
# imports
|
||||
|
||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||
version_info = VersionInfo(major="1", minor="0", micro="0.rc1")
|
||||
version_info = VersionInfo(major="1", minor="0", micro="2")
|
||||
|
||||
@@ -15,7 +15,7 @@ __title__ = "bot_data.abc"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.0.0rc1"
|
||||
__version__ = "1.0.2"
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
@@ -23,4 +23,4 @@ from collections import namedtuple
|
||||
# imports
|
||||
|
||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||
version_info = VersionInfo(major="1", minor="0", micro="0.rc1")
|
||||
version_info = VersionInfo(major="1", minor="0", micro="2")
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
"Version": {
|
||||
"Major": "1",
|
||||
"Minor": "0",
|
||||
"Micro": "0.rc1"
|
||||
"Micro": "2"
|
||||
},
|
||||
"Author": "Sven Heidemann",
|
||||
"AuthorEmail": "sven.heidemann@sh-edraft.de",
|
||||
|
||||
@@ -27,6 +27,7 @@ from bot_data.abc.user_warnings_repository_abc import UserWarningsRepositoryABC
|
||||
from bot_data.service.api_key_repository_service import ApiKeyRepositoryService
|
||||
from bot_data.service.auth_user_repository_service import AuthUserRepositoryService
|
||||
from bot_data.service.auto_role_repository_service import AutoRoleRepositoryService
|
||||
from bot_data.service.cache_service import CacheService
|
||||
from bot_data.service.client_repository_service import ClientRepositoryService
|
||||
from bot_data.service.game_server_repository_service import GameServerRepositoryService
|
||||
from bot_data.service.known_user_repository_service import KnownUserRepositoryService
|
||||
@@ -56,6 +57,8 @@ class DataModule(ModuleABC):
|
||||
pass
|
||||
|
||||
def configure_services(self, services: ServiceCollectionABC, env: ApplicationEnvironmentABC):
|
||||
services.add_singleton(CacheService)
|
||||
|
||||
services.add_transient(ApiKeyRepositoryABC, ApiKeyRepositoryService)
|
||||
services.add_transient(AuthUserRepositoryABC, AuthUserRepositoryService)
|
||||
services.add_transient(ServerRepositoryABC, ServerRepositoryService)
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import time
|
||||
|
||||
from cpl_core.database import DatabaseSettings
|
||||
from cpl_core.database.context import DatabaseContext
|
||||
|
||||
@@ -31,4 +33,9 @@ class DBContext(DatabaseContext):
|
||||
return super(DBContext, self).select(statement)
|
||||
except Exception as e:
|
||||
self._logger.error(__name__, f"Database error caused by {statement}", e)
|
||||
try:
|
||||
time.sleep(0.5)
|
||||
return self.select(statement)
|
||||
except Exception as e:
|
||||
pass
|
||||
return []
|
||||
|
||||
@@ -15,7 +15,7 @@ __title__ = "bot_data.migration"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.0.0rc1"
|
||||
__version__ = "1.0.2"
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
@@ -23,4 +23,4 @@ from collections import namedtuple
|
||||
# imports
|
||||
|
||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||
version_info = VersionInfo(major="1", minor="0", micro="0.rc1")
|
||||
version_info = VersionInfo(major="1", minor="0", micro="2")
|
||||
|
||||
@@ -1,11 +1,8 @@
|
||||
ALTER TABLE `ApiKeys`
|
||||
MODIFY `LastModifiedAt` DATETIME(6) NULL ON UPDATE CURRENT_TIMESTAMP(6);
|
||||
CHANGE `CreatedAt` `CreatedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6);
|
||||
|
||||
ALTER TABLE `ApiKeys`
|
||||
ALTER COLUMN `CreatedAt` SET DEFAULT CURRENT_TIMESTAMP(6);
|
||||
|
||||
ALTER TABLE `ApiKeys`
|
||||
ALTER COLUMN `LastModifiedAt` SET DEFAULT CURRENT_TIMESTAMP(6);
|
||||
CHANGE `LastModifiedAt` `LastModifiedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `ApiKeysHistory`
|
||||
(
|
||||
|
||||
@@ -1,11 +1,8 @@
|
||||
ALTER TABLE `AuthUserUsersRelations`
|
||||
MODIFY `LastModifiedAt` DATETIME(6) NULL ON UPDATE CURRENT_TIMESTAMP(6);
|
||||
CHANGE `CreatedAt` `CreatedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6);
|
||||
|
||||
ALTER TABLE `AuthUserUsersRelations`
|
||||
ALTER COLUMN `CreatedAt` SET DEFAULT CURRENT_TIMESTAMP(6);
|
||||
|
||||
ALTER TABLE `AuthUserUsersRelations`
|
||||
ALTER COLUMN `LastModifiedAt` SET DEFAULT CURRENT_TIMESTAMP(6);
|
||||
CHANGE `LastModifiedAt` `LastModifiedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6);
|
||||
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `AuthUserUsersRelationsHistory`
|
||||
|
||||
@@ -1,11 +1,8 @@
|
||||
ALTER TABLE `AuthUsers`
|
||||
MODIFY `LastModifiedAt` DATETIME(6) NULL ON UPDATE CURRENT_TIMESTAMP(6);
|
||||
CHANGE `CreatedAt` `CreatedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6);
|
||||
|
||||
ALTER TABLE `AuthUsers`
|
||||
ALTER COLUMN `CreatedAt` SET DEFAULT CURRENT_TIMESTAMP(6);
|
||||
|
||||
ALTER TABLE `AuthUsers`
|
||||
ALTER COLUMN `LastModifiedAt` SET DEFAULT CURRENT_TIMESTAMP(6);
|
||||
CHANGE `LastModifiedAt` `LastModifiedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `AuthUsersHistory`
|
||||
(
|
||||
|
||||
@@ -1,11 +1,8 @@
|
||||
ALTER TABLE `AutoRoleRules`
|
||||
MODIFY `LastModifiedAt` DATETIME(6) NULL ON UPDATE CURRENT_TIMESTAMP(6);
|
||||
CHANGE `CreatedAt` `CreatedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6);
|
||||
|
||||
ALTER TABLE `AutoRoleRules`
|
||||
ALTER COLUMN `CreatedAt` SET DEFAULT CURRENT_TIMESTAMP(6);
|
||||
|
||||
ALTER TABLE `AutoRoleRules`
|
||||
ALTER COLUMN `LastModifiedAt` SET DEFAULT CURRENT_TIMESTAMP(6);
|
||||
CHANGE `LastModifiedAt` `LastModifiedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `AutoRoleRulesHistory`
|
||||
(
|
||||
|
||||
@@ -1,11 +1,8 @@
|
||||
ALTER TABLE `AutoRoles`
|
||||
MODIFY `LastModifiedAt` DATETIME(6) NULL ON UPDATE CURRENT_TIMESTAMP(6);
|
||||
CHANGE `CreatedAt` `CreatedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6);
|
||||
|
||||
ALTER TABLE `AutoRoles`
|
||||
ALTER COLUMN `CreatedAt` SET DEFAULT CURRENT_TIMESTAMP(6);
|
||||
|
||||
ALTER TABLE `AutoRoles`
|
||||
ALTER COLUMN `LastModifiedAt` SET DEFAULT CURRENT_TIMESTAMP(6);
|
||||
CHANGE `LastModifiedAt` `LastModifiedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `AutoRolesHistory`
|
||||
(
|
||||
|
||||
@@ -1,11 +1,8 @@
|
||||
ALTER TABLE `Clients`
|
||||
MODIFY `LastModifiedAt` DATETIME(6) NULL ON UPDATE CURRENT_TIMESTAMP(6);
|
||||
CHANGE `CreatedAt` `CreatedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6);
|
||||
|
||||
ALTER TABLE `Clients`
|
||||
ALTER COLUMN `CreatedAt` SET DEFAULT CURRENT_TIMESTAMP(6);
|
||||
|
||||
ALTER TABLE `Clients`
|
||||
ALTER COLUMN `LastModifiedAt` SET DEFAULT CURRENT_TIMESTAMP(6);
|
||||
CHANGE `LastModifiedAt` `LastModifiedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `ClientsHistory`
|
||||
(
|
||||
|
||||
@@ -1,11 +1,8 @@
|
||||
ALTER TABLE `GameServers`
|
||||
MODIFY `LastModifiedAt` DATETIME(6) NULL ON UPDATE CURRENT_TIMESTAMP(6);
|
||||
CHANGE `CreatedAt` `CreatedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6);
|
||||
|
||||
ALTER TABLE `GameServers`
|
||||
ALTER COLUMN `CreatedAt` SET DEFAULT CURRENT_TIMESTAMP(6);
|
||||
|
||||
ALTER TABLE `GameServers`
|
||||
ALTER COLUMN `LastModifiedAt` SET DEFAULT CURRENT_TIMESTAMP(6);
|
||||
CHANGE `LastModifiedAt` `LastModifiedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `GameServersHistory`
|
||||
(
|
||||
|
||||
@@ -1,11 +1,8 @@
|
||||
ALTER TABLE `KnownUsers`
|
||||
MODIFY `LastModifiedAt` DATETIME(6) NULL ON UPDATE CURRENT_TIMESTAMP(6);
|
||||
CHANGE `CreatedAt` `CreatedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6);
|
||||
|
||||
ALTER TABLE `KnownUsers`
|
||||
ALTER COLUMN `CreatedAt` SET DEFAULT CURRENT_TIMESTAMP(6);
|
||||
|
||||
ALTER TABLE `KnownUsers`
|
||||
ALTER COLUMN `LastModifiedAt` SET DEFAULT CURRENT_TIMESTAMP(6);
|
||||
CHANGE `LastModifiedAt` `LastModifiedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `KnownUsersHistory`
|
||||
(
|
||||
|
||||
@@ -1,11 +1,8 @@
|
||||
ALTER TABLE `Levels`
|
||||
MODIFY `LastModifiedAt` DATETIME(6) NULL ON UPDATE CURRENT_TIMESTAMP(6);
|
||||
CHANGE `CreatedAt` `CreatedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6);
|
||||
|
||||
ALTER TABLE `Levels`
|
||||
ALTER COLUMN `CreatedAt` SET DEFAULT CURRENT_TIMESTAMP(6);
|
||||
|
||||
ALTER TABLE `Levels`
|
||||
ALTER COLUMN `LastModifiedAt` SET DEFAULT CURRENT_TIMESTAMP(6);
|
||||
CHANGE `LastModifiedAt` `LastModifiedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `LevelsHistory`
|
||||
(
|
||||
|
||||
@@ -1,11 +1,8 @@
|
||||
ALTER TABLE `Servers`
|
||||
MODIFY `LastModifiedAt` DATETIME(6) NULL ON UPDATE CURRENT_TIMESTAMP(6);
|
||||
CHANGE `CreatedAt` `CreatedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6);
|
||||
|
||||
ALTER TABLE `Servers`
|
||||
ALTER COLUMN `CreatedAt` SET DEFAULT CURRENT_TIMESTAMP(6);
|
||||
|
||||
ALTER TABLE `Servers`
|
||||
ALTER COLUMN `LastModifiedAt` SET DEFAULT CURRENT_TIMESTAMP(6);
|
||||
CHANGE `LastModifiedAt` `LastModifiedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `ServersHistory`
|
||||
(
|
||||
|
||||
@@ -1,11 +1,8 @@
|
||||
ALTER TABLE `UserGameIdents`
|
||||
MODIFY `LastModifiedAt` DATETIME(6) NULL ON UPDATE CURRENT_TIMESTAMP(6);
|
||||
CHANGE `CreatedAt` `CreatedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6);
|
||||
|
||||
ALTER TABLE `UserGameIdents`
|
||||
ALTER COLUMN `CreatedAt` SET DEFAULT CURRENT_TIMESTAMP(6);
|
||||
|
||||
ALTER TABLE `UserGameIdents`
|
||||
ALTER COLUMN `LastModifiedAt` SET DEFAULT CURRENT_TIMESTAMP(6);
|
||||
CHANGE `LastModifiedAt` `LastModifiedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `UserGameIdentsHistory`
|
||||
(
|
||||
|
||||
@@ -1,11 +1,8 @@
|
||||
ALTER TABLE `UserJoinedGameServer`
|
||||
MODIFY `LastModifiedAt` DATETIME(6) NULL ON UPDATE CURRENT_TIMESTAMP(6);
|
||||
CHANGE `CreatedAt` `CreatedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6);
|
||||
|
||||
ALTER TABLE `UserJoinedGameServer`
|
||||
ALTER COLUMN `CreatedAt` SET DEFAULT CURRENT_TIMESTAMP(6);
|
||||
|
||||
ALTER TABLE `UserJoinedGameServer`
|
||||
ALTER COLUMN `LastModifiedAt` SET DEFAULT CURRENT_TIMESTAMP(6);
|
||||
CHANGE `LastModifiedAt` `LastModifiedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `UserJoinedGameServerHistory`
|
||||
(
|
||||
|
||||
@@ -1,11 +1,8 @@
|
||||
ALTER TABLE `UserJoinedServers`
|
||||
MODIFY `LastModifiedAt` DATETIME(6) NULL ON UPDATE CURRENT_TIMESTAMP(6);
|
||||
CHANGE `CreatedAt` `CreatedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6);
|
||||
|
||||
ALTER TABLE `UserJoinedServers`
|
||||
ALTER COLUMN `CreatedAt` SET DEFAULT CURRENT_TIMESTAMP(6);
|
||||
|
||||
ALTER TABLE `UserJoinedServers`
|
||||
ALTER COLUMN `LastModifiedAt` SET DEFAULT CURRENT_TIMESTAMP(6);
|
||||
CHANGE `LastModifiedAt` `LastModifiedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `UserJoinedServersHistory`
|
||||
(
|
||||
|
||||
@@ -1,11 +1,8 @@
|
||||
ALTER TABLE `UserJoinedVoiceChannel`
|
||||
MODIFY `LastModifiedAt` DATETIME(6) NULL ON UPDATE CURRENT_TIMESTAMP(6);
|
||||
CHANGE `CreatedAt` `CreatedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6);
|
||||
|
||||
ALTER TABLE `UserJoinedVoiceChannel`
|
||||
ALTER COLUMN `CreatedAt` SET DEFAULT CURRENT_TIMESTAMP(6);
|
||||
|
||||
ALTER TABLE `UserJoinedVoiceChannel`
|
||||
ALTER COLUMN `LastModifiedAt` SET DEFAULT CURRENT_TIMESTAMP(6);
|
||||
CHANGE `LastModifiedAt` `LastModifiedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `UserJoinedVoiceChannelHistory`
|
||||
(
|
||||
|
||||
@@ -1,11 +1,8 @@
|
||||
ALTER TABLE `UserMessageCountPerHour`
|
||||
MODIFY `LastModifiedAt` DATETIME(6) NULL ON UPDATE CURRENT_TIMESTAMP(6);
|
||||
CHANGE `CreatedAt` `CreatedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6);
|
||||
|
||||
ALTER TABLE `UserMessageCountPerHour`
|
||||
ALTER COLUMN `CreatedAt` SET DEFAULT CURRENT_TIMESTAMP(6);
|
||||
|
||||
ALTER TABLE `UserMessageCountPerHour`
|
||||
ALTER COLUMN `LastModifiedAt` SET DEFAULT CURRENT_TIMESTAMP(6);
|
||||
CHANGE `LastModifiedAt` `LastModifiedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `UserMessageCountPerHourHistory`
|
||||
(
|
||||
|
||||
@@ -1,11 +1,8 @@
|
||||
ALTER TABLE `UserWarnings`
|
||||
MODIFY `LastModifiedAt` DATETIME(6) NULL ON UPDATE CURRENT_TIMESTAMP(6);
|
||||
CHANGE `CreatedAt` `CreatedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6);
|
||||
|
||||
ALTER TABLE `UserWarnings`
|
||||
ALTER COLUMN `CreatedAt` SET DEFAULT CURRENT_TIMESTAMP(6);
|
||||
|
||||
ALTER TABLE `UserWarnings`
|
||||
ALTER COLUMN `LastModifiedAt` SET DEFAULT CURRENT_TIMESTAMP(6);
|
||||
CHANGE `LastModifiedAt` `LastModifiedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `UserWarningsHistory`
|
||||
(
|
||||
|
||||
@@ -1,11 +1,8 @@
|
||||
ALTER TABLE `Users`
|
||||
MODIFY `LastModifiedAt` DATETIME(6) NULL ON UPDATE CURRENT_TIMESTAMP(6);
|
||||
CHANGE `CreatedAt` `CreatedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6);
|
||||
|
||||
ALTER TABLE `Users`
|
||||
ALTER COLUMN `CreatedAt` SET DEFAULT CURRENT_TIMESTAMP(6);
|
||||
|
||||
ALTER TABLE `Users`
|
||||
ALTER COLUMN `LastModifiedAt` SET DEFAULT CURRENT_TIMESTAMP(6);
|
||||
CHANGE `LastModifiedAt` `LastModifiedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `UsersHistory`
|
||||
(
|
||||
|
||||
@@ -15,7 +15,7 @@ __title__ = "bot_data.model"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.0.0rc1"
|
||||
__version__ = "1.0.2"
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
@@ -23,4 +23,4 @@ from collections import namedtuple
|
||||
# imports
|
||||
|
||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||
version_info = VersionInfo(major="1", minor="0", micro="0.rc1")
|
||||
version_info = VersionInfo(major="1", minor="0", micro="2")
|
||||
|
||||
@@ -15,7 +15,7 @@ __title__ = "bot_data.service"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.0.0rc1"
|
||||
__version__ = "1.0.2"
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
@@ -23,4 +23,4 @@ from collections import namedtuple
|
||||
# imports
|
||||
|
||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||
version_info = VersionInfo(major="1", minor="0", micro="0.rc1")
|
||||
version_info = VersionInfo(major="1", minor="0", micro="2")
|
||||
|
||||
16
kdb-bot/src/bot_data/service/cache_service.py
Normal file
16
kdb-bot/src/bot_data/service/cache_service.py
Normal file
@@ -0,0 +1,16 @@
|
||||
from cpl_query.extension import List
|
||||
|
||||
from bot_data.model.server import Server
|
||||
|
||||
|
||||
class CacheService:
|
||||
def __init__(self):
|
||||
self._cached_server = List(Server)
|
||||
|
||||
@property
|
||||
def cached_server(self) -> List[Server]:
|
||||
return self._cached_server
|
||||
|
||||
@cached_server.setter
|
||||
def cached_server(self, value: List[Server]):
|
||||
self._cached_server = value
|
||||
@@ -8,12 +8,14 @@ from bot_core.logging.database_logger import DatabaseLogger
|
||||
from bot_data.abc.server_repository_abc import ServerRepositoryABC
|
||||
from bot_data.filtered_result import FilteredResult
|
||||
from bot_data.model.server import Server
|
||||
from bot_data.service.cache_service import CacheService
|
||||
|
||||
|
||||
class ServerRepositoryService(ServerRepositoryABC):
|
||||
def __init__(self, logger: DatabaseLogger, db_context: DatabaseContextABC):
|
||||
def __init__(self, logger: DatabaseLogger, db_context: DatabaseContextABC, cache: CacheService):
|
||||
self._logger = logger
|
||||
self._context = db_context
|
||||
self._cache = cache
|
||||
|
||||
ServerRepositoryABC.__init__(self)
|
||||
|
||||
@@ -24,6 +26,7 @@ class ServerRepositoryService(ServerRepositoryABC):
|
||||
for result in results:
|
||||
servers.append(Server(result[1], result[2], result[3], id=result[0]))
|
||||
|
||||
self._cache.cached_server = List(Server, servers)
|
||||
return servers
|
||||
|
||||
def get_filtered_servers(self, criteria: ServerSelectCriteria) -> FilteredResult:
|
||||
@@ -52,11 +55,21 @@ class ServerRepositoryService(ServerRepositoryABC):
|
||||
return result
|
||||
|
||||
def get_server_by_id(self, server_id: int) -> Server:
|
||||
cs = self._cache.cached_server.where(lambda x: x.id == server_id).single_or_default()
|
||||
if cs is not None:
|
||||
return cs
|
||||
|
||||
self._logger.trace(__name__, f"Send SQL command: {Server.get_select_by_id_string(server_id)}")
|
||||
result = self._context.select(Server.get_select_by_id_string(server_id))[0]
|
||||
return Server(result[1], result[2], result[3], id=result[0])
|
||||
server = Server(result[1], result[2], result[3], id=result[0])
|
||||
self._cache.cached_server.add(server)
|
||||
return server
|
||||
|
||||
def get_server_by_discord_id(self, discord_id: int) -> Server:
|
||||
cs = self._cache.cached_server.where(lambda x: x.discord_id == discord_id).single_or_default()
|
||||
if cs is not None:
|
||||
return cs
|
||||
|
||||
self._logger.trace(
|
||||
__name__,
|
||||
f"Send SQL command: {Server.get_select_by_discord_id_string(discord_id)}",
|
||||
@@ -65,6 +78,10 @@ class ServerRepositoryService(ServerRepositoryABC):
|
||||
return Server(result[1], result[2], result[3], id=result[0])
|
||||
|
||||
def find_server_by_discord_id(self, discord_id: int) -> Optional[Server]:
|
||||
cs = self._cache.cached_server.where(lambda x: x.discord_id == discord_id).single_or_default()
|
||||
if cs is not None:
|
||||
return cs
|
||||
|
||||
self._logger.trace(
|
||||
__name__,
|
||||
f"Send SQL command: {Server.get_select_by_discord_id_string(discord_id)}",
|
||||
|
||||
@@ -15,7 +15,7 @@ __title__ = "bot_graphql"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.0.0rc1"
|
||||
__version__ = "1.0.2"
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
@@ -23,4 +23,4 @@ from collections import namedtuple
|
||||
# imports
|
||||
|
||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||
version_info = VersionInfo(major="1", minor="0", micro="0.rc1")
|
||||
version_info = VersionInfo(major="1", minor="0", micro="2")
|
||||
|
||||
@@ -15,7 +15,7 @@ __title__ = "bot_graphql.abc"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.0.0rc1"
|
||||
__version__ = "1.0.2"
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
@@ -23,4 +23,4 @@ from collections import namedtuple
|
||||
# imports:
|
||||
|
||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||
version_info = VersionInfo(major="1", minor="0", micro="0.rc1")
|
||||
version_info = VersionInfo(major="1", minor="0", micro="2")
|
||||
|
||||
@@ -82,7 +82,7 @@ class QueryABC(ObjectType):
|
||||
break
|
||||
|
||||
elif type(element) == AutoRoleRule:
|
||||
element: AutoRole = element.game_server
|
||||
element: AutoRole = element
|
||||
for u in user.users:
|
||||
u: User = u
|
||||
guild = bot.get_guild(u.server.discord_id)
|
||||
@@ -124,28 +124,36 @@ class QueryABC(ObjectType):
|
||||
elif type(element) == User:
|
||||
for u in user.users:
|
||||
u: User = u
|
||||
if u.id == element.id:
|
||||
guild = bot.get_guild(u.server.discord_id)
|
||||
member = guild.get_member(u.discord_id)
|
||||
if u.id == element.id or permissions.is_member_moderator(member):
|
||||
access = True
|
||||
break
|
||||
|
||||
elif type(element) == UserJoinedServer:
|
||||
for u in user.users:
|
||||
u: User = u
|
||||
if u.id == element.user.id:
|
||||
guild = bot.get_guild(u.server.discord_id)
|
||||
member = guild.get_member(u.discord_id)
|
||||
if u.id == element.user.id or permissions.is_member_moderator(member):
|
||||
access = True
|
||||
break
|
||||
|
||||
elif type(element) == UserJoinedVoiceChannel:
|
||||
for u in user.users:
|
||||
u: User = u
|
||||
if u.id == element.user.id:
|
||||
guild = bot.get_guild(u.server.discord_id)
|
||||
member = guild.get_member(u.discord_id)
|
||||
if u.id == element.user.id or permissions.is_member_moderator(member):
|
||||
access = True
|
||||
break
|
||||
|
||||
elif type(element) == UserJoinedGameServer:
|
||||
for u in user.users:
|
||||
u: User = u
|
||||
if u.id == element.user.id:
|
||||
guild = bot.get_guild(u.server.discord_id)
|
||||
member = guild.get_member(u.discord_id)
|
||||
if u.id == element.user.id or permissions.is_member_moderator(member):
|
||||
access = True
|
||||
break
|
||||
|
||||
@@ -182,10 +190,10 @@ class QueryABC(ObjectType):
|
||||
if filter is not None:
|
||||
collection = filter.filter(collection)
|
||||
|
||||
if page is not None:
|
||||
collection = page.filter(collection)
|
||||
|
||||
if sort is not None:
|
||||
collection = sort.filter(collection)
|
||||
|
||||
if page is not None:
|
||||
collection = page.filter(collection)
|
||||
|
||||
return collection
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
"Version": {
|
||||
"Major": "1",
|
||||
"Minor": "0",
|
||||
"Micro": "0.rc1"
|
||||
"Micro": "2"
|
||||
},
|
||||
"Author": "Sven Heidemann",
|
||||
"AuthorEmail": "sven.heidemann@sh-edraft.de",
|
||||
@@ -16,10 +16,10 @@
|
||||
"LicenseName": "MIT",
|
||||
"LicenseDescription": "MIT, see LICENSE for more details.",
|
||||
"Dependencies": [
|
||||
"cpl-core>=1.0.0.rc1"
|
||||
"cpl-core>=1.0.2"
|
||||
],
|
||||
"DevDependencies": [
|
||||
"cpl-cli>=1.0.0.rc1"
|
||||
"cpl-cli>=1.0.2"
|
||||
],
|
||||
"PythonVersion": ">=3.10.4",
|
||||
"PythonPath": {},
|
||||
|
||||
@@ -15,7 +15,7 @@ __title__ = "bot_graphql.filter"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.0.0rc1"
|
||||
__version__ = "1.0.2"
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
@@ -23,4 +23,4 @@ from collections import namedtuple
|
||||
# imports:
|
||||
|
||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||
version_info = VersionInfo(major="1", minor="0", micro="0.rc1")
|
||||
version_info = VersionInfo(major="1", minor="0", micro="2")
|
||||
|
||||
@@ -30,7 +30,6 @@ type UserHistory implements HistoryTableQuery {
|
||||
xp: Int
|
||||
|
||||
server: ID
|
||||
leftServer: Boolean
|
||||
|
||||
deleted: Boolean
|
||||
dateFrom: String
|
||||
|
||||
@@ -15,7 +15,7 @@ __title__ = "bot_graphql.mutations"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.0.0rc1"
|
||||
__version__ = "1.0.2"
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
@@ -23,4 +23,4 @@ from collections import namedtuple
|
||||
# imports:
|
||||
|
||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||
version_info = VersionInfo(major="1", minor="0", micro="0.rc1")
|
||||
version_info = VersionInfo(major="1", minor="0", micro="2")
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
from cpl_core.database.context import DatabaseContextABC
|
||||
from cpl_discord.service import DiscordBotServiceABC
|
||||
|
||||
from bot_core.abc.client_utils_abc import ClientUtilsABC
|
||||
from bot_data.abc.auto_role_repository_abc import AutoRoleRepositoryABC
|
||||
from bot_data.abc.server_repository_abc import ServerRepositoryABC
|
||||
from bot_data.model.auto_role_rule import AutoRoleRule
|
||||
@@ -10,15 +12,19 @@ from bot_graphql.abc.query_abc import QueryABC
|
||||
class AutoRoleRuleMutation(QueryABC):
|
||||
def __init__(
|
||||
self,
|
||||
bot: DiscordBotServiceABC,
|
||||
servers: ServerRepositoryABC,
|
||||
auto_roles: AutoRoleRepositoryABC,
|
||||
db: DatabaseContextABC,
|
||||
client_utils: ClientUtilsABC,
|
||||
):
|
||||
QueryABC.__init__(self, "AutoRoleRuleMutation")
|
||||
|
||||
self._bot = bot
|
||||
self._servers = servers
|
||||
self._auto_roles = auto_roles
|
||||
self._db = db
|
||||
self._client_utils = client_utils
|
||||
|
||||
self.set_field("createAutoRoleRule", self.resolve_create_auto_role_rule)
|
||||
self.set_field("updateAutoRoleRule", self.resolve_update_auto_role_rule)
|
||||
@@ -40,6 +46,14 @@ class AutoRoleRuleMutation(QueryABC):
|
||||
and x.role_id == int(input["roleId"])
|
||||
)
|
||||
|
||||
self._bot.loop.create_task(
|
||||
self._client_utils.react_to_message_by_auto_role_rule(
|
||||
auto_role_rule.auto_role.discord_channel_id,
|
||||
auto_role_rule.auto_role.discord_message_id,
|
||||
auto_role_rule,
|
||||
self._bot.get_guild(auto_role_rule.auto_role.server.discord_id),
|
||||
)
|
||||
)
|
||||
return self._auto_roles.get_auto_role_rules_by_auto_role_id(auto_role_rule.auto_role.id).where(get_new).last()
|
||||
|
||||
def resolve_update_auto_role_rule(self, *_, input: dict):
|
||||
@@ -53,6 +67,14 @@ class AutoRoleRuleMutation(QueryABC):
|
||||
self._db.save_changes()
|
||||
|
||||
auto_role_rule = self._auto_roles.get_auto_role_rule_by_id(input["id"])
|
||||
self._bot.loop.create_task(
|
||||
self._client_utils.react_to_message_by_auto_role_rule(
|
||||
auto_role_rule.auto_role.discord_channel_id,
|
||||
auto_role_rule.auto_role.discord_message_id,
|
||||
auto_role_rule,
|
||||
self._bot.get_guild(auto_role_rule.auto_role.server.discord_id),
|
||||
)
|
||||
)
|
||||
return auto_role_rule
|
||||
|
||||
def resolve_delete_auto_role_rule(self, *_, id: int):
|
||||
|
||||
@@ -39,9 +39,10 @@ class UserMutation(QueryABC):
|
||||
|
||||
if "levelId" in input:
|
||||
level = self._levels.get_level_by_id(input["levelId"])
|
||||
user.xp = level.min_xp
|
||||
|
||||
user.xp = input["xp"] if "xp" in input else user.xp
|
||||
if user.level.id != level.id:
|
||||
user.xp = level.min_xp
|
||||
else:
|
||||
user.xp = input["xp"] if "xp" in input else user.xp
|
||||
|
||||
self._users.update_user(user)
|
||||
self._db.save_changes()
|
||||
|
||||
@@ -15,7 +15,7 @@ __title__ = "bot_graphql.queries"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.0.0rc1"
|
||||
__version__ = "1.0.2"
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
@@ -23,4 +23,4 @@ from collections import namedtuple
|
||||
# imports:
|
||||
|
||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||
version_info = VersionInfo(major="1", minor="0", micro="0.rc1")
|
||||
version_info = VersionInfo(major="1", minor="0", micro="2")
|
||||
|
||||
@@ -15,7 +15,7 @@ __title__ = "bot_graphql.queries.discord"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.0.0rc1"
|
||||
__version__ = "1.0.2"
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
@@ -23,4 +23,4 @@ from collections import namedtuple
|
||||
# imports:
|
||||
|
||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||
version_info = VersionInfo(major="1", minor="0", micro="0.rc1")
|
||||
version_info = VersionInfo(major="1", minor="0", micro="2")
|
||||
|
||||
@@ -10,7 +10,6 @@ class UserHistoryQuery(HistoryQueryABC):
|
||||
self.set_field("discordId", self.resolve_discord_id)
|
||||
self.set_field("xp", self.resolve_xp)
|
||||
self.set_field("server", self.resolve_server)
|
||||
self.set_field("leftServer", self.resolve_left_server)
|
||||
|
||||
@staticmethod
|
||||
def resolve_id(user: User, *_):
|
||||
@@ -27,7 +26,3 @@ class UserHistoryQuery(HistoryQueryABC):
|
||||
@staticmethod
|
||||
def resolve_server(user: User, *_):
|
||||
return user.server
|
||||
|
||||
@staticmethod
|
||||
def resolve_left_server(user: User, *_):
|
||||
return user.left_server
|
||||
|
||||
@@ -15,7 +15,7 @@ __title__ = "modules.auto_role"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.0.0rc1"
|
||||
__version__ = "1.0.2"
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
@@ -23,4 +23,4 @@ from collections import namedtuple
|
||||
# imports:
|
||||
|
||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||
version_info = VersionInfo(major="1", minor="0", micro="0.rc1")
|
||||
version_info = VersionInfo(major="1", minor="0", micro="2")
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
"Version": {
|
||||
"Major": "1",
|
||||
"Minor": "0",
|
||||
"Micro": "0.rc1"
|
||||
"Micro": "2"
|
||||
},
|
||||
"Author": "",
|
||||
"AuthorEmail": "",
|
||||
|
||||
@@ -15,7 +15,7 @@ __title__ = "modules.auto_role.command"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.0.0rc1"
|
||||
__version__ = "1.0.2"
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
@@ -23,4 +23,4 @@ from collections import namedtuple
|
||||
# imports:
|
||||
|
||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||
version_info = VersionInfo(major="1", minor="0", micro="0.rc1")
|
||||
version_info = VersionInfo(major="1", minor="0", micro="2")
|
||||
|
||||
@@ -6,7 +6,7 @@ from cpl_discord.command import DiscordCommandABC
|
||||
from cpl_discord.service import DiscordBotServiceABC
|
||||
from cpl_query.extension import List
|
||||
from cpl_translation import TranslatePipe
|
||||
from discord import app_commands, Guild
|
||||
from discord import app_commands
|
||||
from discord.ext import commands
|
||||
from discord.ext.commands import Context
|
||||
|
||||
@@ -312,26 +312,13 @@ class AutoRoleGroup(DiscordCommandABC):
|
||||
.where(lambda r: r.emoji_name == emoji.name and int(role_id) == role.id)
|
||||
.single()
|
||||
)
|
||||
try:
|
||||
guild: Guild = self._bot.guilds.where(lambda g: g == ctx.guild).single()
|
||||
channel = guild.get_channel(auto_role_from_db.discord_channel_id)
|
||||
message = await channel.fetch_message(auto_role_from_db.discord_message_id)
|
||||
emoji = List(discord.Emoji, guild.emojis).where(lambda x: x.name == rule.emoji_name).single()
|
||||
|
||||
if emoji is None:
|
||||
self._logger.debug(__name__, f"Emoji {rule.emoji_name} not found")
|
||||
return
|
||||
await message.add_reaction(emoji)
|
||||
self._logger.debug(
|
||||
__name__,
|
||||
f"Added reaction {rule.emoji_name} to message: {auto_role_from_db.discord_message_id}",
|
||||
)
|
||||
except Exception as e:
|
||||
self._logger.error(
|
||||
__name__,
|
||||
f"Cannot add reaction {rule.emoji_name} to message: {auto_role_from_db.discord_message_id}",
|
||||
e,
|
||||
# as task to run in background
|
||||
self._bot.loop.create_task(
|
||||
await self._client_utils.react_to_message_by_auto_role_rule(
|
||||
auto_role_from_db.discord_channel_id, auto_role_from_db.discord_message_id, rule, ctx.guild
|
||||
)
|
||||
)
|
||||
|
||||
await self._message_service.send_ctx_msg(
|
||||
ctx,
|
||||
|
||||
@@ -15,7 +15,7 @@ __title__ = "modules.auto_role.events"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.0.0rc1"
|
||||
__version__ = "1.0.2"
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
@@ -23,4 +23,4 @@ from collections import namedtuple
|
||||
# imports:
|
||||
|
||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||
version_info = VersionInfo(major="1", minor="0", micro="0.rc1")
|
||||
version_info = VersionInfo(major="1", minor="0", micro="2")
|
||||
|
||||
@@ -15,7 +15,7 @@ __title__ = "modules.auto_role.helper"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.0.0rc1"
|
||||
__version__ = "1.0.2"
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
@@ -23,4 +23,4 @@ from collections import namedtuple
|
||||
# imports:
|
||||
|
||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||
version_info = VersionInfo(major="1", minor="0", micro="0.rc1")
|
||||
version_info = VersionInfo(major="1", minor="0", micro="2")
|
||||
|
||||
@@ -32,9 +32,9 @@ class AutoRoleReactionHandler:
|
||||
return
|
||||
|
||||
guild = self._bot.get_guild(payload.guild_id)
|
||||
user = guild.get_member(payload.user_id)
|
||||
user = guild.get_member(payload.id)
|
||||
if user is None:
|
||||
self._logger.warn(__name__, f"User {payload.user_id} in {guild.name} not found - skipping")
|
||||
self._logger.warn(__name__, f"User {payload.id} in {guild.name} not found - skipping")
|
||||
return
|
||||
|
||||
if user.bot:
|
||||
|
||||
@@ -15,7 +15,7 @@ __title__ = "modules.base"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.0.0rc1"
|
||||
__version__ = "1.0.2"
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
@@ -23,4 +23,4 @@ from collections import namedtuple
|
||||
# imports
|
||||
|
||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||
version_info = VersionInfo(major="1", minor="0", micro="0.rc1")
|
||||
version_info = VersionInfo(major="1", minor="0", micro="2")
|
||||
|
||||
@@ -15,7 +15,7 @@ __title__ = "modules.base.abc"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.0.0rc1"
|
||||
__version__ = "1.0.2"
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
@@ -23,4 +23,4 @@ from collections import namedtuple
|
||||
# imports:
|
||||
|
||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||
version_info = VersionInfo(major="1", minor="0", micro="0.rc1")
|
||||
version_info = VersionInfo(major="1", minor="0", micro="2")
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
"Version": {
|
||||
"Major": "1",
|
||||
"Minor": "0",
|
||||
"Micro": "0.rc1"
|
||||
"Micro": "2"
|
||||
},
|
||||
"Author": "",
|
||||
"AuthorEmail": "",
|
||||
|
||||
@@ -15,7 +15,7 @@ __title__ = "modules.base.command"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.0.0rc1"
|
||||
__version__ = "1.0.2"
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
@@ -23,4 +23,4 @@ from collections import namedtuple
|
||||
# imports
|
||||
|
||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||
version_info = VersionInfo(major="1", minor="0", micro="0.rc1")
|
||||
version_info = VersionInfo(major="1", minor="0", micro="2")
|
||||
|
||||
@@ -15,7 +15,7 @@ __title__ = "modules.base.configuration"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.0.0rc1"
|
||||
__version__ = "1.0.2"
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
@@ -23,4 +23,4 @@ from collections import namedtuple
|
||||
# imports:
|
||||
|
||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||
version_info = VersionInfo(major="1", minor="0", micro="0.rc1")
|
||||
version_info = VersionInfo(major="1", minor="0", micro="2")
|
||||
|
||||
@@ -15,7 +15,7 @@ __title__ = "modules.base.events"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.0.0rc1"
|
||||
__version__ = "1.0.2"
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
@@ -23,4 +23,4 @@ from collections import namedtuple
|
||||
# imports:
|
||||
|
||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||
version_info = VersionInfo(major="1", minor="0", micro="0.rc1")
|
||||
version_info = VersionInfo(major="1", minor="0", micro="2")
|
||||
|
||||
@@ -102,6 +102,9 @@ class BaseOnVoiceStateUpdateEvent(OnVoiceStateUpdateABC):
|
||||
server = self._servers.get_server_by_discord_id(member.guild.id)
|
||||
|
||||
try:
|
||||
if before.channel == after.channel:
|
||||
return
|
||||
|
||||
# join
|
||||
if (
|
||||
before.channel is None
|
||||
|
||||
@@ -52,12 +52,12 @@ class BaseOnVoiceStateUpdateEventScheduledEventBonus(OnVoiceStateUpdateABC):
|
||||
return
|
||||
|
||||
server = self._servers.get_server_by_discord_id(member.guild.id)
|
||||
user = self._users.get_user_by_discord_id_and_server_id(member.id, server.server_id)
|
||||
if active_event.participants.any(lambda x: x.user_id == user.user_id):
|
||||
user = self._users.get_user_by_discord_id_and_server_id(member.id, server.id)
|
||||
if active_event.participants.any(lambda x: x.id == user.id):
|
||||
self._logger.debug(__name__, f"Module {type(self)} stopped")
|
||||
return
|
||||
|
||||
settings: BaseServerSettings = self._base_helper.get_config(server.discord_server_id)
|
||||
settings: BaseServerSettings = self._base_helper.get_config(server.discord_id)
|
||||
user.xp += settings.xp_per_event_participation
|
||||
self._users.update_user(user)
|
||||
self._db.save_changes()
|
||||
|
||||
@@ -15,7 +15,7 @@ __title__ = "modules.base.helper"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.0.0rc1"
|
||||
__version__ = "1.0.2"
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
@@ -23,4 +23,4 @@ from collections import namedtuple
|
||||
# imports:
|
||||
|
||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||
version_info = VersionInfo(major="1", minor="0", micro="0.rc1")
|
||||
version_info = VersionInfo(major="1", minor="0", micro="2")
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
from datetime import datetime
|
||||
|
||||
from cpl_core.database.context import DatabaseContextABC
|
||||
from cpl_core.logging import LoggerABC
|
||||
from cpl_discord.service import DiscordBotServiceABC
|
||||
from discord import RawReactionActionEvent
|
||||
|
||||
from bot_core.abc.client_utils_abc import ClientUtilsABC
|
||||
from bot_core.helper.log_message_helper import LogMessageHelper
|
||||
from bot_core.logging.message_logger import MessageLogger
|
||||
from bot_data.abc.server_repository_abc import ServerRepositoryABC
|
||||
from bot_data.abc.user_repository_abc import UserRepositoryABC
|
||||
from modules.base.abc.base_helper_abc import BaseHelperABC
|
||||
@@ -16,7 +16,7 @@ from modules.base.configuration.base_server_settings import BaseServerSettings
|
||||
class BaseReactionHandler:
|
||||
def __init__(
|
||||
self,
|
||||
logger: LoggerABC,
|
||||
logger: MessageLogger,
|
||||
bot: DiscordBotServiceABC,
|
||||
servers: ServerRepositoryABC,
|
||||
users: UserRepositoryABC,
|
||||
|
||||
@@ -15,7 +15,7 @@ __title__ = "modules.base.model"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.0.0rc1"
|
||||
__version__ = "1.0.2"
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
@@ -23,4 +23,4 @@ from collections import namedtuple
|
||||
# imports:
|
||||
|
||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||
version_info = VersionInfo(major="1", minor="0", micro="0.rc1")
|
||||
version_info = VersionInfo(major="1", minor="0", micro="2")
|
||||
|
||||
@@ -15,7 +15,7 @@ __title__ = "modules.base.service"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||
__version__ = "1.0.0rc1"
|
||||
__version__ = "1.0.2"
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
@@ -23,4 +23,4 @@ from collections import namedtuple
|
||||
# imports
|
||||
|
||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||
version_info = VersionInfo(major="1", minor="0", micro="0.rc1")
|
||||
version_info = VersionInfo(major="1", minor="0", micro="2")
|
||||
|
||||
@@ -57,7 +57,9 @@ class UserWarningsService:
|
||||
else:
|
||||
translation = self._t.transform("modules.base.warnings.team_warned").format(member.mention, description)
|
||||
|
||||
self._bot.loop.create_task(self._message_service.send_channel_message(channel, translation))
|
||||
self._bot.loop.create_task(
|
||||
self._message_service.send_channel_message(channel, translation, is_persistent=True)
|
||||
)
|
||||
except Exception as e:
|
||||
self._logger.error(__name__, f"Team notification for user warning failed!", e)
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user