Compare commits
32 Commits
9353fa749c
...
master
Author | SHA1 | Date | |
---|---|---|---|
aa0bed80ce | |||
d0b4a390f0 | |||
65d04785b1 | |||
614a60bd2b | |||
e5b03e7219 | |||
09c8f41b05 | |||
bebecb5ec6 | |||
5a31ea5f76 | |||
6216bcf917 | |||
f060d62039 | |||
5d30f551fd | |||
6e74e9b190 | |||
352ede1667 | |||
405055edf5 | |||
3abd145ce2 | |||
2bb22c0297 | |||
1d4e99de46 | |||
9bed89ed60 | |||
35fdeb168f | |||
e785bddf2e | |||
b361a7b685 | |||
bdd0da38ab | |||
179c8a954b | |||
248d47c280 | |||
414720f53b | |||
bb0ff1c560 | |||
521a063fca | |||
dc5ae365bb | |||
3c21b68b0c | |||
df316fd53b | |||
0a18f26a51 | |||
995c498e54 |
@@ -7,7 +7,7 @@ on:
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
pre-build:
|
pre-build:
|
||||||
runs-on: [ dobby.sh-edraft.de, ubuntu-latest ]
|
runs-on: [ dobby ]
|
||||||
container: git.sh-edraft.de/sh-edraft.de/act-runner:latest
|
container: git.sh-edraft.de/sh-edraft.de/act-runner:latest
|
||||||
steps:
|
steps:
|
||||||
- name: Shutdown stack
|
- name: Shutdown stack
|
||||||
@@ -15,13 +15,9 @@ jobs:
|
|||||||
|
|
||||||
build-bot:
|
build-bot:
|
||||||
needs: pre-build
|
needs: pre-build
|
||||||
runs-on: [ dobby.sh-edraft.de, ubuntu-latest ]
|
runs-on: [ dobby ]
|
||||||
container: git.sh-edraft.de/sh-edraft.de/act-runner:latest
|
container: git.sh-edraft.de/sh-edraft.de/act-runner:latest
|
||||||
steps:
|
steps:
|
||||||
- name: Setup docker
|
|
||||||
uses: https://github.com/papodaca/install-docker-action@main
|
|
||||||
- run: docker -v
|
|
||||||
|
|
||||||
- name: Clone Repository
|
- name: Clone Repository
|
||||||
uses: https://github.com/actions/checkout@v3
|
uses: https://github.com/actions/checkout@v3
|
||||||
with:
|
with:
|
||||||
@@ -55,13 +51,9 @@ jobs:
|
|||||||
|
|
||||||
build-web:
|
build-web:
|
||||||
needs: pre-build
|
needs: pre-build
|
||||||
runs-on: [ dobby.sh-edraft.de, ubuntu-latest ]
|
runs-on: [ dobby ]
|
||||||
container: git.sh-edraft.de/sh-edraft.de/act-runner:latest
|
container: git.sh-edraft.de/sh-edraft.de/act-runner:latest
|
||||||
steps:
|
steps:
|
||||||
- name: Setup docker
|
|
||||||
uses: https://github.com/papodaca/install-docker-action@main
|
|
||||||
- run: docker -v
|
|
||||||
|
|
||||||
- name: Clone Repository
|
- name: Clone Repository
|
||||||
uses: https://github.com/actions/checkout@v3
|
uses: https://github.com/actions/checkout@v3
|
||||||
with:
|
with:
|
||||||
@@ -99,7 +91,7 @@ jobs:
|
|||||||
|
|
||||||
deploy:
|
deploy:
|
||||||
needs: [ build-bot, build-web ]
|
needs: [ build-bot, build-web ]
|
||||||
runs-on: [ dobby.sh-edraft.de, ubuntu-latest ]
|
runs-on: [ dobby ]
|
||||||
container: git.sh-edraft.de/sh-edraft.de/act-runner:latest
|
container: git.sh-edraft.de/sh-edraft.de/act-runner:latest
|
||||||
steps:
|
steps:
|
||||||
- name: Clone Repository
|
- name: Clone Repository
|
||||||
|
@@ -7,7 +7,7 @@ on:
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
pre-build:
|
pre-build:
|
||||||
runs-on: [ dobby.sh-edraft.de, ubuntu-latest ]
|
runs-on: [ dobby ]
|
||||||
container: git.sh-edraft.de/sh-edraft.de/act-runner:latest
|
container: git.sh-edraft.de/sh-edraft.de/act-runner:latest
|
||||||
steps:
|
steps:
|
||||||
- name: Shutdown stack
|
- name: Shutdown stack
|
||||||
@@ -15,13 +15,9 @@ jobs:
|
|||||||
|
|
||||||
build-bot:
|
build-bot:
|
||||||
needs: pre-build
|
needs: pre-build
|
||||||
runs-on: [ dobby.sh-edraft.de, ubuntu-latest ]
|
runs-on: [ dobby ]
|
||||||
container: git.sh-edraft.de/sh-edraft.de/act-runner:latest
|
container: git.sh-edraft.de/sh-edraft.de/act-runner:latest
|
||||||
steps:
|
steps:
|
||||||
- name: Setup docker
|
|
||||||
uses: https://github.com/papodaca/install-docker-action@main
|
|
||||||
- run: docker -v
|
|
||||||
|
|
||||||
- name: Clone Repository
|
- name: Clone Repository
|
||||||
uses: https://github.com/actions/checkout@v3
|
uses: https://github.com/actions/checkout@v3
|
||||||
with:
|
with:
|
||||||
@@ -55,13 +51,9 @@ jobs:
|
|||||||
|
|
||||||
build-web:
|
build-web:
|
||||||
needs: pre-build
|
needs: pre-build
|
||||||
runs-on: [ dobby.sh-edraft.de, ubuntu-latest ]
|
runs-on: [ dobby ]
|
||||||
container: git.sh-edraft.de/sh-edraft.de/act-runner:latest
|
container: git.sh-edraft.de/sh-edraft.de/act-runner:latest
|
||||||
steps:
|
steps:
|
||||||
- name: Setup docker
|
|
||||||
uses: https://github.com/papodaca/install-docker-action@main
|
|
||||||
- run: docker -v
|
|
||||||
|
|
||||||
- name: Clone Repository
|
- name: Clone Repository
|
||||||
uses: https://github.com/actions/checkout@v3
|
uses: https://github.com/actions/checkout@v3
|
||||||
with:
|
with:
|
||||||
@@ -98,7 +90,7 @@ jobs:
|
|||||||
|
|
||||||
deploy:
|
deploy:
|
||||||
needs: [ build-bot, build-web ]
|
needs: [ build-bot, build-web ]
|
||||||
runs-on: [ dobby.sh-edraft.de, ubuntu-latest ]
|
runs-on: [ dobby ]
|
||||||
container: git.sh-edraft.de/sh-edraft.de/act-runner:latest
|
container: git.sh-edraft.de/sh-edraft.de/act-runner:latest
|
||||||
steps:
|
steps:
|
||||||
- name: Clone Repository
|
- name: Clone Repository
|
||||||
|
@@ -7,7 +7,7 @@ on:
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
pre-build:
|
pre-build:
|
||||||
runs-on: [ dobby.sh-edraft.de, ubuntu-latest ]
|
runs-on: [ dobby ]
|
||||||
container: git.sh-edraft.de/sh-edraft.de/act-runner:latest
|
container: git.sh-edraft.de/sh-edraft.de/act-runner:latest
|
||||||
steps:
|
steps:
|
||||||
- name: Shutdown stack
|
- name: Shutdown stack
|
||||||
@@ -15,13 +15,9 @@ jobs:
|
|||||||
|
|
||||||
build-bot:
|
build-bot:
|
||||||
needs: pre-build
|
needs: pre-build
|
||||||
runs-on: [ dobby.sh-edraft.de, ubuntu-latest ]
|
runs-on: [ dobby ]
|
||||||
container: git.sh-edraft.de/sh-edraft.de/act-runner:latest
|
container: git.sh-edraft.de/sh-edraft.de/act-runner:latest
|
||||||
steps:
|
steps:
|
||||||
- name: Setup docker
|
|
||||||
uses: https://github.com/papodaca/install-docker-action@main
|
|
||||||
- run: docker -v
|
|
||||||
|
|
||||||
- name: Clone Repository
|
- name: Clone Repository
|
||||||
uses: https://github.com/actions/checkout@v3
|
uses: https://github.com/actions/checkout@v3
|
||||||
with:
|
with:
|
||||||
@@ -55,13 +51,9 @@ jobs:
|
|||||||
|
|
||||||
build-web:
|
build-web:
|
||||||
needs: pre-build
|
needs: pre-build
|
||||||
runs-on: [ dobby.sh-edraft.de, ubuntu-latest ]
|
runs-on: [ dobby ]
|
||||||
container: git.sh-edraft.de/sh-edraft.de/act-runner:latest
|
container: git.sh-edraft.de/sh-edraft.de/act-runner:latest
|
||||||
steps:
|
steps:
|
||||||
- name: Setup docker
|
|
||||||
uses: https://github.com/papodaca/install-docker-action@main
|
|
||||||
- run: docker -v
|
|
||||||
|
|
||||||
- name: Clone Repository
|
- name: Clone Repository
|
||||||
uses: https://github.com/actions/checkout@v3
|
uses: https://github.com/actions/checkout@v3
|
||||||
with:
|
with:
|
||||||
@@ -99,7 +91,7 @@ jobs:
|
|||||||
|
|
||||||
deploy:
|
deploy:
|
||||||
needs: [ build-bot, build-web ]
|
needs: [ build-bot, build-web ]
|
||||||
runs-on: [ dobby.sh-edraft.de, ubuntu-latest ]
|
runs-on: [ dobby ]
|
||||||
container: git.sh-edraft.de/sh-edraft.de/act-runner:latest
|
container: git.sh-edraft.de/sh-edraft.de/act-runner:latest
|
||||||
steps:
|
steps:
|
||||||
- name: Clone Repository
|
- name: Clone Repository
|
||||||
|
@@ -14,6 +14,7 @@
|
|||||||
"config": "src/modules/config/config.json",
|
"config": "src/modules/config/config.json",
|
||||||
"database": "src/modules/database/database.json",
|
"database": "src/modules/database/database.json",
|
||||||
"level": "src/modules/level/level.json",
|
"level": "src/modules/level/level.json",
|
||||||
|
"realms": "src/modules/realms/realms.json",
|
||||||
"technician": "src/modules/technician/technician.json",
|
"technician": "src/modules/technician/technician.json",
|
||||||
"short-role-name": "src/modules/short_role_name/short-role-name.json",
|
"short-role-name": "src/modules/short_role_name/short-role-name.json",
|
||||||
"special-offers": "src/modules/special_offers/special-offers.json",
|
"special-offers": "src/modules/special_offers/special-offers.json",
|
||||||
|
Submodule bot/docker updated: 36ed43055d...c26ab4be08
@@ -15,7 +15,7 @@ __title__ = "bot"
|
|||||||
__author__ = "Sven Heidemann"
|
__author__ = "Sven Heidemann"
|
||||||
__license__ = "MIT"
|
__license__ = "MIT"
|
||||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||||
__version__ = "1.2.7"
|
__version__ = "1.2.11"
|
||||||
|
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
@@ -23,4 +23,4 @@ from collections import namedtuple
|
|||||||
# imports:
|
# imports:
|
||||||
|
|
||||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||||
version_info = VersionInfo(major="1", minor="2", micro="7")
|
version_info = VersionInfo(major="1", minor="2", micro="11")
|
||||||
|
@@ -4,7 +4,7 @@
|
|||||||
"Version": {
|
"Version": {
|
||||||
"Major": "1",
|
"Major": "1",
|
||||||
"Minor": "2",
|
"Minor": "2",
|
||||||
"Micro": "7"
|
"Micro": "11"
|
||||||
},
|
},
|
||||||
"Author": "Sven Heidemann",
|
"Author": "Sven Heidemann",
|
||||||
"AuthorEmail": "sven.heidemann@sh-edraft.de",
|
"AuthorEmail": "sven.heidemann@sh-edraft.de",
|
||||||
@@ -71,6 +71,7 @@
|
|||||||
"../modules/config/config.json",
|
"../modules/config/config.json",
|
||||||
"../modules/database/database.json",
|
"../modules/database/database.json",
|
||||||
"../modules/level/level.json",
|
"../modules/level/level.json",
|
||||||
|
"../modules/realms/realms.json",
|
||||||
"../modules/short_role_name/short-role-name.json",
|
"../modules/short_role_name/short-role-name.json",
|
||||||
"../modules/special_offers/special-offers.json",
|
"../modules/special_offers/special-offers.json",
|
||||||
"../modules/technician/technician.json"
|
"../modules/technician/technician.json"
|
||||||
|
Submodule bot/src/bot/config updated: eeebd13f80...40df176141
@@ -15,7 +15,7 @@ __title__ = "bot.extension"
|
|||||||
__author__ = "Sven Heidemann"
|
__author__ = "Sven Heidemann"
|
||||||
__license__ = "MIT"
|
__license__ = "MIT"
|
||||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||||
__version__ = "1.2.7"
|
__version__ = "1.2.11"
|
||||||
|
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
@@ -23,4 +23,4 @@ from collections import namedtuple
|
|||||||
# imports:
|
# imports:
|
||||||
|
|
||||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||||
version_info = VersionInfo(major="1", minor="2", micro="7")
|
version_info = VersionInfo(major="1", minor="2", micro="11")
|
||||||
|
@@ -12,6 +12,7 @@ from modules.boot_log.boot_log_module import BootLogModule
|
|||||||
from modules.config.config_module import ConfigModule
|
from modules.config.config_module import ConfigModule
|
||||||
from modules.database.database_module import DatabaseModule
|
from modules.database.database_module import DatabaseModule
|
||||||
from modules.level.level_module import LevelModule
|
from modules.level.level_module import LevelModule
|
||||||
|
from modules.realms.reams_module import RealmsModule
|
||||||
from modules.short_role_name.short_role_name_module import ShortRoleNameModule
|
from modules.short_role_name.short_role_name_module import ShortRoleNameModule
|
||||||
from modules.special_offers.special_offers_module import SteamSpecialOffersModule
|
from modules.special_offers.special_offers_module import SteamSpecialOffersModule
|
||||||
from modules.technician.technician_module import TechnicianModule
|
from modules.technician.technician_module import TechnicianModule
|
||||||
@@ -37,6 +38,7 @@ class ModuleList:
|
|||||||
AchievementsModule,
|
AchievementsModule,
|
||||||
ShortRoleNameModule,
|
ShortRoleNameModule,
|
||||||
SteamSpecialOffersModule,
|
SteamSpecialOffersModule,
|
||||||
|
RealmsModule,
|
||||||
# has to be last!
|
# has to be last!
|
||||||
BootLogModule,
|
BootLogModule,
|
||||||
CoreExtensionModule,
|
CoreExtensionModule,
|
||||||
|
@@ -95,6 +95,56 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"modules": {
|
"modules": {
|
||||||
|
"realm": {
|
||||||
|
"list": {
|
||||||
|
"title": "Level:",
|
||||||
|
"description": "Konfigurierte Level:",
|
||||||
|
"realm_names": "Realm-Namen",
|
||||||
|
"error": {
|
||||||
|
"nothing_found": "Keine Einträge gefunden."
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"add": {
|
||||||
|
"error": {
|
||||||
|
"role_exists": "Die Rolle {} existiert bereits.",
|
||||||
|
"category_exists": "Die Kategorie {} existiert bereits.",
|
||||||
|
"realm_exists": "Das Realm {} existiert bereits.",
|
||||||
|
"realm_create": "Fehler beim Erstellen des Realms {}."
|
||||||
|
},
|
||||||
|
"success": "Das Realm {} wurde erfolgreich erstellt."
|
||||||
|
},
|
||||||
|
"edit": {
|
||||||
|
"error": {
|
||||||
|
"realm_not_found": "Das Realm {} wurde nicht gefunden."
|
||||||
|
},
|
||||||
|
"success": "Das Realm {} wurde erfolgreich in {} umbenannt."
|
||||||
|
},
|
||||||
|
"error": {
|
||||||
|
"not_moderator": "Du bist kein Moderator des Realms {}."
|
||||||
|
},
|
||||||
|
"delete": {
|
||||||
|
"error": {
|
||||||
|
"realm_not_found": "Das Realm {} wurde nicht gefunden."
|
||||||
|
},
|
||||||
|
"success": "Das Realm {} wurde erfolgreich gelöscht."
|
||||||
|
},
|
||||||
|
"member": {
|
||||||
|
"add": {
|
||||||
|
"success": "{} wurde erfolgreich zum Realm {} hinzugefügt."
|
||||||
|
},
|
||||||
|
"remove": {
|
||||||
|
"success": "{} wurde erfolgreich aus dem Realm {} entfernt."
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"moderator": {
|
||||||
|
"add": {
|
||||||
|
"success": "{} wurde erfolgreich zum Moderator des Realms {} hinzugefügt."
|
||||||
|
},
|
||||||
|
"remove": {
|
||||||
|
"success": "{} wurde erfolgreich als Moderator des Realms {} entfernt."
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"special_offers": {
|
"special_offers": {
|
||||||
"price": "Preis",
|
"price": "Preis",
|
||||||
"discount": "Rabatt",
|
"discount": "Rabatt",
|
||||||
@@ -236,7 +286,7 @@
|
|||||||
},
|
},
|
||||||
"user": {
|
"user": {
|
||||||
"birthday": {
|
"birthday": {
|
||||||
"has_birthday": "Alles Gute zum Geburtag {} :D",
|
"has_birthday": "Alles Gute zum Geburtstag {} :D",
|
||||||
"success": "Dein Geburtstag wurde eingetragen.",
|
"success": "Dein Geburtstag wurde eingetragen.",
|
||||||
"success_team": "{} hat seinen Geburtstag eingetragen: {}"
|
"success_team": "{} hat seinen Geburtstag eingetragen: {}"
|
||||||
},
|
},
|
||||||
|
@@ -15,7 +15,7 @@ __title__ = "bot_api"
|
|||||||
__author__ = "Sven Heidemann"
|
__author__ = "Sven Heidemann"
|
||||||
__license__ = "MIT"
|
__license__ = "MIT"
|
||||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||||
__version__ = "1.2.7"
|
__version__ = "1.2.11"
|
||||||
|
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
@@ -23,4 +23,4 @@ from collections import namedtuple
|
|||||||
# imports:
|
# imports:
|
||||||
|
|
||||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||||
version_info = VersionInfo(major="1", minor="2", micro="7")
|
version_info = VersionInfo(major="1", minor="2", micro="11")
|
||||||
|
@@ -15,7 +15,7 @@ __title__ = "bot_api.abc"
|
|||||||
__author__ = "Sven Heidemann"
|
__author__ = "Sven Heidemann"
|
||||||
__license__ = "MIT"
|
__license__ = "MIT"
|
||||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||||
__version__ = "1.2.7"
|
__version__ = "1.2.11"
|
||||||
|
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
@@ -23,4 +23,4 @@ from collections import namedtuple
|
|||||||
# imports:
|
# imports:
|
||||||
|
|
||||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||||
version_info = VersionInfo(major="1", minor="2", micro="7")
|
version_info = VersionInfo(major="1", minor="2", micro="11")
|
||||||
|
@@ -4,7 +4,7 @@
|
|||||||
"Version": {
|
"Version": {
|
||||||
"Major": "1",
|
"Major": "1",
|
||||||
"Minor": "2",
|
"Minor": "2",
|
||||||
"Micro": "7"
|
"Micro": "11"
|
||||||
},
|
},
|
||||||
"Author": "",
|
"Author": "",
|
||||||
"AuthorEmail": "",
|
"AuthorEmail": "",
|
||||||
|
@@ -15,7 +15,7 @@ __title__ = "bot_api.configuration"
|
|||||||
__author__ = "Sven Heidemann"
|
__author__ = "Sven Heidemann"
|
||||||
__license__ = "MIT"
|
__license__ = "MIT"
|
||||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||||
__version__ = "1.2.7"
|
__version__ = "1.2.11"
|
||||||
|
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
@@ -23,4 +23,4 @@ from collections import namedtuple
|
|||||||
# imports
|
# imports
|
||||||
|
|
||||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||||
version_info = VersionInfo(major="1", minor="2", micro="7")
|
version_info = VersionInfo(major="1", minor="2", micro="11")
|
||||||
|
@@ -15,7 +15,7 @@ __title__ = "bot_api.controller"
|
|||||||
__author__ = "Sven Heidemann"
|
__author__ = "Sven Heidemann"
|
||||||
__license__ = "MIT"
|
__license__ = "MIT"
|
||||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||||
__version__ = "1.2.7"
|
__version__ = "1.2.11"
|
||||||
|
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
@@ -23,4 +23,4 @@ from collections import namedtuple
|
|||||||
# imports:
|
# imports:
|
||||||
|
|
||||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||||
version_info = VersionInfo(major="1", minor="2", micro="7")
|
version_info = VersionInfo(major="1", minor="2", micro="11")
|
||||||
|
@@ -15,7 +15,7 @@ __title__ = "bot_api.event"
|
|||||||
__author__ = "Sven Heidemann"
|
__author__ = "Sven Heidemann"
|
||||||
__license__ = "MIT"
|
__license__ = "MIT"
|
||||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||||
__version__ = "1.2.7"
|
__version__ = "1.2.11"
|
||||||
|
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
@@ -23,4 +23,4 @@ from collections import namedtuple
|
|||||||
# imports:
|
# imports:
|
||||||
|
|
||||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||||
version_info = VersionInfo(major="1", minor="2", micro="7")
|
version_info = VersionInfo(major="1", minor="2", micro="11")
|
||||||
|
@@ -15,7 +15,7 @@ __title__ = "bot_api.filter"
|
|||||||
__author__ = "Sven Heidemann"
|
__author__ = "Sven Heidemann"
|
||||||
__license__ = "MIT"
|
__license__ = "MIT"
|
||||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||||
__version__ = "1.2.7"
|
__version__ = "1.2.11"
|
||||||
|
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
@@ -23,4 +23,4 @@ from collections import namedtuple
|
|||||||
# imports:
|
# imports:
|
||||||
|
|
||||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||||
version_info = VersionInfo(major="1", minor="2", micro="7")
|
version_info = VersionInfo(major="1", minor="2", micro="11")
|
||||||
|
@@ -15,7 +15,7 @@ __title__ = "bot_api.filter.discord"
|
|||||||
__author__ = "Sven Heidemann"
|
__author__ = "Sven Heidemann"
|
||||||
__license__ = "MIT"
|
__license__ = "MIT"
|
||||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||||
__version__ = "1.2.7"
|
__version__ = "1.2.11"
|
||||||
|
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
@@ -23,4 +23,4 @@ from collections import namedtuple
|
|||||||
# imports:
|
# imports:
|
||||||
|
|
||||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||||
version_info = VersionInfo(major="1", minor="2", micro="7")
|
version_info = VersionInfo(major="1", minor="2", micro="11")
|
||||||
|
@@ -15,7 +15,7 @@ __title__ = "bot_api.logging"
|
|||||||
__author__ = "Sven Heidemann"
|
__author__ = "Sven Heidemann"
|
||||||
__license__ = "MIT"
|
__license__ = "MIT"
|
||||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||||
__version__ = "1.2.7"
|
__version__ = "1.2.11"
|
||||||
|
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
@@ -23,4 +23,4 @@ from collections import namedtuple
|
|||||||
# imports:
|
# imports:
|
||||||
|
|
||||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||||
version_info = VersionInfo(major="1", minor="2", micro="7")
|
version_info = VersionInfo(major="1", minor="2", micro="11")
|
||||||
|
@@ -15,7 +15,7 @@ __title__ = "bot_api.model"
|
|||||||
__author__ = "Sven Heidemann"
|
__author__ = "Sven Heidemann"
|
||||||
__license__ = "MIT"
|
__license__ = "MIT"
|
||||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||||
__version__ = "1.2.7"
|
__version__ = "1.2.11"
|
||||||
|
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
@@ -23,4 +23,4 @@ from collections import namedtuple
|
|||||||
# imports:
|
# imports:
|
||||||
|
|
||||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||||
version_info = VersionInfo(major="1", minor="2", micro="7")
|
version_info = VersionInfo(major="1", minor="2", micro="11")
|
||||||
|
@@ -15,7 +15,7 @@ __title__ = "bot_api.model.discord"
|
|||||||
__author__ = "Sven Heidemann"
|
__author__ = "Sven Heidemann"
|
||||||
__license__ = "MIT"
|
__license__ = "MIT"
|
||||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||||
__version__ = "1.2.7"
|
__version__ = "1.2.11"
|
||||||
|
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
@@ -23,4 +23,4 @@ from collections import namedtuple
|
|||||||
# imports:
|
# imports:
|
||||||
|
|
||||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||||
version_info = VersionInfo(major="1", minor="2", micro="7")
|
version_info = VersionInfo(major="1", minor="2", micro="11")
|
||||||
|
@@ -15,7 +15,7 @@ __title__ = "bot_api.route"
|
|||||||
__author__ = "Sven Heidemann"
|
__author__ = "Sven Heidemann"
|
||||||
__license__ = "MIT"
|
__license__ = "MIT"
|
||||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||||
__version__ = "1.2.7"
|
__version__ = "1.2.11"
|
||||||
|
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
@@ -23,4 +23,4 @@ from collections import namedtuple
|
|||||||
# imports:
|
# imports:
|
||||||
|
|
||||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||||
version_info = VersionInfo(major="1", minor="2", micro="7")
|
version_info = VersionInfo(major="1", minor="2", micro="11")
|
||||||
|
@@ -15,7 +15,7 @@ __title__ = "bot_api.service"
|
|||||||
__author__ = "Sven Heidemann"
|
__author__ = "Sven Heidemann"
|
||||||
__license__ = "MIT"
|
__license__ = "MIT"
|
||||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||||
__version__ = "1.2.7"
|
__version__ = "1.2.11"
|
||||||
|
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
@@ -23,4 +23,4 @@ from collections import namedtuple
|
|||||||
# imports
|
# imports
|
||||||
|
|
||||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||||
version_info = VersionInfo(major="1", minor="2", micro="7")
|
version_info = VersionInfo(major="1", minor="2", micro="11")
|
||||||
|
@@ -15,7 +15,7 @@ __title__ = "bot_api.transformer"
|
|||||||
__author__ = "Sven Heidemann"
|
__author__ = "Sven Heidemann"
|
||||||
__license__ = "MIT"
|
__license__ = "MIT"
|
||||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||||
__version__ = "1.2.7"
|
__version__ = "1.2.11"
|
||||||
|
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
@@ -23,4 +23,4 @@ from collections import namedtuple
|
|||||||
# imports:
|
# imports:
|
||||||
|
|
||||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||||
version_info = VersionInfo(major="1", minor="2", micro="7")
|
version_info = VersionInfo(major="1", minor="2", micro="11")
|
||||||
|
@@ -35,21 +35,37 @@ class AuthUserTransformer(TransformerABC):
|
|||||||
@ServiceProviderABC.inject
|
@ServiceProviderABC.inject
|
||||||
def _is_technician(user: User, bot: DiscordBotServiceABC, permissions: PermissionServiceABC):
|
def _is_technician(user: User, bot: DiscordBotServiceABC, permissions: PermissionServiceABC):
|
||||||
guild = bot.get_guild(user.server.discord_id)
|
guild = bot.get_guild(user.server.discord_id)
|
||||||
|
if guild is None:
|
||||||
|
return permissions.is_member_technician_by_id(user.discord_id)
|
||||||
|
|
||||||
member = guild.get_member(user.discord_id)
|
member = guild.get_member(user.discord_id)
|
||||||
|
if member is None:
|
||||||
|
return permissions.is_member_technician_by_id(user.discord_id)
|
||||||
|
|
||||||
return permissions.is_member_technician(member)
|
return permissions.is_member_technician(member)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@ServiceProviderABC.inject
|
@ServiceProviderABC.inject
|
||||||
def _is_admin(user: User, bot: DiscordBotServiceABC, permissions: PermissionServiceABC):
|
def _is_admin(user: User, bot: DiscordBotServiceABC, permissions: PermissionServiceABC):
|
||||||
guild = bot.get_guild(user.server.discord_id)
|
guild = bot.get_guild(user.server.discord_id)
|
||||||
|
if guild is None:
|
||||||
|
return False
|
||||||
|
|
||||||
member = guild.get_member(user.discord_id)
|
member = guild.get_member(user.discord_id)
|
||||||
|
if member is None:
|
||||||
|
return False
|
||||||
return permissions.is_member_admin(member)
|
return permissions.is_member_admin(member)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@ServiceProviderABC.inject
|
@ServiceProviderABC.inject
|
||||||
def _is_moderator(user: User, bot: DiscordBotServiceABC, permissions: PermissionServiceABC):
|
def _is_moderator(user: User, bot: DiscordBotServiceABC, permissions: PermissionServiceABC):
|
||||||
guild = bot.get_guild(user.server.discord_id)
|
guild = bot.get_guild(user.server.discord_id)
|
||||||
|
if guild is None:
|
||||||
|
return False
|
||||||
|
|
||||||
member = guild.get_member(user.discord_id)
|
member = guild.get_member(user.discord_id)
|
||||||
|
if member is None:
|
||||||
|
return False
|
||||||
return permissions.is_member_moderator(member)
|
return permissions.is_member_moderator(member)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
@@ -15,7 +15,7 @@ __title__ = "bot_core"
|
|||||||
__author__ = "Sven Heidemann"
|
__author__ = "Sven Heidemann"
|
||||||
__license__ = "MIT"
|
__license__ = "MIT"
|
||||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||||
__version__ = "1.2.7"
|
__version__ = "1.2.11"
|
||||||
|
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
@@ -23,4 +23,4 @@ from collections import namedtuple
|
|||||||
# imports
|
# imports
|
||||||
|
|
||||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||||
version_info = VersionInfo(major="1", minor="2", micro="7")
|
version_info = VersionInfo(major="1", minor="2", micro="11")
|
||||||
|
@@ -15,7 +15,7 @@ __title__ = "bot_core.abc"
|
|||||||
__author__ = "Sven Heidemann"
|
__author__ = "Sven Heidemann"
|
||||||
__license__ = "MIT"
|
__license__ = "MIT"
|
||||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||||
__version__ = "1.2.7"
|
__version__ = "1.2.11"
|
||||||
|
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
@@ -23,4 +23,4 @@ from collections import namedtuple
|
|||||||
# imports:
|
# imports:
|
||||||
|
|
||||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||||
version_info = VersionInfo(major="1", minor="2", micro="7")
|
version_info = VersionInfo(major="1", minor="2", micro="11")
|
||||||
|
@@ -19,3 +19,7 @@ class PermissionServiceABC(ABC):
|
|||||||
@abstractmethod
|
@abstractmethod
|
||||||
def is_member_technician(self, member: discord.Member) -> bool:
|
def is_member_technician(self, member: discord.Member) -> bool:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@abstractmethod
|
||||||
|
def is_member_technician_by_id(self, member_id: int) -> bool:
|
||||||
|
pass
|
||||||
|
@@ -4,7 +4,7 @@
|
|||||||
"Version": {
|
"Version": {
|
||||||
"Major": "1",
|
"Major": "1",
|
||||||
"Minor": "2",
|
"Minor": "2",
|
||||||
"Micro": "7"
|
"Micro": "11"
|
||||||
},
|
},
|
||||||
"Author": "Sven Heidemann",
|
"Author": "Sven Heidemann",
|
||||||
"AuthorEmail": "sven.heidemann@sh-edraft.de",
|
"AuthorEmail": "sven.heidemann@sh-edraft.de",
|
||||||
|
@@ -15,7 +15,7 @@ __title__ = "bot_core.configuration"
|
|||||||
__author__ = "Sven Heidemann"
|
__author__ = "Sven Heidemann"
|
||||||
__license__ = "MIT"
|
__license__ = "MIT"
|
||||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||||
__version__ = "1.2.7"
|
__version__ = "1.2.11"
|
||||||
|
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
@@ -23,4 +23,4 @@ from collections import namedtuple
|
|||||||
# imports:
|
# imports:
|
||||||
|
|
||||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||||
version_info = VersionInfo(major="1", minor="2", micro="7")
|
version_info = VersionInfo(major="1", minor="2", micro="11")
|
||||||
|
@@ -17,6 +17,7 @@ class FeatureFlagsEnum(Enum):
|
|||||||
moderator_module = "ModeratorModule"
|
moderator_module = "ModeratorModule"
|
||||||
short_role_name_module = "ShortRoleNameModule"
|
short_role_name_module = "ShortRoleNameModule"
|
||||||
steam_special_offers_module = "SteamSpecialOffersModule"
|
steam_special_offers_module = "SteamSpecialOffersModule"
|
||||||
|
realm_module = "RealmModule"
|
||||||
# features
|
# features
|
||||||
api_only = "ApiOnly"
|
api_only = "ApiOnly"
|
||||||
presence = "Presence"
|
presence = "Presence"
|
||||||
|
@@ -19,6 +19,7 @@ class FeatureFlagsSettings(ConfigurationModelABC):
|
|||||||
FeatureFlagsEnum.config_module.value: True, # 19.07.2023 #127
|
FeatureFlagsEnum.config_module.value: True, # 19.07.2023 #127
|
||||||
FeatureFlagsEnum.short_role_name_module.value: True, # 28.09.2023 #378
|
FeatureFlagsEnum.short_role_name_module.value: True, # 28.09.2023 #378
|
||||||
FeatureFlagsEnum.steam_special_offers_module.value: True, # 11.10.2023 #188
|
FeatureFlagsEnum.steam_special_offers_module.value: True, # 11.10.2023 #188
|
||||||
|
FeatureFlagsEnum.realm_module.value: True, # 07.01.2025 #481
|
||||||
# features
|
# features
|
||||||
FeatureFlagsEnum.api_only.value: False, # 13.10.2022 #70
|
FeatureFlagsEnum.api_only.value: False, # 13.10.2022 #70
|
||||||
FeatureFlagsEnum.presence.value: True, # 03.10.2022 #56
|
FeatureFlagsEnum.presence.value: True, # 03.10.2022 #56
|
||||||
|
@@ -15,7 +15,7 @@ __title__ = "bot_core.core_extension"
|
|||||||
__author__ = "Sven Heidemann"
|
__author__ = "Sven Heidemann"
|
||||||
__license__ = "MIT"
|
__license__ = "MIT"
|
||||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||||
__version__ = "1.2.7"
|
__version__ = "1.2.11"
|
||||||
|
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
@@ -23,4 +23,4 @@ from collections import namedtuple
|
|||||||
# imports:
|
# imports:
|
||||||
|
|
||||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||||
version_info = VersionInfo(major="1", minor="2", micro="7")
|
version_info = VersionInfo(major="1", minor="2", micro="11")
|
||||||
|
@@ -15,7 +15,7 @@ from bot_core.service.client_utils_service import ClientUtilsService
|
|||||||
from bot_core.service.config_service import ConfigService
|
from bot_core.service.config_service import ConfigService
|
||||||
from bot_core.service.data_integrity_service import DataIntegrityService
|
from bot_core.service.data_integrity_service import DataIntegrityService
|
||||||
from bot_core.service.message_service import MessageService
|
from bot_core.service.message_service import MessageService
|
||||||
from bot_core.service.permission_service import PermissionService
|
from bot_core.service.permission_service_with_cache import PermissionServiceWithCache
|
||||||
|
|
||||||
|
|
||||||
class CoreModule(ModuleABC):
|
class CoreModule(ModuleABC):
|
||||||
@@ -30,7 +30,7 @@ class CoreModule(ModuleABC):
|
|||||||
services.add_transient(MessageServiceABC, MessageService)
|
services.add_transient(MessageServiceABC, MessageService)
|
||||||
services.add_transient(ClientUtilsABC, ClientUtilsService)
|
services.add_transient(ClientUtilsABC, ClientUtilsService)
|
||||||
services.add_transient(DataIntegrityService)
|
services.add_transient(DataIntegrityService)
|
||||||
services.add_singleton(PermissionServiceABC, PermissionService)
|
services.add_singleton(PermissionServiceABC, PermissionServiceWithCache)
|
||||||
|
|
||||||
# pipes
|
# pipes
|
||||||
services.add_transient(DateTimeOffsetPipe)
|
services.add_transient(DateTimeOffsetPipe)
|
||||||
|
@@ -15,7 +15,7 @@ __title__ = "bot_core.events"
|
|||||||
__author__ = "Sven Heidemann"
|
__author__ = "Sven Heidemann"
|
||||||
__license__ = "MIT"
|
__license__ = "MIT"
|
||||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||||
__version__ = "1.2.7"
|
__version__ = "1.2.11"
|
||||||
|
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
@@ -23,4 +23,4 @@ from collections import namedtuple
|
|||||||
# imports:
|
# imports:
|
||||||
|
|
||||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||||
version_info = VersionInfo(major="1", minor="2", micro="7")
|
version_info = VersionInfo(major="1", minor="2", micro="11")
|
||||||
|
@@ -15,7 +15,7 @@ __title__ = "bot_core.exception"
|
|||||||
__author__ = "Sven Heidemann"
|
__author__ = "Sven Heidemann"
|
||||||
__license__ = "MIT"
|
__license__ = "MIT"
|
||||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||||
__version__ = "1.2.7"
|
__version__ = "1.2.11"
|
||||||
|
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
@@ -23,4 +23,4 @@ from collections import namedtuple
|
|||||||
# imports:
|
# imports:
|
||||||
|
|
||||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||||
version_info = VersionInfo(major="1", minor="2", micro="7")
|
version_info = VersionInfo(major="1", minor="2", micro="11")
|
||||||
|
@@ -15,7 +15,7 @@ __title__ = "bot_core.helper"
|
|||||||
__author__ = "Sven Heidemann"
|
__author__ = "Sven Heidemann"
|
||||||
__license__ = "MIT"
|
__license__ = "MIT"
|
||||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||||
__version__ = "1.2.7"
|
__version__ = "1.2.11"
|
||||||
|
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
@@ -23,4 +23,4 @@ from collections import namedtuple
|
|||||||
# imports:
|
# imports:
|
||||||
|
|
||||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||||
version_info = VersionInfo(major="1", minor="2", micro="7")
|
version_info = VersionInfo(major="1", minor="2", micro="11")
|
||||||
|
@@ -15,7 +15,7 @@ __title__ = "bot_core.logging"
|
|||||||
__author__ = "Sven Heidemann"
|
__author__ = "Sven Heidemann"
|
||||||
__license__ = "MIT"
|
__license__ = "MIT"
|
||||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||||
__version__ = "1.2.7"
|
__version__ = "1.2.11"
|
||||||
|
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
@@ -23,4 +23,4 @@ from collections import namedtuple
|
|||||||
# imports
|
# imports
|
||||||
|
|
||||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||||
version_info = VersionInfo(major="1", minor="2", micro="7")
|
version_info = VersionInfo(major="1", minor="2", micro="11")
|
||||||
|
@@ -15,7 +15,7 @@ __title__ = "bot_core.pipes"
|
|||||||
__author__ = "Sven Heidemann"
|
__author__ = "Sven Heidemann"
|
||||||
__license__ = "MIT"
|
__license__ = "MIT"
|
||||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||||
__version__ = "1.2.7"
|
__version__ = "1.2.11"
|
||||||
|
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
@@ -23,4 +23,4 @@ from collections import namedtuple
|
|||||||
# imports
|
# imports
|
||||||
|
|
||||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||||
version_info = VersionInfo(major="1", minor="2", micro="7")
|
version_info = VersionInfo(major="1", minor="2", micro="11")
|
||||||
|
@@ -15,7 +15,7 @@ __title__ = "bot_core.service"
|
|||||||
__author__ = "Sven Heidemann"
|
__author__ = "Sven Heidemann"
|
||||||
__license__ = "MIT"
|
__license__ = "MIT"
|
||||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||||
__version__ = "1.2.7"
|
__version__ = "1.2.11"
|
||||||
|
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
@@ -23,4 +23,4 @@ from collections import namedtuple
|
|||||||
# imports:
|
# imports:
|
||||||
|
|
||||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||||
version_info = VersionInfo(major="1", minor="2", micro="7")
|
version_info = VersionInfo(major="1", minor="2", micro="11")
|
||||||
|
@@ -27,6 +27,7 @@ from bot_data.model.user_joined_server import UserJoinedServer
|
|||||||
from bot_data.model.user_joined_voice_channel import UserJoinedVoiceChannel
|
from bot_data.model.user_joined_voice_channel import UserJoinedVoiceChannel
|
||||||
from bot_data.service.user_repository_service import ServerRepositoryABC
|
from bot_data.service.user_repository_service import ServerRepositoryABC
|
||||||
from modules.achievements.achievement_service import AchievementService
|
from modules.achievements.achievement_service import AchievementService
|
||||||
|
from modules.realms.realm_utils import RealmUtils
|
||||||
|
|
||||||
|
|
||||||
class DataIntegrityService:
|
class DataIntegrityService:
|
||||||
@@ -46,6 +47,7 @@ class DataIntegrityService:
|
|||||||
achievement_service: AchievementService,
|
achievement_service: AchievementService,
|
||||||
client_utils: ClientUtilsABC,
|
client_utils: ClientUtilsABC,
|
||||||
dtp: DateTimeOffsetPipe,
|
dtp: DateTimeOffsetPipe,
|
||||||
|
ream_utils: RealmUtils,
|
||||||
):
|
):
|
||||||
self._config = config
|
self._config = config
|
||||||
|
|
||||||
@@ -62,6 +64,7 @@ class DataIntegrityService:
|
|||||||
self._achievements = achievement_service
|
self._achievements = achievement_service
|
||||||
self._client_utils = client_utils
|
self._client_utils = client_utils
|
||||||
self._dtp = dtp
|
self._dtp = dtp
|
||||||
|
self._realm_utils = ream_utils
|
||||||
|
|
||||||
self._is_for_shutdown = False
|
self._is_for_shutdown = False
|
||||||
|
|
||||||
@@ -96,6 +99,9 @@ class DataIntegrityService:
|
|||||||
self._logger.debug(__name__, f"Start check for user got achievements: {g.id}@{m.id}")
|
self._logger.debug(__name__, f"Start check for user got achievements: {g.id}@{m.id}")
|
||||||
await self._check_for_user_achievements(u)
|
await self._check_for_user_achievements(u)
|
||||||
|
|
||||||
|
self._logger.debug(__name__, f"Start check for user got achievements: {g.id}@{m.id}")
|
||||||
|
await self._realm_utils.check_integrity(s, g)
|
||||||
|
|
||||||
for m in [m for m in g.members if m.bot]:
|
for m in [m for m in g.members if m.bot]:
|
||||||
u = self._users.find_user_by_discord_id_and_server_id(m.id, s.id)
|
u = self._users.find_user_by_discord_id_and_server_id(m.id, s.id)
|
||||||
if u is None:
|
if u is None:
|
||||||
|
@@ -5,14 +5,14 @@ from cpl_core.configuration import ConfigurationABC
|
|||||||
from cpl_core.logging import LoggerABC
|
from cpl_core.logging import LoggerABC
|
||||||
from cpl_discord.service import DiscordBotServiceABC
|
from cpl_discord.service import DiscordBotServiceABC
|
||||||
|
|
||||||
|
from bot_core.abc.permission_service_abc import PermissionServiceABC
|
||||||
from bot_data.abc.server_config_repository_abc import ServerConfigRepositoryABC
|
from bot_data.abc.server_config_repository_abc import ServerConfigRepositoryABC
|
||||||
from bot_data.abc.server_repository_abc import ServerRepositoryABC
|
from bot_data.abc.server_repository_abc import ServerRepositoryABC
|
||||||
from bot_data.abc.technician_config_repository_abc import TechnicianConfigRepositoryABC
|
from bot_data.abc.technician_config_repository_abc import TechnicianConfigRepositoryABC
|
||||||
from bot_data.model.team_member_type_enum import TeamMemberTypeEnum
|
from bot_data.model.team_member_type_enum import TeamMemberTypeEnum
|
||||||
from bot_core.abc.permission_service_abc import PermissionServiceABC
|
|
||||||
|
|
||||||
|
|
||||||
class PermissionService(PermissionServiceABC):
|
class PermissionServiceWithCache(PermissionServiceABC):
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
logger: LoggerABC,
|
logger: LoggerABC,
|
||||||
@@ -112,3 +112,18 @@ class PermissionService(PermissionServiceABC):
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
self._logger.error(__name__, "Permission check failed", e)
|
self._logger.error(__name__, "Permission check failed", e)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
def is_member_technician_by_id(self, member_id: int):
|
||||||
|
has_permission_cached = self.get_cached_permission(member_id, TeamMemberTypeEnum.technician)
|
||||||
|
if has_permission_cached is not None:
|
||||||
|
return has_permission_cached
|
||||||
|
|
||||||
|
self._logger.debug(__name__, f"Checking is member {member_id} technician")
|
||||||
|
|
||||||
|
try:
|
||||||
|
has_permission = member_id in self._technician_configs.get_technician_config().technician_ids
|
||||||
|
self.set_cached_permission(has_permission, member_id, TeamMemberTypeEnum.technician)
|
||||||
|
return has_permission
|
||||||
|
except Exception as e:
|
||||||
|
self._logger.error(__name__, "Permission check failed", e)
|
||||||
|
return False
|
@@ -15,7 +15,7 @@ __title__ = "bot_data"
|
|||||||
__author__ = "Sven Heidemann"
|
__author__ = "Sven Heidemann"
|
||||||
__license__ = "MIT"
|
__license__ = "MIT"
|
||||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||||
__version__ = "1.2.7"
|
__version__ = "1.2.11"
|
||||||
|
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
@@ -23,4 +23,4 @@ from collections import namedtuple
|
|||||||
# imports
|
# imports
|
||||||
|
|
||||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||||
version_info = VersionInfo(major="1", minor="2", micro="7")
|
version_info = VersionInfo(major="1", minor="2", micro="11")
|
||||||
|
@@ -15,7 +15,7 @@ __title__ = "bot_data.abc"
|
|||||||
__author__ = "Sven Heidemann"
|
__author__ = "Sven Heidemann"
|
||||||
__license__ = "MIT"
|
__license__ = "MIT"
|
||||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||||
__version__ = "1.2.7"
|
__version__ = "1.2.11"
|
||||||
|
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
@@ -23,4 +23,4 @@ from collections import namedtuple
|
|||||||
# imports
|
# imports
|
||||||
|
|
||||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||||
version_info = VersionInfo(major="1", minor="2", micro="7")
|
version_info = VersionInfo(major="1", minor="2", micro="11")
|
||||||
|
69
bot/src/bot_data/abc/realm_repository_abc.py
Normal file
69
bot/src/bot_data/abc/realm_repository_abc.py
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
from abc import ABC, abstractmethod
|
||||||
|
from typing import Optional
|
||||||
|
|
||||||
|
from cpl_query.extension import List
|
||||||
|
|
||||||
|
from bot_data.model.realm import Realm
|
||||||
|
from bot_data.model.realm_moderator import RealmModerator
|
||||||
|
|
||||||
|
|
||||||
|
class RealmRepositoryABC(ABC):
|
||||||
|
@abstractmethod
|
||||||
|
def __init__(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
@abstractmethod
|
||||||
|
def get_all(self) -> List[Realm]:
|
||||||
|
pass
|
||||||
|
|
||||||
|
@abstractmethod
|
||||||
|
def get_realm_by_id(self, id: int) -> Realm:
|
||||||
|
pass
|
||||||
|
|
||||||
|
@abstractmethod
|
||||||
|
def find_realm_by_id(self, id: int) -> Optional[Realm]:
|
||||||
|
pass
|
||||||
|
|
||||||
|
@abstractmethod
|
||||||
|
def find_realm_by_name(self, name: str) -> Optional[Realm]:
|
||||||
|
pass
|
||||||
|
|
||||||
|
@abstractmethod
|
||||||
|
def get_realms_by_server_id(self, id: int) -> List[Realm]:
|
||||||
|
pass
|
||||||
|
|
||||||
|
@abstractmethod
|
||||||
|
def add_realm(self, realm: Realm):
|
||||||
|
pass
|
||||||
|
|
||||||
|
@abstractmethod
|
||||||
|
def update_realm(self, realm: Realm):
|
||||||
|
pass
|
||||||
|
|
||||||
|
@abstractmethod
|
||||||
|
def delete_realm(self, realm: Realm):
|
||||||
|
pass
|
||||||
|
|
||||||
|
@abstractmethod
|
||||||
|
def get_realm_moderators(self) -> List[RealmModerator]:
|
||||||
|
pass
|
||||||
|
|
||||||
|
@abstractmethod
|
||||||
|
def get_realm_moderator_by_id(self, id: int) -> RealmModerator:
|
||||||
|
pass
|
||||||
|
|
||||||
|
@abstractmethod
|
||||||
|
def get_realm_moderators_by_realm_id(self, id: int) -> List[RealmModerator]:
|
||||||
|
pass
|
||||||
|
|
||||||
|
@abstractmethod
|
||||||
|
def add_realm_moderator(self, realm: RealmModerator):
|
||||||
|
pass
|
||||||
|
|
||||||
|
@abstractmethod
|
||||||
|
def update_realm_moderator(self, realm: RealmModerator):
|
||||||
|
pass
|
||||||
|
|
||||||
|
@abstractmethod
|
||||||
|
def delete_realm_moderator(self, realm: RealmModerator):
|
||||||
|
pass
|
@@ -4,7 +4,7 @@
|
|||||||
"Version": {
|
"Version": {
|
||||||
"Major": "1",
|
"Major": "1",
|
||||||
"Minor": "2",
|
"Minor": "2",
|
||||||
"Micro": "7"
|
"Micro": "11"
|
||||||
},
|
},
|
||||||
"Author": "Sven Heidemann",
|
"Author": "Sven Heidemann",
|
||||||
"AuthorEmail": "sven.heidemann@sh-edraft.de",
|
"AuthorEmail": "sven.heidemann@sh-edraft.de",
|
||||||
|
@@ -14,6 +14,7 @@ from bot_data.abc.data_seeder_abc import DataSeederABC
|
|||||||
from bot_data.abc.game_server_repository_abc import GameServerRepositoryABC
|
from bot_data.abc.game_server_repository_abc import GameServerRepositoryABC
|
||||||
from bot_data.abc.known_user_repository_abc import KnownUserRepositoryABC
|
from bot_data.abc.known_user_repository_abc import KnownUserRepositoryABC
|
||||||
from bot_data.abc.level_repository_abc import LevelRepositoryABC
|
from bot_data.abc.level_repository_abc import LevelRepositoryABC
|
||||||
|
from bot_data.abc.realm_repository_abc import RealmRepositoryABC
|
||||||
from bot_data.abc.scheduled_event_repository_abc import ScheduledEventRepositoryABC
|
from bot_data.abc.scheduled_event_repository_abc import ScheduledEventRepositoryABC
|
||||||
from bot_data.abc.server_config_repository_abc import ServerConfigRepositoryABC
|
from bot_data.abc.server_config_repository_abc import ServerConfigRepositoryABC
|
||||||
from bot_data.abc.server_repository_abc import ServerRepositoryABC
|
from bot_data.abc.server_repository_abc import ServerRepositoryABC
|
||||||
@@ -46,6 +47,7 @@ from bot_data.service.client_repository_service import ClientRepositoryService
|
|||||||
from bot_data.service.game_server_repository_service import GameServerRepositoryService
|
from bot_data.service.game_server_repository_service import GameServerRepositoryService
|
||||||
from bot_data.service.known_user_repository_service import KnownUserRepositoryService
|
from bot_data.service.known_user_repository_service import KnownUserRepositoryService
|
||||||
from bot_data.service.level_repository_service import LevelRepositoryService
|
from bot_data.service.level_repository_service import LevelRepositoryService
|
||||||
|
from bot_data.service.realm_repository_service import RealmRepositoryService
|
||||||
from bot_data.service.scheduled_event_repository_service import ScheduledEventRepositoryService
|
from bot_data.service.scheduled_event_repository_service import ScheduledEventRepositoryService
|
||||||
from bot_data.service.seeder_service import SeederService
|
from bot_data.service.seeder_service import SeederService
|
||||||
from bot_data.service.server_config_repository_service import (
|
from bot_data.service.server_config_repository_service import (
|
||||||
@@ -118,6 +120,7 @@ class DataModule(ModuleABC):
|
|||||||
services.add_transient(ShortRoleNameRepositoryABC, ShortRoleNameRepositoryService)
|
services.add_transient(ShortRoleNameRepositoryABC, ShortRoleNameRepositoryService)
|
||||||
services.add_transient(SteamSpecialOfferRepositoryABC, SteamSpecialOfferRepositoryService)
|
services.add_transient(SteamSpecialOfferRepositoryABC, SteamSpecialOfferRepositoryService)
|
||||||
services.add_transient(ScheduledEventRepositoryABC, ScheduledEventRepositoryService)
|
services.add_transient(ScheduledEventRepositoryABC, ScheduledEventRepositoryService)
|
||||||
|
services.add_transient(RealmRepositoryABC, RealmRepositoryService)
|
||||||
|
|
||||||
services.add_transient(SeederService)
|
services.add_transient(SeederService)
|
||||||
services.add_transient(DataSeederABC, TechnicianConfigSeeder)
|
services.add_transient(DataSeederABC, TechnicianConfigSeeder)
|
||||||
|
50
bot/src/bot_data/db_connection.py
Normal file
50
bot/src/bot_data/db_connection.py
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
from typing import Optional
|
||||||
|
|
||||||
|
from cpl_core.database import DatabaseSettings
|
||||||
|
from cpl_core.database.connection import DatabaseConnectionABC
|
||||||
|
from mysql.connector.abstracts import MySQLConnectionAbstract
|
||||||
|
from mysql.connector.cursor import MySQLCursorBuffered
|
||||||
|
|
||||||
|
|
||||||
|
class DBConnection(DatabaseConnectionABC):
|
||||||
|
def __init__(self):
|
||||||
|
DatabaseConnectionABC.__init__(self)
|
||||||
|
|
||||||
|
self._database: Optional[MySQLConnectionAbstract] = None
|
||||||
|
self._cursor: Optional[MySQLCursorBuffered] = None
|
||||||
|
|
||||||
|
@property
|
||||||
|
def server(self) -> MySQLConnectionAbstract:
|
||||||
|
return self._database
|
||||||
|
|
||||||
|
@property
|
||||||
|
def cursor(self) -> MySQLCursorBuffered:
|
||||||
|
return self._cursor
|
||||||
|
|
||||||
|
def connect(self, settings: DatabaseSettings):
|
||||||
|
# connection = sql.connect(
|
||||||
|
# host=settings.host,
|
||||||
|
# port=settings.port,
|
||||||
|
# user=settings.user,
|
||||||
|
# passwd=CredentialManager.decrypt(settings.password),
|
||||||
|
# charset=settings.charset,
|
||||||
|
# use_unicode=settings.use_unicode,
|
||||||
|
# buffered=settings.buffered,
|
||||||
|
# auth_plugin=settings.auth_plugin,
|
||||||
|
# ssl_disabled=settings.ssl_disabled,
|
||||||
|
# )
|
||||||
|
# connection.cursor().execute(f"CREATE DATABASE IF NOT EXISTS `{settings.database}`;")
|
||||||
|
# self._database = sql.connect(
|
||||||
|
# host=settings.host,
|
||||||
|
# port=settings.port,
|
||||||
|
# user=settings.user,
|
||||||
|
# passwd=CredentialManager.decrypt(settings.password),
|
||||||
|
# db=settings.database,
|
||||||
|
# charset=settings.charset,
|
||||||
|
# use_unicode=settings.use_unicode,
|
||||||
|
# buffered=settings.buffered,
|
||||||
|
# auth_plugin=settings.auth_plugin,
|
||||||
|
# ssl_disabled=settings.ssl_disabled,
|
||||||
|
# )
|
||||||
|
self._
|
||||||
|
self._cursor = self._database.cursor()
|
@@ -1,4 +1,3 @@
|
|||||||
import time
|
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
from cpl_core.database import DatabaseSettings
|
from cpl_core.database import DatabaseSettings
|
||||||
@@ -7,6 +6,7 @@ from cpl_core.database.context import DatabaseContext
|
|||||||
from bot_core.exception.service_error_code_enum import ServiceErrorCode
|
from bot_core.exception.service_error_code_enum import ServiceErrorCode
|
||||||
from bot_core.exception.service_exception import ServiceException
|
from bot_core.exception.service_exception import ServiceException
|
||||||
from bot_core.logging.database_logger import DatabaseLogger
|
from bot_core.logging.database_logger import DatabaseLogger
|
||||||
|
from bot_data.mysql_pool import MySQLPool
|
||||||
|
|
||||||
|
|
||||||
class DBContext(DatabaseContext):
|
class DBContext(DatabaseContext):
|
||||||
@@ -14,27 +14,28 @@ class DBContext(DatabaseContext):
|
|||||||
self._logger = logger
|
self._logger = logger
|
||||||
|
|
||||||
DatabaseContext.__init__(self)
|
DatabaseContext.__init__(self)
|
||||||
|
self._pool: MySQLPool = None
|
||||||
self._fails = 0
|
self._fails = 0
|
||||||
|
|
||||||
def connect(self, database_settings: DatabaseSettings):
|
def connect(self, database_settings: DatabaseSettings):
|
||||||
try:
|
try:
|
||||||
self._logger.debug(__name__, "Connecting to database")
|
self._logger.debug(__name__, "Connecting to database")
|
||||||
self._db.connect(database_settings)
|
self._pool = MySQLPool(database_settings)
|
||||||
|
self._pool.execute(f"CREATE DATABASE IF NOT EXISTS `{database_settings.database}`;", commit=True)
|
||||||
self._logger.info(__name__, "Connected to database")
|
self._logger.info(__name__, "Connected to database")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self._logger.fatal(__name__, "Connecting to database failed", e)
|
self._logger.fatal(__name__, "Connecting to database failed", e)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def cursor(self):
|
||||||
|
return self
|
||||||
|
|
||||||
def save_changes(self):
|
def save_changes(self):
|
||||||
try:
|
pass
|
||||||
self._logger.trace(__name__, "Save changes")
|
|
||||||
super(DBContext, self).save_changes()
|
|
||||||
self._logger.debug(__name__, "Saved changes")
|
|
||||||
except Exception as e:
|
|
||||||
self._logger.error(__name__, "Saving changes failed", e)
|
|
||||||
|
|
||||||
def select(self, statement: str) -> list[tuple]:
|
def select(self, statement: str) -> list[tuple]:
|
||||||
try:
|
try:
|
||||||
return super(DBContext, self).select(statement)
|
return self._pool.execute(statement)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
if self._fails >= 3:
|
if self._fails >= 3:
|
||||||
self._logger.error(__name__, f"Database error caused by {statement}", e)
|
self._logger.error(__name__, f"Database error caused by {statement}", e)
|
||||||
@@ -47,9 +48,11 @@ class DBContext(DatabaseContext):
|
|||||||
self._logger.error(__name__, f"Database error caused by {statement}", e)
|
self._logger.error(__name__, f"Database error caused by {statement}", e)
|
||||||
self._fails += 1
|
self._fails += 1
|
||||||
try:
|
try:
|
||||||
time.sleep(0.5)
|
|
||||||
self._logger.debug(__name__, "Retry select")
|
self._logger.debug(__name__, "Retry select")
|
||||||
return self.select(statement)
|
return self.select(statement)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
pass
|
pass
|
||||||
return []
|
return []
|
||||||
|
|
||||||
|
def execute(self, statement: str):
|
||||||
|
return self._pool.execute(statement, commit=True)
|
||||||
|
@@ -15,7 +15,7 @@ __title__ = "bot_data.model"
|
|||||||
__author__ = "Sven Heidemann"
|
__author__ = "Sven Heidemann"
|
||||||
__license__ = "MIT"
|
__license__ = "MIT"
|
||||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||||
__version__ = "1.2.7"
|
__version__ = "1.2.11"
|
||||||
|
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
@@ -23,4 +23,4 @@ from collections import namedtuple
|
|||||||
# imports
|
# imports
|
||||||
|
|
||||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||||
version_info = VersionInfo(major="1", minor="2", micro="7")
|
version_info = VersionInfo(major="1", minor="2", micro="11")
|
||||||
|
@@ -1,4 +1,5 @@
|
|||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
from typing import Optional
|
||||||
|
|
||||||
from cpl_core.database import TableABC
|
from cpl_core.database import TableABC
|
||||||
from cpl_core.dependency_injection import ServiceProviderABC
|
from cpl_core.dependency_injection import ServiceProviderABC
|
||||||
@@ -48,8 +49,10 @@ class AutoRoleRule(TableABC):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
@ServiceProviderABC.inject
|
@ServiceProviderABC.inject
|
||||||
def role_name(self, bot: DiscordBotServiceABC) -> str:
|
def role_name(self, bot: DiscordBotServiceABC) -> Optional[str]:
|
||||||
guild = bot.get_guild(self.auto_role.server.discord_id)
|
guild = bot.get_guild(self.auto_role.server.discord_id)
|
||||||
|
if guild is None:
|
||||||
|
return None
|
||||||
return guild.get_role(self.role_id).name
|
return guild.get_role(self.role_id).name
|
||||||
|
|
||||||
@role_id.setter
|
@role_id.setter
|
||||||
|
@@ -1,3 +1,5 @@
|
|||||||
|
from typing import Optional
|
||||||
|
|
||||||
from cpl_core.dependency_injection import ServiceProviderABC
|
from cpl_core.dependency_injection import ServiceProviderABC
|
||||||
from cpl_discord.service import DiscordBotServiceABC
|
from cpl_discord.service import DiscordBotServiceABC
|
||||||
|
|
||||||
@@ -43,6 +45,8 @@ class AutoRoleRuleHistory(HistoryTableABC):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
@ServiceProviderABC.inject
|
@ServiceProviderABC.inject
|
||||||
def role_name(self, bot: DiscordBotServiceABC) -> str:
|
def role_name(self, bot: DiscordBotServiceABC) -> Optional[str]:
|
||||||
guild = bot.get_guild(self.auto_role.server.discord_id)
|
guild = bot.get_guild(self.auto_role.server.discord_id)
|
||||||
|
if guild is None:
|
||||||
|
return None
|
||||||
return guild.get_role(self.role_id).name
|
return guild.get_role(self.role_id).name
|
||||||
|
@@ -39,8 +39,10 @@ class Level(TableABC):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
@ServiceProviderABC.inject
|
@ServiceProviderABC.inject
|
||||||
def icon_url(self, bot: DiscordBotServiceABC) -> str:
|
def icon_url(self, bot: DiscordBotServiceABC) -> Optional[str]:
|
||||||
guild = bot.get_guild(self.server.discord_id)
|
guild = bot.get_guild(self.server.discord_id)
|
||||||
|
if guild is None:
|
||||||
|
return None
|
||||||
role = List(Role, guild.roles).where(lambda x: x.name == self._name).first_or_default()
|
role = List(Role, guild.roles).where(lambda x: x.name == self._name).first_or_default()
|
||||||
return None if role is None else role.icon
|
return None if role is None else role.icon
|
||||||
|
|
||||||
|
120
bot/src/bot_data/model/realm.py
Normal file
120
bot/src/bot_data/model/realm.py
Normal file
@@ -0,0 +1,120 @@
|
|||||||
|
from datetime import datetime
|
||||||
|
from typing import Optional
|
||||||
|
|
||||||
|
from cpl_core.database import TableABC
|
||||||
|
|
||||||
|
from bot_data.model.server import Server
|
||||||
|
|
||||||
|
|
||||||
|
class Realm(TableABC):
|
||||||
|
def __init__(
|
||||||
|
self,
|
||||||
|
name: str,
|
||||||
|
role_id: int,
|
||||||
|
server: Optional[Server],
|
||||||
|
created_at: datetime = None,
|
||||||
|
modified_at: datetime = None,
|
||||||
|
id=0,
|
||||||
|
):
|
||||||
|
self._id = id
|
||||||
|
self._name = name.replace("'", "")
|
||||||
|
self._role_id = role_id
|
||||||
|
self._server = server
|
||||||
|
|
||||||
|
TableABC.__init__(self)
|
||||||
|
self._created_at = created_at if created_at is not None else self._created_at
|
||||||
|
self._modified_at = modified_at if modified_at is not None else self._modified_at
|
||||||
|
|
||||||
|
@property
|
||||||
|
def id(self) -> int:
|
||||||
|
return self._id
|
||||||
|
|
||||||
|
@property
|
||||||
|
def name(self) -> str:
|
||||||
|
return self._name.replace("'", "")
|
||||||
|
|
||||||
|
@name.setter
|
||||||
|
def name(self, value: str):
|
||||||
|
self._name = value.replace("'", "")
|
||||||
|
|
||||||
|
@property
|
||||||
|
def role_id(self) -> int:
|
||||||
|
return self._role_id
|
||||||
|
|
||||||
|
@role_id.setter
|
||||||
|
def role_id(self, value: int):
|
||||||
|
self._role_id = value
|
||||||
|
|
||||||
|
@property
|
||||||
|
def server(self) -> Server:
|
||||||
|
return self._server
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def get_select_all_string() -> str:
|
||||||
|
return str(
|
||||||
|
f"""
|
||||||
|
SELECT * FROM `Realms`;
|
||||||
|
"""
|
||||||
|
)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def get_select_by_id_string(id: int) -> str:
|
||||||
|
return str(
|
||||||
|
f"""
|
||||||
|
SELECT * FROM `Realms`
|
||||||
|
WHERE `RealmId` = {id};
|
||||||
|
"""
|
||||||
|
)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def get_select_by_server_id_string(id: int) -> str:
|
||||||
|
return str(
|
||||||
|
f"""
|
||||||
|
SELECT * FROM `Realms`
|
||||||
|
WHERE `ServerId` = {id};
|
||||||
|
"""
|
||||||
|
)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def get_select_by_name_string(name: str) -> str:
|
||||||
|
return str(
|
||||||
|
f"""
|
||||||
|
SELECT * FROM `Realms`
|
||||||
|
WHERE `Name` = '{name}';
|
||||||
|
"""
|
||||||
|
)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def insert_string(self) -> str:
|
||||||
|
return str(
|
||||||
|
f"""
|
||||||
|
INSERT INTO `Realms` (
|
||||||
|
`ServerId`, `Name`, `RoleId`
|
||||||
|
) VALUES (
|
||||||
|
{self._server.id},
|
||||||
|
'{self._name}',
|
||||||
|
{self._role_id}
|
||||||
|
);
|
||||||
|
"""
|
||||||
|
)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def udpate_string(self) -> str:
|
||||||
|
return str(
|
||||||
|
f"""
|
||||||
|
UPDATE `Realms`
|
||||||
|
SET `ServerId` = {self._server.id},
|
||||||
|
`Name` = '{self._name}',
|
||||||
|
`RoleId` = {self._role_id}
|
||||||
|
WHERE `RealmId` = {self._id};
|
||||||
|
"""
|
||||||
|
)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def delete_string(self) -> str:
|
||||||
|
return str(
|
||||||
|
f"""
|
||||||
|
DELETE FROM `Realms`
|
||||||
|
WHERE `RealmId` = {self._id};
|
||||||
|
"""
|
||||||
|
)
|
43
bot/src/bot_data/model/realm_history.py
Normal file
43
bot/src/bot_data/model/realm_history.py
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
from typing import Optional
|
||||||
|
|
||||||
|
from bot_data.abc.history_table_abc import HistoryTableABC
|
||||||
|
from bot_data.model.server import Server
|
||||||
|
|
||||||
|
|
||||||
|
class Realm(HistoryTableABC):
|
||||||
|
def __init__(
|
||||||
|
self,
|
||||||
|
server: Optional[Server],
|
||||||
|
name: str,
|
||||||
|
role_id: int,
|
||||||
|
deleted: bool,
|
||||||
|
date_from: str,
|
||||||
|
date_to: str,
|
||||||
|
id=0,
|
||||||
|
):
|
||||||
|
HistoryTableABC.__init__(self)
|
||||||
|
|
||||||
|
self._id = id
|
||||||
|
self._server = server
|
||||||
|
self._name = name
|
||||||
|
self._role_id = role_id
|
||||||
|
|
||||||
|
self._deleted = deleted
|
||||||
|
self._date_from = date_from
|
||||||
|
self._date_to = date_to
|
||||||
|
|
||||||
|
@property
|
||||||
|
def id(self) -> int:
|
||||||
|
return self._id
|
||||||
|
|
||||||
|
@property
|
||||||
|
def server(self) -> Server:
|
||||||
|
return self._server
|
||||||
|
|
||||||
|
@property
|
||||||
|
def name(self) -> str:
|
||||||
|
return self._name
|
||||||
|
|
||||||
|
@property
|
||||||
|
def role_id(self) -> int:
|
||||||
|
return self._role_id
|
106
bot/src/bot_data/model/realm_moderator.py
Normal file
106
bot/src/bot_data/model/realm_moderator.py
Normal file
@@ -0,0 +1,106 @@
|
|||||||
|
from datetime import datetime
|
||||||
|
|
||||||
|
from cpl_core.database import TableABC
|
||||||
|
|
||||||
|
from bot_data.model.realm import Realm
|
||||||
|
from bot_data.model.user import User
|
||||||
|
|
||||||
|
|
||||||
|
class RealmModerator(TableABC):
|
||||||
|
def __init__(
|
||||||
|
self,
|
||||||
|
realm: Realm,
|
||||||
|
user: User,
|
||||||
|
created_at: datetime = None,
|
||||||
|
modified_at: datetime = None,
|
||||||
|
id=0,
|
||||||
|
):
|
||||||
|
self._join_id = id
|
||||||
|
self._realm = realm
|
||||||
|
self._user = user
|
||||||
|
|
||||||
|
TableABC.__init__(self)
|
||||||
|
self._created_at = created_at if created_at is not None else self._created_at
|
||||||
|
self._modified_at = modified_at if modified_at is not None else self._modified_at
|
||||||
|
|
||||||
|
@property
|
||||||
|
def id(self) -> int:
|
||||||
|
return self._join_id
|
||||||
|
|
||||||
|
@property
|
||||||
|
def realm(self) -> Realm:
|
||||||
|
return self._realm
|
||||||
|
|
||||||
|
@property
|
||||||
|
def user(self) -> User:
|
||||||
|
return self._user
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def get_select_all_string() -> str:
|
||||||
|
return str(
|
||||||
|
f"""
|
||||||
|
SELECT * FROM `RealmModerators`;
|
||||||
|
"""
|
||||||
|
)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def get_select_by_id_string(id: int) -> str:
|
||||||
|
return str(
|
||||||
|
f"""
|
||||||
|
SELECT * FROM `RealmModerators`
|
||||||
|
WHERE `Id` = {id};
|
||||||
|
"""
|
||||||
|
)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def get_select_by_realm_id_string(id: int) -> str:
|
||||||
|
return str(
|
||||||
|
f"""
|
||||||
|
SELECT * FROM `RealmModerators`
|
||||||
|
WHERE `RealmId` = {id};
|
||||||
|
"""
|
||||||
|
)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def get_select_by_user_id_string(id: int) -> str:
|
||||||
|
return str(
|
||||||
|
f"""
|
||||||
|
SELECT * FROM `RealmModerators`
|
||||||
|
WHERE `UserId` = {id};
|
||||||
|
"""
|
||||||
|
)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def insert_string(self) -> str:
|
||||||
|
return str(
|
||||||
|
f"""
|
||||||
|
INSERT INTO `RealmModerators` (
|
||||||
|
`UserId`, `RealmId`
|
||||||
|
) VALUES (
|
||||||
|
{self._user.id},
|
||||||
|
{self._realm.id}
|
||||||
|
);
|
||||||
|
"""
|
||||||
|
)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def udpate_string(self) -> str:
|
||||||
|
return str(f"""""")
|
||||||
|
|
||||||
|
@property
|
||||||
|
def delete_string(self) -> str:
|
||||||
|
return str(
|
||||||
|
f"""
|
||||||
|
DELETE FROM `RealmModerators`
|
||||||
|
WHERE `Id` = {self._join_id};
|
||||||
|
"""
|
||||||
|
)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def delete_by_user_id_string(id: int) -> str:
|
||||||
|
return str(
|
||||||
|
f"""
|
||||||
|
DELETE FROM `RealmModerators`
|
||||||
|
WHERE `UserId` = {id}
|
||||||
|
"""
|
||||||
|
)
|
36
bot/src/bot_data/model/realm_moderator_history.py
Normal file
36
bot/src/bot_data/model/realm_moderator_history.py
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
from bot_data.abc.history_table_abc import HistoryTableABC
|
||||||
|
from bot_data.model.realm import Realm
|
||||||
|
from bot_data.model.user import User
|
||||||
|
|
||||||
|
|
||||||
|
class RealmModerator(HistoryTableABC):
|
||||||
|
def __init__(
|
||||||
|
self,
|
||||||
|
realm: Realm,
|
||||||
|
user: User,
|
||||||
|
deleted: bool,
|
||||||
|
date_from: str,
|
||||||
|
date_to: str,
|
||||||
|
id=0,
|
||||||
|
):
|
||||||
|
HistoryTableABC.__init__(self)
|
||||||
|
|
||||||
|
self._join_id = id
|
||||||
|
self._realm = realm
|
||||||
|
self._user = user
|
||||||
|
|
||||||
|
self._deleted = deleted
|
||||||
|
self._date_from = date_from
|
||||||
|
self._date_to = date_to
|
||||||
|
|
||||||
|
@property
|
||||||
|
def id(self) -> int:
|
||||||
|
return self._join_id
|
||||||
|
|
||||||
|
@property
|
||||||
|
def realm(self) -> Realm:
|
||||||
|
return self._realm
|
||||||
|
|
||||||
|
@property
|
||||||
|
def user(self) -> User:
|
||||||
|
return self._user
|
@@ -1,4 +1,5 @@
|
|||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
from typing import Optional
|
||||||
|
|
||||||
from cpl_core.database import TableABC
|
from cpl_core.database import TableABC
|
||||||
from cpl_core.dependency_injection import ServiceProviderABC
|
from cpl_core.dependency_injection import ServiceProviderABC
|
||||||
@@ -30,14 +31,18 @@ class Server(TableABC):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
@ServiceProviderABC.inject
|
@ServiceProviderABC.inject
|
||||||
def name(self, bot: DiscordBotServiceABC) -> str:
|
def name(self, bot: DiscordBotServiceABC) -> Optional[str]:
|
||||||
guild = bot.get_guild(self.discord_id)
|
guild = bot.get_guild(self.discord_id)
|
||||||
|
if guild is None:
|
||||||
|
return None
|
||||||
return None if guild is None else guild.name
|
return None if guild is None else guild.name
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@ServiceProviderABC.inject
|
@ServiceProviderABC.inject
|
||||||
def icon_url(self, bot: DiscordBotServiceABC) -> str:
|
def icon_url(self, bot: DiscordBotServiceABC) -> Optional[str]:
|
||||||
guild = bot.get_guild(self.discord_id)
|
guild = bot.get_guild(self.discord_id)
|
||||||
|
if guild is None:
|
||||||
|
return None
|
||||||
return None if guild is None else guild.icon.url
|
return None if guild is None else guild.icon.url
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
@@ -1,3 +1,5 @@
|
|||||||
|
from typing import Optional
|
||||||
|
|
||||||
from cpl_core.dependency_injection import ServiceProviderABC
|
from cpl_core.dependency_injection import ServiceProviderABC
|
||||||
from cpl_discord.service import DiscordBotServiceABC
|
from cpl_discord.service import DiscordBotServiceABC
|
||||||
|
|
||||||
@@ -32,12 +34,16 @@ class ServerHistory(HistoryTableABC):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
@ServiceProviderABC.inject
|
@ServiceProviderABC.inject
|
||||||
def name(self, bot: DiscordBotServiceABC) -> str:
|
def name(self, bot: DiscordBotServiceABC) -> Optional[str]:
|
||||||
guild = bot.get_guild(self.discord_id)
|
guild = bot.get_guild(self.discord_id)
|
||||||
|
if guild is None:
|
||||||
|
return None
|
||||||
return None if guild is None else guild.name
|
return None if guild is None else guild.name
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@ServiceProviderABC.inject
|
@ServiceProviderABC.inject
|
||||||
def icon_url(self, bot: DiscordBotServiceABC) -> str:
|
def icon_url(self, bot: DiscordBotServiceABC) -> Optional[str]:
|
||||||
guild = bot.get_guild(self.discord_id)
|
guild = bot.get_guild(self.discord_id)
|
||||||
|
if guild is None:
|
||||||
|
return None
|
||||||
return None if guild is None else guild.icon.url
|
return None if guild is None else guild.icon.url
|
||||||
|
@@ -1,4 +1,5 @@
|
|||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
from typing import Optional
|
||||||
|
|
||||||
from cpl_core.database import TableABC
|
from cpl_core.database import TableABC
|
||||||
from cpl_core.dependency_injection import ServiceProviderABC
|
from cpl_core.dependency_injection import ServiceProviderABC
|
||||||
@@ -51,8 +52,10 @@ class ShortRoleName(TableABC):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
@ServiceProviderABC.inject
|
@ServiceProviderABC.inject
|
||||||
def role_name(self, bot: DiscordBotServiceABC) -> str:
|
def role_name(self, bot: DiscordBotServiceABC) -> Optional[str]:
|
||||||
guild = bot.get_guild(self._server.discord_id)
|
guild = bot.get_guild(self._server.discord_id)
|
||||||
|
if guild is None:
|
||||||
|
return None
|
||||||
return guild.get_role(self.role_id).name
|
return guild.get_role(self.role_id).name
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@@ -1,3 +1,5 @@
|
|||||||
|
from typing import Optional
|
||||||
|
|
||||||
from cpl_core.dependency_injection import ServiceProviderABC
|
from cpl_core.dependency_injection import ServiceProviderABC
|
||||||
from cpl_discord.service import DiscordBotServiceABC
|
from cpl_discord.service import DiscordBotServiceABC
|
||||||
|
|
||||||
@@ -47,8 +49,10 @@ class ShortRoleNameHistory(HistoryTableABC):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
@ServiceProviderABC.inject
|
@ServiceProviderABC.inject
|
||||||
def role_name(self, bot: DiscordBotServiceABC) -> str:
|
def role_name(self, bot: DiscordBotServiceABC) -> Optional[str]:
|
||||||
guild = bot.get_guild(self._server.discord_id)
|
guild = bot.get_guild(self._server.discord_id)
|
||||||
|
if guild is None:
|
||||||
|
return None
|
||||||
return guild.get_role(self.role_id).name
|
return guild.get_role(self.role_id).name
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@@ -53,15 +53,19 @@ class User(TableABC):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
@ServiceProviderABC.inject
|
@ServiceProviderABC.inject
|
||||||
def name(self, bot: DiscordBotServiceABC) -> str:
|
def name(self, bot: DiscordBotServiceABC) -> Optional[str]:
|
||||||
guild = bot.get_guild(self.server.discord_id)
|
guild = bot.get_guild(self.server.discord_id)
|
||||||
|
if guild is None:
|
||||||
|
return None
|
||||||
user = guild.get_member(self.discord_id)
|
user = guild.get_member(self.discord_id)
|
||||||
return None if user is None else user.name
|
return None if user is None else user.name
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@ServiceProviderABC.inject
|
@ServiceProviderABC.inject
|
||||||
def icon_url(self, bot: DiscordBotServiceABC) -> str:
|
def icon_url(self, bot: DiscordBotServiceABC) -> Optional[str]:
|
||||||
guild = bot.get_guild(self.server.discord_id)
|
guild = bot.get_guild(self.server.discord_id)
|
||||||
|
if guild is None:
|
||||||
|
return None
|
||||||
user = guild.get_member(self.discord_id)
|
user = guild.get_member(self.discord_id)
|
||||||
return None if user is None else user.display_icon
|
return None if user is None else user.display_icon
|
||||||
|
|
||||||
@@ -137,7 +141,7 @@ class User(TableABC):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
@ServiceProviderABC.inject
|
@ServiceProviderABC.inject
|
||||||
def level(self, services: ServiceProviderABC) -> Level:
|
def level(self, services: ServiceProviderABC) -> Optional[Level]:
|
||||||
from modules.level.service.level_service import LevelService
|
from modules.level.service.level_service import LevelService
|
||||||
|
|
||||||
levels: LevelService = services.get_service(LevelService)
|
levels: LevelService = services.get_service(LevelService)
|
||||||
@@ -175,8 +179,10 @@ class User(TableABC):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
@ServiceProviderABC.inject
|
@ServiceProviderABC.inject
|
||||||
def profile_picture_url(self, bot: DiscordBotServiceABC) -> str:
|
def profile_picture_url(self, bot: DiscordBotServiceABC) -> Optional[str]:
|
||||||
guild = bot.get_guild(self.server.discord_id)
|
guild = bot.get_guild(self.server.discord_id)
|
||||||
|
if guild is None:
|
||||||
|
return None
|
||||||
user = guild.get_member(self._discord_id)
|
user = guild.get_member(self._discord_id)
|
||||||
return None if user is None or user.avatar is None else user.avatar.url
|
return None if user is None or user.avatar is None else user.avatar.url
|
||||||
|
|
||||||
|
104
bot/src/bot_data/mysql_pool.py
Normal file
104
bot/src/bot_data/mysql_pool.py
Normal file
@@ -0,0 +1,104 @@
|
|||||||
|
# https://stackoverflow.com/questions/32658679/how-to-create-a-mysql-connection-pool-or-any-better-way-to-initialize-the-multip
|
||||||
|
import mysql.connector as sql
|
||||||
|
from cpl_core.database import DatabaseSettings
|
||||||
|
from cpl_core.utils import CredentialManager
|
||||||
|
|
||||||
|
|
||||||
|
class MySQLPool(object):
|
||||||
|
"""
|
||||||
|
create a pool when connect mysql, which will decrease the time spent in
|
||||||
|
request connection, create connection and close connection.
|
||||||
|
"""
|
||||||
|
|
||||||
|
def __init__(
|
||||||
|
self,
|
||||||
|
database_settings: DatabaseSettings,
|
||||||
|
pool_size=5,
|
||||||
|
):
|
||||||
|
res = {
|
||||||
|
"host": database_settings.host,
|
||||||
|
"port": database_settings.port,
|
||||||
|
"user": database_settings.user,
|
||||||
|
"password": CredentialManager.decrypt(database_settings.password),
|
||||||
|
"database": database_settings.database,
|
||||||
|
}
|
||||||
|
|
||||||
|
self.dbconfig = res
|
||||||
|
self.pool = self.create_pool(pool_name="MySqlPool", pool_size=pool_size)
|
||||||
|
|
||||||
|
def create_pool(self, pool_name="MySqlPool", pool_size=3):
|
||||||
|
"""
|
||||||
|
Create a connection pool, after created, the request of connecting
|
||||||
|
MySQL could get a connection from this pool instead of request to
|
||||||
|
create a connection.
|
||||||
|
:param pool_name: the name of pool, default is "mypool"
|
||||||
|
:param pool_size: the size of pool, default is 3
|
||||||
|
:return: connection pool
|
||||||
|
"""
|
||||||
|
pool = sql.pooling.MySQLConnectionPool(
|
||||||
|
pool_name=pool_name, pool_size=pool_size, pool_reset_session=True, **self.dbconfig
|
||||||
|
)
|
||||||
|
return pool
|
||||||
|
|
||||||
|
def close(self, conn, cursor):
|
||||||
|
"""
|
||||||
|
A method used to close connection of mysql.
|
||||||
|
:param conn:
|
||||||
|
:param cursor:
|
||||||
|
:return:
|
||||||
|
"""
|
||||||
|
cursor.close()
|
||||||
|
conn.close()
|
||||||
|
|
||||||
|
def execute(self, sql, args=None, commit=False):
|
||||||
|
"""
|
||||||
|
Execute a sql, it could be with args and with out args. The usage is
|
||||||
|
similar with execute() function in module pymysql.
|
||||||
|
:param sql: sql clause
|
||||||
|
:param args: args need by sql clause
|
||||||
|
:param commit: whether to commit
|
||||||
|
:return: if commit, return None, else, return result
|
||||||
|
"""
|
||||||
|
# get connection form connection pool instead of create one.
|
||||||
|
conn = self.pool.get_connection()
|
||||||
|
cursor = conn.cursor()
|
||||||
|
if args:
|
||||||
|
cursor.execute(sql, args)
|
||||||
|
else:
|
||||||
|
cursor.execute(sql)
|
||||||
|
if commit is True:
|
||||||
|
conn.commit()
|
||||||
|
self.close(conn, cursor)
|
||||||
|
return None
|
||||||
|
else:
|
||||||
|
res = cursor.fetchall()
|
||||||
|
self.close(conn, cursor)
|
||||||
|
return res
|
||||||
|
|
||||||
|
def executemany(self, sql, args, commit=False):
|
||||||
|
"""
|
||||||
|
Execute with many args. Similar with executemany() function in pymysql.
|
||||||
|
args should be a sequence.
|
||||||
|
:param sql: sql clause
|
||||||
|
:param args: args
|
||||||
|
:param commit: commit or not.
|
||||||
|
:return: if commit, return None, else, return result
|
||||||
|
"""
|
||||||
|
# get connection form connection pool instead of create one.
|
||||||
|
conn = self.pool.get_connection()
|
||||||
|
cursor = conn.cursor()
|
||||||
|
cursor.executemany(sql, args)
|
||||||
|
if commit is True:
|
||||||
|
conn.commit()
|
||||||
|
self.close(conn, cursor)
|
||||||
|
return None
|
||||||
|
else:
|
||||||
|
res = cursor.fetchall()
|
||||||
|
self.close(conn, cursor)
|
||||||
|
return res
|
||||||
|
|
||||||
|
def commit(self):
|
||||||
|
conn = self.pool.get_connection()
|
||||||
|
conn.commit()
|
||||||
|
cursor = conn.cursor()
|
||||||
|
self.close(conn, cursor)
|
4
bot/src/bot_data/scripts/1.2.9/1_Realm_down.sql
Normal file
4
bot/src/bot_data/scripts/1.2.9/1_Realm_down.sql
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
DROP TABLE IF EXISTS `Realms`;
|
||||||
|
DROP TABLE IF EXISTS `RealmsHistory`;
|
||||||
|
DROP TABLE IF EXISTS `RealmModerators`;
|
||||||
|
DROP TABLE IF EXISTS `RealmModeratorsHistory`;
|
97
bot/src/bot_data/scripts/1.2.9/1_Realm_up.sql
Normal file
97
bot/src/bot_data/scripts/1.2.9/1_Realm_up.sql
Normal file
@@ -0,0 +1,97 @@
|
|||||||
|
CREATE TABLE IF NOT EXISTS `Realms`
|
||||||
|
(
|
||||||
|
`RealmId` BIGINT NOT NULL AUTO_INCREMENT,
|
||||||
|
`Name` VARCHAR(255) NOT NULL,
|
||||||
|
`RoleId` BIGINT NOT NULL,
|
||||||
|
`ServerId` BIGINT,
|
||||||
|
`CreatedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6),
|
||||||
|
`LastModifiedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6),
|
||||||
|
PRIMARY KEY (`RealmId`),
|
||||||
|
FOREIGN KEY (`ServerId`) REFERENCES `Servers` (`ServerId`)
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS `RealmsHistory`
|
||||||
|
(
|
||||||
|
`RealmId` BIGINT(20) NOT NULL,
|
||||||
|
`Name` VARCHAR(255) NOT NULL,
|
||||||
|
`RoleId` BIGINT NOT NULL,
|
||||||
|
`ServerId` BIGINT(20) DEFAULT NULL,
|
||||||
|
`Deleted` BOOL DEFAULT FALSE,
|
||||||
|
`DateFrom` DATETIME(6) NOT NULL,
|
||||||
|
`DateTo` DATETIME(6) NOT NULL
|
||||||
|
);
|
||||||
|
|
||||||
|
DROP TRIGGER IF EXISTS `TR_RealmsUpdate`;
|
||||||
|
|
||||||
|
CREATE TRIGGER `TR_RealmsUpdate`
|
||||||
|
AFTER UPDATE
|
||||||
|
ON `Realms`
|
||||||
|
FOR EACH ROW
|
||||||
|
BEGIN
|
||||||
|
INSERT INTO `RealmsHistory` (`RealmId`, `Name`, `RoleId`, `ServerId`, `DateFrom`, `DateTo`)
|
||||||
|
VALUES (OLD.RealmId, OLD.Name, OLD.RoleId, OLD.ServerId, OLD.LastModifiedAt, CURRENT_TIMESTAMP(6));
|
||||||
|
END;
|
||||||
|
|
||||||
|
DROP TRIGGER IF EXISTS `TR_RealmsDelete`;
|
||||||
|
|
||||||
|
CREATE TRIGGER `TR_RealmsDelete`
|
||||||
|
AFTER DELETE
|
||||||
|
ON `Realms`
|
||||||
|
FOR EACH ROW
|
||||||
|
BEGIN
|
||||||
|
INSERT INTO `RealmsHistory` (`RealmId`, `Name`, `RoleId`, `ServerId`, `Deleted`, `DateFrom`, `DateTo`)
|
||||||
|
VALUES (OLD.RealmId, OLD.Name, OLD.RoleId, OLD.ServerId, TRUE, OLD.LastModifiedAt, CURRENT_TIMESTAMP(6));
|
||||||
|
END;
|
||||||
|
|
||||||
|
-- Realm moderators
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS `RealmModerators`
|
||||||
|
(
|
||||||
|
`Id` BIGINT NOT NULL AUTO_INCREMENT,
|
||||||
|
`RealmId` BIGINT NOT NULL,
|
||||||
|
`UserId` BIGINT NOT NULL,
|
||||||
|
`ServerId` BIGINT,
|
||||||
|
`CreatedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6),
|
||||||
|
`LastModifiedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6),
|
||||||
|
PRIMARY KEY (`Id`),
|
||||||
|
FOREIGN KEY (`RealmId`) REFERENCES `Realms` (`RealmId`),
|
||||||
|
FOREIGN KEY (`UserId`) REFERENCES `Users` (`UserId`),
|
||||||
|
FOREIGN KEY (`ServerId`) REFERENCES `Servers` (`ServerId`)
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS `RealmModeratorsHistory`
|
||||||
|
(
|
||||||
|
`Id` BIGINT(20) NOT NULL,
|
||||||
|
`RealmId` BIGINT NOT NULL,
|
||||||
|
`UserId` BIGINT NOT NULL,
|
||||||
|
`ServerId` BIGINT(20) DEFAULT NULL,
|
||||||
|
`Deleted` BOOL DEFAULT FALSE,
|
||||||
|
`DateFrom` DATETIME(6) NOT NULL,
|
||||||
|
`DateTo` DATETIME(6) NOT NULL
|
||||||
|
);
|
||||||
|
|
||||||
|
DROP TRIGGER IF EXISTS `TR_RealmModeratorsUpdate`;
|
||||||
|
|
||||||
|
CREATE TRIGGER `TR_RealmModeratorsUpdate`
|
||||||
|
AFTER UPDATE
|
||||||
|
ON `RealmModerators`
|
||||||
|
FOR EACH ROW
|
||||||
|
BEGIN
|
||||||
|
INSERT INTO `RealmModeratorsHistory` (`Id`, `RealmId`, `UserId`, `ServerId`, `DateFrom`, `DateTo`)
|
||||||
|
VALUES (OLD.Id, OLD.RealmId, OLD.UserId, OLD.ServerId, OLD.LastModifiedAt, CURRENT_TIMESTAMP(6));
|
||||||
|
END;
|
||||||
|
|
||||||
|
DROP TRIGGER IF EXISTS `TR_RealmModeratorsDelete`;
|
||||||
|
|
||||||
|
CREATE TRIGGER `TR_RealmModeratorsDelete`
|
||||||
|
AFTER DELETE
|
||||||
|
ON `RealmModerators`
|
||||||
|
FOR EACH ROW
|
||||||
|
BEGIN
|
||||||
|
INSERT INTO `RealmModeratorsHistory` (`Id`, `RealmId`, `UserId`, `ServerId`, `Deleted`, `DateFrom`, `DateTo`)
|
||||||
|
VALUES (OLD.Id, OLD.RealmId, OLD.UserId, OLD.ServerId, TRUE, OLD.LastModifiedAt, CURRENT_TIMESTAMP(6));
|
||||||
|
END;
|
||||||
|
|
||||||
|
|
@@ -15,7 +15,7 @@ __title__ = "bot_data.service"
|
|||||||
__author__ = "Sven Heidemann"
|
__author__ = "Sven Heidemann"
|
||||||
__license__ = "MIT"
|
__license__ = "MIT"
|
||||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||||
__version__ = "1.2.7"
|
__version__ = "1.2.11"
|
||||||
|
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
@@ -23,4 +23,4 @@ from collections import namedtuple
|
|||||||
# imports
|
# imports
|
||||||
|
|
||||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||||
version_info = VersionInfo(major="1", minor="2", micro="7")
|
version_info = VersionInfo(major="1", minor="2", micro="11")
|
||||||
|
@@ -1,13 +1,13 @@
|
|||||||
import glob
|
import glob
|
||||||
import os
|
import os
|
||||||
|
|
||||||
from cpl_core.database.context import DatabaseContextABC
|
|
||||||
from cpl_core.dependency_injection import ServiceProviderABC
|
from cpl_core.dependency_injection import ServiceProviderABC
|
||||||
from cpl_query.extension import List
|
from cpl_query.extension import List
|
||||||
from packaging import version
|
from packaging import version
|
||||||
|
|
||||||
import bot
|
import bot
|
||||||
from bot_core.logging.database_logger import DatabaseLogger
|
from bot_core.logging.database_logger import DatabaseLogger
|
||||||
|
from bot_data.db_context import DBContext
|
||||||
from bot_data.model.migration import Migration
|
from bot_data.model.migration import Migration
|
||||||
from bot_data.model.migration_history import MigrationHistory
|
from bot_data.model.migration_history import MigrationHistory
|
||||||
|
|
||||||
@@ -17,13 +17,12 @@ class MigrationService:
|
|||||||
self,
|
self,
|
||||||
logger: DatabaseLogger,
|
logger: DatabaseLogger,
|
||||||
services: ServiceProviderABC,
|
services: ServiceProviderABC,
|
||||||
db: DatabaseContextABC,
|
db: DBContext,
|
||||||
):
|
):
|
||||||
self._logger = logger
|
self._logger = logger
|
||||||
self._services = services
|
self._services = services
|
||||||
|
|
||||||
self._db = db
|
self._db = db
|
||||||
self._cursor = db.cursor
|
|
||||||
|
|
||||||
def _get_migration_history(self) -> List[MigrationHistory]:
|
def _get_migration_history(self) -> List[MigrationHistory]:
|
||||||
results = self._db.select(
|
results = self._db.select(
|
||||||
@@ -42,7 +41,7 @@ class MigrationService:
|
|||||||
return
|
return
|
||||||
|
|
||||||
self._logger.debug(__name__, f"Migrate new migration {migration.migration_id} to old method")
|
self._logger.debug(__name__, f"Migrate new migration {migration.migration_id} to old method")
|
||||||
self._cursor.execute(migration.change_id_string(f"{migration.migration_id}Migration"))
|
self._db.execute(migration.change_id_string(f"{migration.migration_id}Migration"))
|
||||||
self._db.save_changes()
|
self._db.save_changes()
|
||||||
|
|
||||||
def _migration_migrations_to_new(self, migration: MigrationHistory):
|
def _migration_migrations_to_new(self, migration: MigrationHistory):
|
||||||
@@ -50,12 +49,11 @@ class MigrationService:
|
|||||||
return
|
return
|
||||||
|
|
||||||
self._logger.debug(__name__, f"Migrate old migration {migration.migration_id} to new method")
|
self._logger.debug(__name__, f"Migrate old migration {migration.migration_id} to new method")
|
||||||
self._cursor.execute(migration.change_id_string(migration.migration_id.replace("Migration", "")))
|
self._db.execute(migration.change_id_string(migration.migration_id.replace("Migration", "")))
|
||||||
self._db.save_changes()
|
self._db.save_changes()
|
||||||
|
|
||||||
def _migrate_from_old_to_new(self):
|
def _migrate_from_old_to_new(self):
|
||||||
self._cursor.execute("SHOW TABLES LIKE 'MigrationHistory'")
|
result = self._db.select("SHOW TABLES LIKE 'MigrationHistory'")
|
||||||
result = self._cursor.fetchone()
|
|
||||||
if not result:
|
if not result:
|
||||||
return
|
return
|
||||||
|
|
||||||
@@ -120,8 +118,7 @@ class MigrationService:
|
|||||||
active_statement = ""
|
active_statement = ""
|
||||||
try:
|
try:
|
||||||
# check if table exists
|
# check if table exists
|
||||||
self._cursor.execute("SHOW TABLES LIKE 'MigrationHistory'")
|
result = self._db.select("SHOW TABLES LIKE 'MigrationHistory'")
|
||||||
result = self._cursor.fetchone()
|
|
||||||
if result:
|
if result:
|
||||||
# there is a table named "tableName"
|
# there is a table named "tableName"
|
||||||
self._logger.trace(
|
self._logger.trace(
|
||||||
@@ -142,9 +139,9 @@ class MigrationService:
|
|||||||
if statement in ["", "\n"]:
|
if statement in ["", "\n"]:
|
||||||
continue
|
continue
|
||||||
active_statement = statement
|
active_statement = statement
|
||||||
self._cursor.execute(statement + ";")
|
self._db.execute(statement + ";")
|
||||||
|
|
||||||
self._cursor.execute(
|
self._db.execute(
|
||||||
MigrationHistory(migration.name).insert_string
|
MigrationHistory(migration.name).insert_string
|
||||||
if upgrade
|
if upgrade
|
||||||
else MigrationHistory(migration.name).delete_string
|
else MigrationHistory(migration.name).delete_string
|
||||||
|
127
bot/src/bot_data/service/realm_repository_service.py
Normal file
127
bot/src/bot_data/service/realm_repository_service.py
Normal file
@@ -0,0 +1,127 @@
|
|||||||
|
from typing import Optional
|
||||||
|
|
||||||
|
from cpl_core.database.context import DatabaseContextABC
|
||||||
|
from cpl_query.extension import List
|
||||||
|
|
||||||
|
from bot_core.logging.database_logger import DatabaseLogger
|
||||||
|
from bot_data.abc.realm_repository_abc import RealmRepositoryABC
|
||||||
|
from bot_data.abc.server_repository_abc import ServerRepositoryABC
|
||||||
|
from bot_data.abc.user_repository_abc import UserRepositoryABC
|
||||||
|
from bot_data.model.realm import Realm
|
||||||
|
from bot_data.model.realm_moderator import RealmModerator
|
||||||
|
|
||||||
|
|
||||||
|
class RealmRepositoryService(RealmRepositoryABC):
|
||||||
|
def __init__(
|
||||||
|
self,
|
||||||
|
logger: DatabaseLogger,
|
||||||
|
db_context: DatabaseContextABC,
|
||||||
|
servers: ServerRepositoryABC,
|
||||||
|
users: UserRepositoryABC,
|
||||||
|
):
|
||||||
|
self._logger = logger
|
||||||
|
self._context = db_context
|
||||||
|
self._servers = servers
|
||||||
|
self._users = users
|
||||||
|
|
||||||
|
RealmRepositoryABC.__init__(self)
|
||||||
|
|
||||||
|
def _from_result(self, result: tuple) -> Realm:
|
||||||
|
return Realm(
|
||||||
|
result[1],
|
||||||
|
result[2],
|
||||||
|
self._servers.get_server_by_id(result[3]),
|
||||||
|
result[4],
|
||||||
|
result[5],
|
||||||
|
id=result[0],
|
||||||
|
)
|
||||||
|
|
||||||
|
def get_all(self) -> List[Realm]:
|
||||||
|
self._logger.trace(__name__, f"Send SQL command: {Realm.get_select_all_string()}")
|
||||||
|
return List(
|
||||||
|
Realm, [self._from_result(result) for result in self._context.select(Realm.get_select_all_string())]
|
||||||
|
)
|
||||||
|
|
||||||
|
def get_realm_by_id(self, id: int) -> Realm:
|
||||||
|
self._logger.trace(__name__, f"Send SQL command: {Realm.get_select_by_id_string(id)}")
|
||||||
|
return self._from_result(self._context.select(Realm.get_select_by_id_string(id))[0])
|
||||||
|
|
||||||
|
def find_realm_by_id(self, id: int) -> Optional[Realm]:
|
||||||
|
self._logger.trace(__name__, f"Send SQL command: {Realm.get_select_by_id_string(id)}")
|
||||||
|
result = self._context.select(Realm.get_select_by_id_string(id))
|
||||||
|
if result is None or len(result) == 0:
|
||||||
|
return None
|
||||||
|
|
||||||
|
return self._from_result(result[0])
|
||||||
|
|
||||||
|
def find_realm_by_name(self, name: str) -> Optional[Realm]:
|
||||||
|
self._logger.trace(__name__, f"Send SQL command: {Realm.get_select_by_name_string(name)}")
|
||||||
|
result = self._context.select(Realm.get_select_by_name_string(name))
|
||||||
|
if result is None or len(result) == 0:
|
||||||
|
return None
|
||||||
|
|
||||||
|
return self._from_result(result[0])
|
||||||
|
|
||||||
|
def get_realms_by_server_id(self, id: int) -> List[Realm]:
|
||||||
|
self._logger.trace(__name__, f"Send SQL command: {Realm.get_select_by_server_id_string(id)}")
|
||||||
|
return List(
|
||||||
|
Realm,
|
||||||
|
[self._from_result(result) for result in self._context.select(Realm.get_select_by_server_id_string(id))],
|
||||||
|
)
|
||||||
|
|
||||||
|
def add_realm(self, realm: Realm):
|
||||||
|
self._logger.trace(__name__, f"Send SQL command: {realm.insert_string}")
|
||||||
|
self._context.cursor.execute(realm.insert_string)
|
||||||
|
|
||||||
|
def update_realm(self, realm: Realm):
|
||||||
|
self._logger.trace(__name__, f"Send SQL command: {realm.udpate_string}")
|
||||||
|
self._context.cursor.execute(realm.udpate_string)
|
||||||
|
|
||||||
|
def delete_realm(self, realm: Realm):
|
||||||
|
self._logger.trace(__name__, f"Send SQL command: {realm.delete_string}")
|
||||||
|
self._context.cursor.execute(realm.delete_string)
|
||||||
|
|
||||||
|
def _rule_from_result(self, result: tuple) -> RealmModerator:
|
||||||
|
return RealmModerator(
|
||||||
|
self.get_realm_by_id(result[1]),
|
||||||
|
self._users.get_user_by_id(result[2]),
|
||||||
|
result[4],
|
||||||
|
result[5],
|
||||||
|
id=result[0],
|
||||||
|
)
|
||||||
|
|
||||||
|
def get_realm_moderators(self) -> List[RealmModerator]:
|
||||||
|
self._logger.trace(__name__, f"Send SQL command: {RealmModerator.get_select_all_string()}")
|
||||||
|
return List(
|
||||||
|
RealmModerator,
|
||||||
|
[self._rule_from_result(result) for result in self._context.select(RealmModerator.get_select_all_string())],
|
||||||
|
)
|
||||||
|
|
||||||
|
def get_realm_moderator_by_id(self, id: int) -> RealmModerator:
|
||||||
|
self._logger.trace(__name__, f"Send SQL command: {RealmModerator.get_select_by_id_string(id)}")
|
||||||
|
return self._rule_from_result(self._context.select(RealmModerator.get_select_by_id_string(id))[0])
|
||||||
|
|
||||||
|
def get_realm_moderators_by_realm_id(self, id: int) -> List[RealmModerator]:
|
||||||
|
self._logger.trace(
|
||||||
|
__name__,
|
||||||
|
f"Send SQL command: {RealmModerator.get_select_by_realm_id_string(id)}",
|
||||||
|
)
|
||||||
|
return List(
|
||||||
|
RealmModerator,
|
||||||
|
[
|
||||||
|
self._rule_from_result(result)
|
||||||
|
for result in self._context.select(RealmModerator.get_select_by_realm_id_string(id))
|
||||||
|
],
|
||||||
|
)
|
||||||
|
|
||||||
|
def add_realm_moderator(self, realm_moderator: RealmModerator):
|
||||||
|
self._logger.trace(__name__, f"Send SQL command: {realm_moderator.insert_string}")
|
||||||
|
self._context.cursor.execute(realm_moderator.insert_string)
|
||||||
|
|
||||||
|
def update_realm_moderator(self, realm_moderator: RealmModerator):
|
||||||
|
self._logger.trace(__name__, f"Send SQL command: {realm_moderator.udpate_string}")
|
||||||
|
self._context.cursor.execute(realm_moderator.udpate_string)
|
||||||
|
|
||||||
|
def delete_realm_moderator(self, realm_moderator: RealmModerator):
|
||||||
|
self._logger.trace(__name__, f"Send SQL command: {realm_moderator.delete_string}")
|
||||||
|
self._context.cursor.execute(realm_moderator.delete_string)
|
@@ -2,6 +2,7 @@ from datetime import datetime
|
|||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
|
||||||
from cpl_core.database.context import DatabaseContextABC
|
from cpl_core.database.context import DatabaseContextABC
|
||||||
|
from cpl_core.time import TimeFormatSettings
|
||||||
from cpl_query.extension import List
|
from cpl_query.extension import List
|
||||||
|
|
||||||
from bot_core.logging.database_logger import DatabaseLogger
|
from bot_core.logging.database_logger import DatabaseLogger
|
||||||
@@ -15,12 +16,14 @@ from bot_data.model.user_message_count_per_hour import UserMessageCountPerHour
|
|||||||
class UserMessageCountPerHourRepositoryService(UserMessageCountPerHourRepositoryABC):
|
class UserMessageCountPerHourRepositoryService(UserMessageCountPerHourRepositoryABC):
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
|
time_format: TimeFormatSettings,
|
||||||
logger: DatabaseLogger,
|
logger: DatabaseLogger,
|
||||||
db_context: DatabaseContextABC,
|
db_context: DatabaseContextABC,
|
||||||
users: UserRepositoryABC,
|
users: UserRepositoryABC,
|
||||||
):
|
):
|
||||||
UserMessageCountPerHourRepositoryABC.__init__(self)
|
UserMessageCountPerHourRepositoryABC.__init__(self)
|
||||||
|
|
||||||
|
self._time_format = time_format
|
||||||
self._logger = logger
|
self._logger = logger
|
||||||
self._context = db_context
|
self._context = db_context
|
||||||
self._users = users
|
self._users = users
|
||||||
@@ -67,7 +70,12 @@ class UserMessageCountPerHourRepositoryService(UserMessageCountPerHourRepository
|
|||||||
) -> UserMessageCountPerHour:
|
) -> UserMessageCountPerHour:
|
||||||
sql = UserMessageCountPerHour.get_select_by_user_id_and_date_string(user_id, date)
|
sql = UserMessageCountPerHour.get_select_by_user_id_and_date_string(user_id, date)
|
||||||
self._logger.trace(__name__, f"Send SQL command: {sql}")
|
self._logger.trace(__name__, f"Send SQL command: {sql}")
|
||||||
return self._from_result(self._context.select(sql)[0])
|
res = self._context.select(sql)
|
||||||
|
if len(res) > 0:
|
||||||
|
return self._from_result(res[0])
|
||||||
|
|
||||||
|
user = self._users.get_user_by_id(user_id)
|
||||||
|
return UserMessageCountPerHour(date.strftime(self._time_format.date_time_format), date.hour, 0, user)
|
||||||
|
|
||||||
def find_user_message_count_per_hour_by_user_id_and_date(
|
def find_user_message_count_per_hour_by_user_id_and_date(
|
||||||
self, user_id: int, date: datetime
|
self, user_id: int, date: datetime
|
||||||
|
@@ -15,7 +15,7 @@ __title__ = "bot_graphql"
|
|||||||
__author__ = "Sven Heidemann"
|
__author__ = "Sven Heidemann"
|
||||||
__license__ = "MIT"
|
__license__ = "MIT"
|
||||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||||
__version__ = "1.2.7"
|
__version__ = "1.2.11"
|
||||||
|
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
@@ -23,4 +23,4 @@ from collections import namedtuple
|
|||||||
# imports
|
# imports
|
||||||
|
|
||||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||||
version_info = VersionInfo(major="1", minor="2", micro="7")
|
version_info = VersionInfo(major="1", minor="2", micro="11")
|
||||||
|
@@ -15,7 +15,7 @@ __title__ = "bot_graphql.abc"
|
|||||||
__author__ = "Sven Heidemann"
|
__author__ = "Sven Heidemann"
|
||||||
__license__ = "MIT"
|
__license__ = "MIT"
|
||||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||||
__version__ = "1.2.7"
|
__version__ = "1.2.11"
|
||||||
|
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
@@ -23,4 +23,4 @@ from collections import namedtuple
|
|||||||
# imports:
|
# imports:
|
||||||
|
|
||||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||||
version_info = VersionInfo(major="1", minor="2", micro="7")
|
version_info = VersionInfo(major="1", minor="2", micro="11")
|
||||||
|
@@ -12,7 +12,7 @@ from bot_core.exception.service_exception import ServiceException
|
|||||||
from bot_api.route.route import Route
|
from bot_api.route.route import Route
|
||||||
from bot_core.configuration.feature_flags_enum import FeatureFlagsEnum
|
from bot_core.configuration.feature_flags_enum import FeatureFlagsEnum
|
||||||
from bot_core.environment_variables import MAINTENANCE
|
from bot_core.environment_variables import MAINTENANCE
|
||||||
from bot_core.service.permission_service import PermissionService
|
from bot_core.service.permission_service_with_cache import PermissionServiceWithCache
|
||||||
from bot_data.model.achievement import Achievement
|
from bot_data.model.achievement import Achievement
|
||||||
from bot_data.model.auth_role_enum import AuthRoleEnum
|
from bot_data.model.auth_role_enum import AuthRoleEnum
|
||||||
from bot_data.model.auth_user import AuthUser
|
from bot_data.model.auth_user import AuthUser
|
||||||
@@ -82,7 +82,7 @@ class QueryABC(ObjectType):
|
|||||||
return config
|
return config
|
||||||
|
|
||||||
services = get_services()
|
services = get_services()
|
||||||
permissions: PermissionService = services.get_service(PermissionService)
|
permissions: PermissionServiceWithCache = services.get_service(PermissionServiceWithCache)
|
||||||
bot: DiscordBotServiceABC = services.get_service(DiscordBotServiceABC)
|
bot: DiscordBotServiceABC = services.get_service(DiscordBotServiceABC)
|
||||||
config = get_config()
|
config = get_config()
|
||||||
|
|
||||||
@@ -91,7 +91,7 @@ class QueryABC(ObjectType):
|
|||||||
|
|
||||||
for u in user.users:
|
for u in user.users:
|
||||||
guild = bot.get_guild(u.server.discord_id)
|
guild = bot.get_guild(u.server.discord_id)
|
||||||
if permissions.is_member_technician(guild.get_member(u.discord_id)):
|
if guild is not None and permissions.is_member_technician(guild.get_member(u.discord_id)):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
if config.get_configuration(MAINTENANCE):
|
if config.get_configuration(MAINTENANCE):
|
||||||
@@ -111,6 +111,8 @@ class QueryABC(ObjectType):
|
|||||||
for u in user.users:
|
for u in user.users:
|
||||||
u: User = u
|
u: User = u
|
||||||
guild = bot.get_guild(u.server.discord_id)
|
guild = bot.get_guild(u.server.discord_id)
|
||||||
|
if guild is None:
|
||||||
|
continue
|
||||||
member = guild.get_member(u.discord_id)
|
member = guild.get_member(u.discord_id)
|
||||||
if permissions.is_member_moderator(member) and u.server.id == element.server.id:
|
if permissions.is_member_moderator(member) and u.server.id == element.server.id:
|
||||||
access = True
|
access = True
|
||||||
@@ -121,6 +123,8 @@ class QueryABC(ObjectType):
|
|||||||
for u in user.users:
|
for u in user.users:
|
||||||
u: User = u
|
u: User = u
|
||||||
guild = bot.get_guild(u.server.discord_id)
|
guild = bot.get_guild(u.server.discord_id)
|
||||||
|
if guild is None:
|
||||||
|
continue
|
||||||
member = guild.get_member(u.discord_id)
|
member = guild.get_member(u.discord_id)
|
||||||
if permissions.is_member_moderator(member) and u.server.id == element.auto_role.server.id:
|
if permissions.is_member_moderator(member) and u.server.id == element.auto_role.server.id:
|
||||||
access = True
|
access = True
|
||||||
@@ -137,6 +141,8 @@ class QueryABC(ObjectType):
|
|||||||
for u in user.users:
|
for u in user.users:
|
||||||
u: User = u
|
u: User = u
|
||||||
guild = bot.get_guild(u.server.discord_id)
|
guild = bot.get_guild(u.server.discord_id)
|
||||||
|
if guild is None:
|
||||||
|
continue
|
||||||
member = guild.get_member(u.discord_id)
|
member = guild.get_member(u.discord_id)
|
||||||
if permissions.is_member_moderator(member):
|
if permissions.is_member_moderator(member):
|
||||||
access = True
|
access = True
|
||||||
@@ -160,6 +166,8 @@ class QueryABC(ObjectType):
|
|||||||
for u in user.users:
|
for u in user.users:
|
||||||
u: User = u
|
u: User = u
|
||||||
guild = bot.get_guild(u.server.discord_id)
|
guild = bot.get_guild(u.server.discord_id)
|
||||||
|
if guild is None:
|
||||||
|
continue
|
||||||
member = guild.get_member(u.discord_id)
|
member = guild.get_member(u.discord_id)
|
||||||
if u.id == element.id or permissions.is_member_moderator(member):
|
if u.id == element.id or permissions.is_member_moderator(member):
|
||||||
access = True
|
access = True
|
||||||
@@ -169,6 +177,8 @@ class QueryABC(ObjectType):
|
|||||||
for u in user.users:
|
for u in user.users:
|
||||||
u: User = u
|
u: User = u
|
||||||
guild = bot.get_guild(u.server.discord_id)
|
guild = bot.get_guild(u.server.discord_id)
|
||||||
|
if guild is None:
|
||||||
|
continue
|
||||||
member = guild.get_member(u.discord_id)
|
member = guild.get_member(u.discord_id)
|
||||||
if u.id == element.user.id or permissions.is_member_moderator(member):
|
if u.id == element.user.id or permissions.is_member_moderator(member):
|
||||||
access = True
|
access = True
|
||||||
@@ -178,6 +188,8 @@ class QueryABC(ObjectType):
|
|||||||
for u in user.users:
|
for u in user.users:
|
||||||
u: User = u
|
u: User = u
|
||||||
guild = bot.get_guild(u.server.discord_id)
|
guild = bot.get_guild(u.server.discord_id)
|
||||||
|
if guild is None:
|
||||||
|
continue
|
||||||
member = guild.get_member(u.discord_id)
|
member = guild.get_member(u.discord_id)
|
||||||
if u.id == element.user.id or permissions.is_member_moderator(member):
|
if u.id == element.user.id or permissions.is_member_moderator(member):
|
||||||
access = True
|
access = True
|
||||||
@@ -187,6 +199,8 @@ class QueryABC(ObjectType):
|
|||||||
for u in user.users:
|
for u in user.users:
|
||||||
u: User = u
|
u: User = u
|
||||||
guild = bot.get_guild(u.server.discord_id)
|
guild = bot.get_guild(u.server.discord_id)
|
||||||
|
if guild is None:
|
||||||
|
continue
|
||||||
member = guild.get_member(u.discord_id)
|
member = guild.get_member(u.discord_id)
|
||||||
if u.id == element.user.id or permissions.is_member_moderator(member):
|
if u.id == element.user.id or permissions.is_member_moderator(member):
|
||||||
access = True
|
access = True
|
||||||
@@ -196,6 +210,8 @@ class QueryABC(ObjectType):
|
|||||||
for u in user.users:
|
for u in user.users:
|
||||||
u: User = u
|
u: User = u
|
||||||
guild = bot.get_guild(u.server.discord_id)
|
guild = bot.get_guild(u.server.discord_id)
|
||||||
|
if guild is None:
|
||||||
|
continue
|
||||||
member = guild.get_member(u.discord_id)
|
member = guild.get_member(u.discord_id)
|
||||||
if u.id == element.user.id or permissions.is_member_moderator(member):
|
if u.id == element.user.id or permissions.is_member_moderator(member):
|
||||||
access = True
|
access = True
|
||||||
@@ -205,6 +221,8 @@ class QueryABC(ObjectType):
|
|||||||
for u in user.users:
|
for u in user.users:
|
||||||
u: User = u
|
u: User = u
|
||||||
guild = bot.get_guild(u.server.discord_id)
|
guild = bot.get_guild(u.server.discord_id)
|
||||||
|
if guild is None:
|
||||||
|
continue
|
||||||
member = guild.get_member(u.discord_id)
|
member = guild.get_member(u.discord_id)
|
||||||
if permissions.is_member_technician(member):
|
if permissions.is_member_technician(member):
|
||||||
access = True
|
access = True
|
||||||
@@ -215,6 +233,8 @@ class QueryABC(ObjectType):
|
|||||||
for u in user.users:
|
for u in user.users:
|
||||||
u: User = u
|
u: User = u
|
||||||
guild = bot.get_guild(u.server.discord_id)
|
guild = bot.get_guild(u.server.discord_id)
|
||||||
|
if guild is None:
|
||||||
|
continue
|
||||||
member = guild.get_member(u.discord_id)
|
member = guild.get_member(u.discord_id)
|
||||||
if permissions.is_member_moderator(member) and u.server.id == element.server.id:
|
if permissions.is_member_moderator(member) and u.server.id == element.server.id:
|
||||||
access = True
|
access = True
|
||||||
@@ -225,6 +245,8 @@ class QueryABC(ObjectType):
|
|||||||
for u in user.users:
|
for u in user.users:
|
||||||
u: User = u
|
u: User = u
|
||||||
guild = bot.get_guild(u.server.discord_id)
|
guild = bot.get_guild(u.server.discord_id)
|
||||||
|
if guild is None:
|
||||||
|
continue
|
||||||
member = guild.get_member(u.discord_id)
|
member = guild.get_member(u.discord_id)
|
||||||
if permissions.is_member_moderator(member) and u.server.id == element.server.id:
|
if permissions.is_member_moderator(member) and u.server.id == element.server.id:
|
||||||
access = True
|
access = True
|
||||||
@@ -234,6 +256,8 @@ class QueryABC(ObjectType):
|
|||||||
for u in user.users:
|
for u in user.users:
|
||||||
u: User = u
|
u: User = u
|
||||||
guild = bot.get_guild(u.server.discord_id)
|
guild = bot.get_guild(u.server.discord_id)
|
||||||
|
if guild is None:
|
||||||
|
continue
|
||||||
member = guild.get_member(u.discord_id)
|
member = guild.get_member(u.discord_id)
|
||||||
if permissions.is_member_technician(member):
|
if permissions.is_member_technician(member):
|
||||||
access = True
|
access = True
|
||||||
@@ -245,7 +269,7 @@ class QueryABC(ObjectType):
|
|||||||
def _can_user_mutate_data(
|
def _can_user_mutate_data(
|
||||||
self, server: Server, permission: UserRoleEnum, services: ServiceProviderABC, config: ConfigurationABC
|
self, server: Server, permission: UserRoleEnum, services: ServiceProviderABC, config: ConfigurationABC
|
||||||
):
|
):
|
||||||
permissions: PermissionService = services.get_service(PermissionService)
|
permissions: PermissionServiceWithCache = services.get_service(PermissionServiceWithCache)
|
||||||
bot: DiscordBotServiceABC = services.get_service(DiscordBotServiceABC)
|
bot: DiscordBotServiceABC = services.get_service(DiscordBotServiceABC)
|
||||||
|
|
||||||
auth_user = Route.get_user()
|
auth_user = Route.get_user()
|
||||||
|
@@ -4,7 +4,7 @@
|
|||||||
"Version": {
|
"Version": {
|
||||||
"Major": "1",
|
"Major": "1",
|
||||||
"Minor": "2",
|
"Minor": "2",
|
||||||
"Micro": "7"
|
"Micro": "11"
|
||||||
},
|
},
|
||||||
"Author": "Sven Heidemann",
|
"Author": "Sven Heidemann",
|
||||||
"AuthorEmail": "sven.heidemann@sh-edraft.de",
|
"AuthorEmail": "sven.heidemann@sh-edraft.de",
|
||||||
|
@@ -15,7 +15,7 @@ __title__ = "bot_graphql.filter"
|
|||||||
__author__ = "Sven Heidemann"
|
__author__ = "Sven Heidemann"
|
||||||
__license__ = "MIT"
|
__license__ = "MIT"
|
||||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||||
__version__ = "1.2.7"
|
__version__ = "1.2.11"
|
||||||
|
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
@@ -23,4 +23,4 @@ from collections import namedtuple
|
|||||||
# imports:
|
# imports:
|
||||||
|
|
||||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||||
version_info = VersionInfo(major="1", minor="2", micro="7")
|
version_info = VersionInfo(major="1", minor="2", micro="11")
|
||||||
|
@@ -51,6 +51,8 @@ class AutoRoleRuleFilter(FilterABC):
|
|||||||
|
|
||||||
def get_role_name(x: AutoRoleRule):
|
def get_role_name(x: AutoRoleRule):
|
||||||
guild = self._bot.get_guild(x.auto_role.server.discord_id)
|
guild = self._bot.get_guild(x.auto_role.server.discord_id)
|
||||||
|
if guild is None:
|
||||||
|
return False
|
||||||
name = guild.get_role(x.role_id).name
|
name = guild.get_role(x.role_id).name
|
||||||
return name == self._role_name or self._role_name in name
|
return name == self._role_name or self._role_name in name
|
||||||
|
|
||||||
|
@@ -57,6 +57,8 @@ class ShortRoleNameFilter(FilterABC):
|
|||||||
|
|
||||||
def get_role_name(x: ShortRoleName):
|
def get_role_name(x: ShortRoleName):
|
||||||
guild = self._bot.get_guild(x.server.discord_id)
|
guild = self._bot.get_guild(x.server.discord_id)
|
||||||
|
if guild is None:
|
||||||
|
return False
|
||||||
name = guild.get_role(x.role_id).name
|
name = guild.get_role(x.role_id).name
|
||||||
return name == self._role_name or self._role_name in name
|
return name == self._role_name or self._role_name in name
|
||||||
|
|
||||||
|
@@ -80,6 +80,8 @@ class UserFilter(FilterABC):
|
|||||||
|
|
||||||
def _get_member(user: User):
|
def _get_member(user: User):
|
||||||
guild = self._bot.get_guild(user.server.discord_id)
|
guild = self._bot.get_guild(user.server.discord_id)
|
||||||
|
if guild is None:
|
||||||
|
return False
|
||||||
member = guild.get_member(user.discord_id)
|
member = guild.get_member(user.discord_id)
|
||||||
return member is not None and (member.name == self._name or self._name in member.name)
|
return member is not None and (member.name == self._name or self._name in member.name)
|
||||||
|
|
||||||
|
@@ -15,7 +15,7 @@ __title__ = "bot_graphql.model"
|
|||||||
__author__ = "Sven Heidemann"
|
__author__ = "Sven Heidemann"
|
||||||
__license__ = "MIT"
|
__license__ = "MIT"
|
||||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||||
__version__ = "1.2.7"
|
__version__ = "1.2.11"
|
||||||
|
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
@@ -23,4 +23,4 @@ from collections import namedtuple
|
|||||||
# imports
|
# imports
|
||||||
|
|
||||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||||
version_info = VersionInfo(major="1", minor="2", micro="7")
|
version_info = VersionInfo(major="1", minor="2", micro="11")
|
||||||
|
@@ -15,7 +15,7 @@ __title__ = "bot_graphql.mutations"
|
|||||||
__author__ = "Sven Heidemann"
|
__author__ = "Sven Heidemann"
|
||||||
__license__ = "MIT"
|
__license__ = "MIT"
|
||||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||||
__version__ = "1.2.7"
|
__version__ = "1.2.11"
|
||||||
|
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
@@ -23,4 +23,4 @@ from collections import namedtuple
|
|||||||
# imports:
|
# imports:
|
||||||
|
|
||||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||||
version_info = VersionInfo(major="1", minor="2", micro="7")
|
version_info = VersionInfo(major="1", minor="2", micro="11")
|
||||||
|
@@ -6,7 +6,7 @@ from bot_data.abc.server_repository_abc import ServerRepositoryABC
|
|||||||
from bot_data.model.achievement import Achievement
|
from bot_data.model.achievement import Achievement
|
||||||
from bot_data.model.user_role_enum import UserRoleEnum
|
from bot_data.model.user_role_enum import UserRoleEnum
|
||||||
from bot_graphql.abc.query_abc import QueryABC
|
from bot_graphql.abc.query_abc import QueryABC
|
||||||
from bot_core.service.permission_service import PermissionService
|
from bot_core.service.permission_service_with_cache import PermissionServiceWithCache
|
||||||
|
|
||||||
|
|
||||||
class AchievementMutation(QueryABC):
|
class AchievementMutation(QueryABC):
|
||||||
@@ -16,7 +16,7 @@ class AchievementMutation(QueryABC):
|
|||||||
achievements: AchievementRepositoryABC,
|
achievements: AchievementRepositoryABC,
|
||||||
bot: DiscordBotServiceABC,
|
bot: DiscordBotServiceABC,
|
||||||
db: DatabaseContextABC,
|
db: DatabaseContextABC,
|
||||||
permissions: PermissionService,
|
permissions: PermissionServiceWithCache,
|
||||||
):
|
):
|
||||||
QueryABC.__init__(self, "AchievementMutation")
|
QueryABC.__init__(self, "AchievementMutation")
|
||||||
|
|
||||||
|
@@ -10,7 +10,7 @@ from bot_data.model.scheduled_event import ScheduledEvent
|
|||||||
from bot_data.model.scheduled_event_interval_enum import ScheduledEventIntervalEnum
|
from bot_data.model.scheduled_event_interval_enum import ScheduledEventIntervalEnum
|
||||||
from bot_data.model.user_role_enum import UserRoleEnum
|
from bot_data.model.user_role_enum import UserRoleEnum
|
||||||
from bot_graphql.abc.query_abc import QueryABC
|
from bot_graphql.abc.query_abc import QueryABC
|
||||||
from bot_core.service.permission_service import PermissionService
|
from bot_core.service.permission_service_with_cache import PermissionServiceWithCache
|
||||||
|
|
||||||
|
|
||||||
class ScheduledEventMutation(QueryABC):
|
class ScheduledEventMutation(QueryABC):
|
||||||
@@ -20,7 +20,7 @@ class ScheduledEventMutation(QueryABC):
|
|||||||
scheduled_events: ScheduledEventRepositoryABC,
|
scheduled_events: ScheduledEventRepositoryABC,
|
||||||
bot: DiscordBotServiceABC,
|
bot: DiscordBotServiceABC,
|
||||||
db: DatabaseContextABC,
|
db: DatabaseContextABC,
|
||||||
permissions: PermissionService,
|
permissions: PermissionServiceWithCache,
|
||||||
):
|
):
|
||||||
QueryABC.__init__(self, "ScheduledEventMutation")
|
QueryABC.__init__(self, "ScheduledEventMutation")
|
||||||
|
|
||||||
|
@@ -13,7 +13,7 @@ from bot_data.model.server_team_role_ids_config import ServerTeamRoleIdsConfig
|
|||||||
from bot_data.model.team_member_type_enum import TeamMemberTypeEnum
|
from bot_data.model.team_member_type_enum import TeamMemberTypeEnum
|
||||||
from bot_data.model.user_role_enum import UserRoleEnum
|
from bot_data.model.user_role_enum import UserRoleEnum
|
||||||
from bot_graphql.abc.query_abc import QueryABC
|
from bot_graphql.abc.query_abc import QueryABC
|
||||||
from bot_core.service.permission_service import PermissionService
|
from bot_core.service.permission_service_with_cache import PermissionServiceWithCache
|
||||||
|
|
||||||
|
|
||||||
class ServerConfigMutation(QueryABC):
|
class ServerConfigMutation(QueryABC):
|
||||||
@@ -25,7 +25,7 @@ class ServerConfigMutation(QueryABC):
|
|||||||
server_configs: ServerConfigRepositoryABC,
|
server_configs: ServerConfigRepositoryABC,
|
||||||
db: DatabaseContextABC,
|
db: DatabaseContextABC,
|
||||||
config_service: ConfigService,
|
config_service: ConfigService,
|
||||||
permissions: PermissionService,
|
permissions: PermissionServiceWithCache,
|
||||||
):
|
):
|
||||||
QueryABC.__init__(self, "ServerConfigMutation")
|
QueryABC.__init__(self, "ServerConfigMutation")
|
||||||
|
|
||||||
|
@@ -6,7 +6,7 @@ from bot_data.abc.short_role_name_repository_abc import ShortRoleNameRepositoryA
|
|||||||
from bot_data.model.short_role_name import ShortRoleName
|
from bot_data.model.short_role_name import ShortRoleName
|
||||||
from bot_data.model.user_role_enum import UserRoleEnum
|
from bot_data.model.user_role_enum import UserRoleEnum
|
||||||
from bot_graphql.abc.query_abc import QueryABC
|
from bot_graphql.abc.query_abc import QueryABC
|
||||||
from bot_core.service.permission_service import PermissionService
|
from bot_core.service.permission_service_with_cache import PermissionServiceWithCache
|
||||||
from modules.short_role_name.service.short_role_name_service import ShortRoleNameService
|
from modules.short_role_name.service.short_role_name_service import ShortRoleNameService
|
||||||
|
|
||||||
|
|
||||||
@@ -17,7 +17,7 @@ class ShortRoleNameMutation(QueryABC):
|
|||||||
short_role_names: ShortRoleNameRepositoryABC,
|
short_role_names: ShortRoleNameRepositoryABC,
|
||||||
bot: DiscordBotServiceABC,
|
bot: DiscordBotServiceABC,
|
||||||
db: DatabaseContextABC,
|
db: DatabaseContextABC,
|
||||||
permissions: PermissionService,
|
permissions: PermissionServiceWithCache,
|
||||||
short_role_name_service: ShortRoleNameService,
|
short_role_name_service: ShortRoleNameService,
|
||||||
):
|
):
|
||||||
QueryABC.__init__(self, "ShortRoleNameMutation")
|
QueryABC.__init__(self, "ShortRoleNameMutation")
|
||||||
|
@@ -16,7 +16,7 @@ from bot_data.model.technician_ping_url_config import TechnicianPingUrlConfig
|
|||||||
from bot_data.model.user_role_enum import UserRoleEnum
|
from bot_data.model.user_role_enum import UserRoleEnum
|
||||||
from bot_data.service.technician_config_seeder import TechnicianConfigSeeder
|
from bot_data.service.technician_config_seeder import TechnicianConfigSeeder
|
||||||
from bot_graphql.abc.query_abc import QueryABC
|
from bot_graphql.abc.query_abc import QueryABC
|
||||||
from bot_core.service.permission_service import PermissionService
|
from bot_core.service.permission_service_with_cache import PermissionServiceWithCache
|
||||||
|
|
||||||
|
|
||||||
class TechnicianConfigMutation(QueryABC):
|
class TechnicianConfigMutation(QueryABC):
|
||||||
@@ -31,7 +31,7 @@ class TechnicianConfigMutation(QueryABC):
|
|||||||
config_service: ConfigService,
|
config_service: ConfigService,
|
||||||
tech_seeder: TechnicianConfigSeeder,
|
tech_seeder: TechnicianConfigSeeder,
|
||||||
client_utils: ClientUtilsABC,
|
client_utils: ClientUtilsABC,
|
||||||
permissions: PermissionService,
|
permissions: PermissionServiceWithCache,
|
||||||
):
|
):
|
||||||
QueryABC.__init__(self, "TechnicianConfigMutation")
|
QueryABC.__init__(self, "TechnicianConfigMutation")
|
||||||
|
|
||||||
|
@@ -11,7 +11,7 @@ from flask import request
|
|||||||
from bot_api.configuration.authentication_settings import AuthenticationSettings
|
from bot_api.configuration.authentication_settings import AuthenticationSettings
|
||||||
from bot_core.configuration.feature_flags_enum import FeatureFlagsEnum
|
from bot_core.configuration.feature_flags_enum import FeatureFlagsEnum
|
||||||
from bot_core.configuration.feature_flags_settings import FeatureFlagsSettings
|
from bot_core.configuration.feature_flags_settings import FeatureFlagsSettings
|
||||||
from bot_core.service.permission_service import PermissionService
|
from bot_core.service.permission_service_with_cache import PermissionServiceWithCache
|
||||||
from bot_data.abc.api_key_repository_abc import ApiKeyRepositoryABC
|
from bot_data.abc.api_key_repository_abc import ApiKeyRepositoryABC
|
||||||
from bot_data.abc.game_server_repository_abc import GameServerRepositoryABC
|
from bot_data.abc.game_server_repository_abc import GameServerRepositoryABC
|
||||||
from bot_data.abc.server_repository_abc import ServerRepositoryABC
|
from bot_data.abc.server_repository_abc import ServerRepositoryABC
|
||||||
@@ -40,7 +40,7 @@ class UserJoinedGameServerMutation(QueryABC):
|
|||||||
user_game_idents: UserGameIdentRepositoryABC,
|
user_game_idents: UserGameIdentRepositoryABC,
|
||||||
bot: DiscordBotServiceABC,
|
bot: DiscordBotServiceABC,
|
||||||
db: DatabaseContextABC,
|
db: DatabaseContextABC,
|
||||||
permissions: PermissionService,
|
permissions: PermissionServiceWithCache,
|
||||||
auth_settings: AuthenticationSettings,
|
auth_settings: AuthenticationSettings,
|
||||||
):
|
):
|
||||||
QueryABC.__init__(self, "UserJoinedGameServerMutation")
|
QueryABC.__init__(self, "UserJoinedGameServerMutation")
|
||||||
|
@@ -4,7 +4,7 @@ from cpl_core.database.context import DatabaseContextABC
|
|||||||
from cpl_discord.service import DiscordBotServiceABC
|
from cpl_discord.service import DiscordBotServiceABC
|
||||||
|
|
||||||
from bot_api.route.route import Route
|
from bot_api.route.route import Route
|
||||||
from bot_core.service.permission_service import PermissionService
|
from bot_core.service.permission_service_with_cache import PermissionServiceWithCache
|
||||||
from bot_data.abc.level_repository_abc import LevelRepositoryABC
|
from bot_data.abc.level_repository_abc import LevelRepositoryABC
|
||||||
from bot_data.abc.server_repository_abc import ServerRepositoryABC
|
from bot_data.abc.server_repository_abc import ServerRepositoryABC
|
||||||
from bot_data.abc.user_repository_abc import UserRepositoryABC
|
from bot_data.abc.user_repository_abc import UserRepositoryABC
|
||||||
@@ -23,7 +23,7 @@ class UserMutation(QueryABC):
|
|||||||
users: UserRepositoryABC,
|
users: UserRepositoryABC,
|
||||||
bot: DiscordBotServiceABC,
|
bot: DiscordBotServiceABC,
|
||||||
db: DatabaseContextABC,
|
db: DatabaseContextABC,
|
||||||
permissions: PermissionService,
|
permissions: PermissionServiceWithCache,
|
||||||
levels: LevelRepositoryABC,
|
levels: LevelRepositoryABC,
|
||||||
level_service: LevelService,
|
level_service: LevelService,
|
||||||
user_warnings: UserWarningsRepositoryABC,
|
user_warnings: UserWarningsRepositoryABC,
|
||||||
|
@@ -15,7 +15,7 @@ __title__ = "bot_graphql.queries"
|
|||||||
__author__ = "Sven Heidemann"
|
__author__ = "Sven Heidemann"
|
||||||
__license__ = "MIT"
|
__license__ = "MIT"
|
||||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||||
__version__ = "1.2.7"
|
__version__ = "1.2.11"
|
||||||
|
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
@@ -23,4 +23,4 @@ from collections import namedtuple
|
|||||||
# imports:
|
# imports:
|
||||||
|
|
||||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||||
version_info = VersionInfo(major="1", minor="2", micro="7")
|
version_info = VersionInfo(major="1", minor="2", micro="11")
|
||||||
|
@@ -15,7 +15,7 @@ __title__ = "bot_graphql.queries.discord"
|
|||||||
__author__ = "Sven Heidemann"
|
__author__ = "Sven Heidemann"
|
||||||
__license__ = "MIT"
|
__license__ = "MIT"
|
||||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||||
__version__ = "1.2.7"
|
__version__ = "1.2.11"
|
||||||
|
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
@@ -23,4 +23,4 @@ from collections import namedtuple
|
|||||||
# imports:
|
# imports:
|
||||||
|
|
||||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||||
version_info = VersionInfo(major="1", minor="2", micro="7")
|
version_info = VersionInfo(major="1", minor="2", micro="11")
|
||||||
|
@@ -8,7 +8,6 @@ from bot_data.abc.achievement_repository_abc import AchievementRepositoryABC
|
|||||||
from bot_data.abc.auto_role_repository_abc import AutoRoleRepositoryABC
|
from bot_data.abc.auto_role_repository_abc import AutoRoleRepositoryABC
|
||||||
from bot_data.abc.client_repository_abc import ClientRepositoryABC
|
from bot_data.abc.client_repository_abc import ClientRepositoryABC
|
||||||
from bot_data.abc.game_server_repository_abc import GameServerRepositoryABC
|
from bot_data.abc.game_server_repository_abc import GameServerRepositoryABC
|
||||||
from bot_data.abc.level_repository_abc import LevelRepositoryABC
|
|
||||||
from bot_data.abc.scheduled_event_repository_abc import ScheduledEventRepositoryABC
|
from bot_data.abc.scheduled_event_repository_abc import ScheduledEventRepositoryABC
|
||||||
from bot_data.abc.server_config_repository_abc import ServerConfigRepositoryABC
|
from bot_data.abc.server_config_repository_abc import ServerConfigRepositoryABC
|
||||||
from bot_data.abc.short_role_name_repository_abc import ShortRoleNameRepositoryABC
|
from bot_data.abc.short_role_name_repository_abc import ShortRoleNameRepositoryABC
|
||||||
@@ -31,6 +30,7 @@ from bot_graphql.filter.short_role_name_filter import ShortRoleNameFilter
|
|||||||
from bot_graphql.filter.user_filter import UserFilter
|
from bot_graphql.filter.user_filter import UserFilter
|
||||||
from bot_graphql.filter.user_warning_filter import UserWarningFilter
|
from bot_graphql.filter.user_warning_filter import UserWarningFilter
|
||||||
from bot_graphql.model.server_statistics import ServerStatistics
|
from bot_graphql.model.server_statistics import ServerStatistics
|
||||||
|
from modules.level.service.level_service import LevelService
|
||||||
|
|
||||||
|
|
||||||
class ServerQuery(DataQueryWithHistoryABC):
|
class ServerQuery(DataQueryWithHistoryABC):
|
||||||
@@ -41,7 +41,7 @@ class ServerQuery(DataQueryWithHistoryABC):
|
|||||||
db: DatabaseContextABC,
|
db: DatabaseContextABC,
|
||||||
auto_roles: AutoRoleRepositoryABC,
|
auto_roles: AutoRoleRepositoryABC,
|
||||||
clients: ClientRepositoryABC,
|
clients: ClientRepositoryABC,
|
||||||
levels: LevelRepositoryABC,
|
levels: LevelService,
|
||||||
game_servers: GameServerRepositoryABC,
|
game_servers: GameServerRepositoryABC,
|
||||||
users: UserRepositoryABC,
|
users: UserRepositoryABC,
|
||||||
ujs: UserJoinedServerRepositoryABC,
|
ujs: UserJoinedServerRepositoryABC,
|
||||||
|
@@ -15,7 +15,7 @@ __title__ = "modules.achievements"
|
|||||||
__author__ = "Sven Heidemann"
|
__author__ = "Sven Heidemann"
|
||||||
__license__ = "MIT"
|
__license__ = "MIT"
|
||||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||||
__version__ = "1.2.7"
|
__version__ = "1.2.11"
|
||||||
|
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
@@ -23,4 +23,4 @@ from collections import namedtuple
|
|||||||
# imports
|
# imports
|
||||||
|
|
||||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||||
version_info = VersionInfo(major="1", minor="2", micro="7")
|
version_info = VersionInfo(major="1", minor="2", micro="11")
|
||||||
|
@@ -4,7 +4,7 @@
|
|||||||
"Version": {
|
"Version": {
|
||||||
"Major": "1",
|
"Major": "1",
|
||||||
"Minor": "2",
|
"Minor": "2",
|
||||||
"Micro": "7"
|
"Micro": "11"
|
||||||
},
|
},
|
||||||
"Author": "Sven Heidemann",
|
"Author": "Sven Heidemann",
|
||||||
"AuthorEmail": "sven.heidemann@sh-edraft.de",
|
"AuthorEmail": "sven.heidemann@sh-edraft.de",
|
||||||
|
@@ -15,7 +15,7 @@ __title__ = "modules.achievements.commands"
|
|||||||
__author__ = "Sven Heidemann"
|
__author__ = "Sven Heidemann"
|
||||||
__license__ = "MIT"
|
__license__ = "MIT"
|
||||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||||
__version__ = "1.2.7"
|
__version__ = "1.2.11"
|
||||||
|
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
@@ -23,4 +23,4 @@ from collections import namedtuple
|
|||||||
# imports
|
# imports
|
||||||
|
|
||||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||||
version_info = VersionInfo(major="1", minor="2", micro="7")
|
version_info = VersionInfo(major="1", minor="2", micro="11")
|
||||||
|
@@ -15,7 +15,7 @@ __title__ = "modules.achievements.events"
|
|||||||
__author__ = "Sven Heidemann"
|
__author__ = "Sven Heidemann"
|
||||||
__license__ = "MIT"
|
__license__ = "MIT"
|
||||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||||
__version__ = "1.2.7"
|
__version__ = "1.2.11"
|
||||||
|
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
@@ -23,4 +23,4 @@ from collections import namedtuple
|
|||||||
# imports
|
# imports
|
||||||
|
|
||||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||||
version_info = VersionInfo(major="1", minor="2", micro="7")
|
version_info = VersionInfo(major="1", minor="2", micro="11")
|
||||||
|
@@ -50,7 +50,9 @@ class AchievementOnMessageEvent(OnMessageABC):
|
|||||||
return
|
return
|
||||||
|
|
||||||
server = self._servers.get_server_by_discord_id(message.guild.id)
|
server = self._servers.get_server_by_discord_id(message.guild.id)
|
||||||
user = self._users.get_user_by_discord_id_and_server_id(message.author.id, server.id)
|
user = self._users.find_user_by_discord_id_and_server_id(message.author.id, server.id)
|
||||||
|
if user is None:
|
||||||
|
return
|
||||||
|
|
||||||
user.message_count += 1
|
user.message_count += 1
|
||||||
self._users.update_user(user)
|
self._users.update_user(user)
|
||||||
|
@@ -15,7 +15,7 @@ __title__ = "modules.achievements.model"
|
|||||||
__author__ = "Sven Heidemann"
|
__author__ = "Sven Heidemann"
|
||||||
__license__ = "MIT"
|
__license__ = "MIT"
|
||||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||||
__version__ = "1.2.7"
|
__version__ = "1.2.11"
|
||||||
|
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
@@ -23,4 +23,4 @@ from collections import namedtuple
|
|||||||
# imports
|
# imports
|
||||||
|
|
||||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||||
version_info = VersionInfo(major="1", minor="2", micro="7")
|
version_info = VersionInfo(major="1", minor="2", micro="11")
|
||||||
|
@@ -15,7 +15,7 @@ __title__ = "modules.auto_role"
|
|||||||
__author__ = "Sven Heidemann"
|
__author__ = "Sven Heidemann"
|
||||||
__license__ = "MIT"
|
__license__ = "MIT"
|
||||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||||
__version__ = "1.2.7"
|
__version__ = "1.2.11"
|
||||||
|
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
@@ -23,4 +23,4 @@ from collections import namedtuple
|
|||||||
# imports:
|
# imports:
|
||||||
|
|
||||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||||
version_info = VersionInfo(major="1", minor="2", micro="7")
|
version_info = VersionInfo(major="1", minor="2", micro="11")
|
||||||
|
@@ -4,7 +4,7 @@
|
|||||||
"Version": {
|
"Version": {
|
||||||
"Major": "1",
|
"Major": "1",
|
||||||
"Minor": "2",
|
"Minor": "2",
|
||||||
"Micro": "7"
|
"Micro": "11"
|
||||||
},
|
},
|
||||||
"Author": "",
|
"Author": "",
|
||||||
"AuthorEmail": "",
|
"AuthorEmail": "",
|
||||||
|
@@ -15,7 +15,7 @@ __title__ = "modules.auto_role.command"
|
|||||||
__author__ = "Sven Heidemann"
|
__author__ = "Sven Heidemann"
|
||||||
__license__ = "MIT"
|
__license__ = "MIT"
|
||||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||||
__version__ = "1.2.7"
|
__version__ = "1.2.11"
|
||||||
|
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
@@ -23,4 +23,4 @@ from collections import namedtuple
|
|||||||
# imports:
|
# imports:
|
||||||
|
|
||||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||||
version_info = VersionInfo(major="1", minor="2", micro="7")
|
version_info = VersionInfo(major="1", minor="2", micro="11")
|
||||||
|
@@ -15,7 +15,7 @@ __title__ = "modules.auto_role.events"
|
|||||||
__author__ = "Sven Heidemann"
|
__author__ = "Sven Heidemann"
|
||||||
__license__ = "MIT"
|
__license__ = "MIT"
|
||||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
||||||
__version__ = "1.2.7"
|
__version__ = "1.2.11"
|
||||||
|
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
@@ -23,4 +23,4 @@ from collections import namedtuple
|
|||||||
# imports:
|
# imports:
|
||||||
|
|
||||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||||
version_info = VersionInfo(major="1", minor="2", micro="7")
|
version_info = VersionInfo(major="1", minor="2", micro="11")
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user