Compare commits

...
This repository has been archived on 2022-07-14. You can view files and clone it, but cannot push or open issues or pull requests.

243 Commits
master ... 0.4

Author SHA1 Message Date
0f2f17b1f4 Merge remote-tracking branch 'origin/0.4' into 0.4 2022-06-29 18:51:09 +02:00
e7747a306f Updated to cpl 2022.6 and added user info config 2022-06-29 18:51:06 +02:00
8a1dfb92f8 Updated to cpl 2022.6 and added user info config 2022-06-29 18:50:57 +02:00
ef276564d2 Updated config 2022-06-29 18:17:03 +02:00
f8fe9af8da Merge pull request '0.4.2 - user-info Befehl' (#45) from 0.4.2 into 0.4
Reviewed-on: #45
2022-01-15 19:01:56 +01:00
db175b5b28 Updated config 2022-01-15 18:59:32 +01:00
4bbb2b5c45 Added user-info command & fixed info command 2022-01-15 18:59:15 +01:00
c74a74a3c5 Changed version 2022-01-15 16:42:41 +01:00
3ae2b68528 Changed version 2022-01-15 16:42:09 +01:00
2deeecf8ff Merge pull request '0.4.9 - Info Befehl' (#44) from 0.4.9 into 0.4
Reviewed-on: #44
2022-01-15 16:40:23 +01:00
8416eaf32a Updated config 2022-01-15 16:38:30 +01:00
5489cc96b4 Added info command & Added dynamic embed 2022-01-15 16:38:15 +01:00
82ba1ae904 Merge pull request '0.4.8' (#43) from 0.4.8 into 0.4
Reviewed-on: #43
closes #21
2022-01-15 14:53:43 +01:00
a5267a793d Added help command & improved message service 2022-01-15 14:51:50 +01:00
010bb65ba7 Changed version 2022-01-15 14:34:07 +01:00
b5d5e0cf66 Merge branch '0.4' into 0.4.8 2022-01-15 14:33:40 +01:00
c968fbb3d7 Registered services 2022-01-15 14:33:09 +01:00
0ef2428b9d [WIP] Added client utils service & Split up base command service 2022-01-15 13:56:17 +01:00
e17b24a0c1 Changed version 2022-01-15 13:29:56 +01:00
234a9a382a Improved module, event and settings loading 2022-01-15 11:47:59 +01:00
Cora Cordes
9eef94baf2 Fixed module loading & added config 2022-01-13 20:18:21 +01:00
ca7798987c Updated dependencies 2022-01-11 10:56:54 +01:00
e825a708ac Improved base config 2022-01-09 10:53:57 +01:00
a4df809916 Improved config 2022-01-09 10:48:47 +01:00
6bfcd4748d Added config submodule 2022-01-09 10:43:24 +01:00
dee76b4d0d [WIP] Removed config 2022-01-09 10:40:44 +01:00
01a7b1f996 [WIP] Removed idea settings 2022-01-09 10:40:02 +01:00
c04389ecaf Added example config 2022-01-09 00:31:54 +01:00
fcf1d2038b Improved parallel tasks in afk command 2022-01-08 19:42:25 +01:00
558d134bd7 Bugfixes for last changes 2022-01-08 19:35:14 +01:00
26963b2bef Build application 2022-01-08 19:19:34 +01:00
bc8ff7dc0f Added PyCharm support to permission module 2022-01-08 19:18:06 +01:00
7d4a28d524 Added PyCharm support to database module 2022-01-08 19:14:58 +01:00
d83e842551 Added PyCharm support to boot-log module 2022-01-08 19:08:13 +01:00
0c142f51cc Added PyCharm support to base module 2022-01-08 19:07:31 +01:00
291d9ad6d6 Added PyCharm support (fixed typing and so on) 2022-01-08 19:02:50 +01:00
7f3541c5c8 Merge pull request '0.4.3' (#41) from 0.4.3 into 0.4
Reviewed-on: #41
Closes #16
2022-01-07 14:56:52 +01:00
Cora Cordes
0662be7b79 Added logic to save bot data 2022-01-07 14:50:32 +01:00
Cora Cordes
853c1262e7 Added logic to move user to afk channel 2022-01-07 14:35:27 +01:00
Cora Cordes
dc025170e1 Added settings 2022-01-07 13:17:00 +01:00
Cora Cordes
c9a5a64c7b Changed version 2022-01-06 21:14:20 +01:00
bed3f07347 Added permission check to command 2021-12-31 12:05:10 +01:00
ab44aa55bc Added purge command 2021-12-31 11:52:37 +01:00
ed2dab6ff8 Added logic to add commands 2021-12-31 11:42:09 +01:00
7dd2d13b58 Moved modules_core -> gismo_core 2021-12-31 10:18:24 +01:00
b352987dcc Improved permission role handling 2021-12-29 21:01:58 +01:00
a8663b8d54 Improved permission handling 2021-12-29 20:41:15 +01:00
ff247bcec3 [WIP] Added permission module 2021-12-29 19:29:35 +01:00
500d884ea1 Added better config handling to modules 2021-12-27 19:54:10 +01:00
2f657a7ce7 [WIP] Improved configuration handling 2021-12-27 19:41:16 +01:00
4db97248ca Improved config loading 2021-12-27 19:32:12 +01:00
40419c9a0b Merge pull request 'A-0.3 - Basismodul' (#36) from 0.3 into Alpha
Reviewed-on: #36
Closed #9
2021-12-27 18:17:41 +01:00
dadaa6ac09 Added logic to send team message when user joined 2021-12-27 18:14:59 +01:00
10ba511158 Added handling of members who are already online on startup 2021-12-27 18:03:46 +01:00
09a4ace867 Fixed dazabase assignment bug 2021-12-21 18:47:58 +01:00
b436daeb35 Rounded ontime 2021-12-21 18:43:00 +01:00
daa031bc57 Added logic to handle xp 2021-12-21 18:12:09 +01:00
286c653252 Fixed bug in database module 2021-12-21 17:24:16 +01:00
Sven Heidemann
3eaae4679f Added logic to check table at startup 2021-12-21 15:39:46 +01:00
Sven Heidemann
39079b2b58 Added user joined voice channel repo 2021-12-21 15:00:00 +01:00
Sven Heidemann
fcc5b882b7 Added user joined voice channel model 2021-12-21 14:37:38 +01:00
42826a1914 Improved config 2021-12-08 19:12:54 +01:00
2ae0a99783 build and improved config 2021-12-08 19:11:36 +01:00
51fd8f7a8b Build with new version 2021-12-08 19:08:20 +01:00
291efd2319 Build project 2021-12-08 19:07:52 +01:00
0b17b27bd0 Removed debug exit 2021-12-08 19:00:22 +01:00
f800a11f41 Added logic to check in db if user already left before starting 2021-12-08 18:53:25 +01:00
7e6485459b Fixed user_joined_server repo 2021-12-08 18:42:52 +01:00
789186454e Removed comment 2021-12-08 18:35:31 +01:00
49aa2f3aa3 Put welcome and goodbye messages into config 2021-12-08 18:34:32 +01:00
199c269804 Added logic to handle on_member_join & remove 2021-12-08 18:26:51 +01:00
adc74d6288 Fixed server repo 2021-12-08 17:59:22 +01:00
c6e52039cb Fixed database module 2021-12-08 17:45:05 +01:00
4955eb3a19 Fixed database module 2021-12-08 17:42:21 +01:00
9d17070d02 Fixed user repo error 2021-12-08 17:40:50 +01:00
f417eca644 Added check for known user at on_member_join 2021-12-08 17:32:55 +01:00
a10724a495 Fixed return error 2021-12-08 07:50:35 +01:00
e3ac78f97b Fixed argument error 2021-12-08 07:49:52 +01:00
68c1bc0bc3 Added logic to save client data 2021-12-08 07:48:55 +01:00
be5567c1fd Added helper functions to append client values 2021-12-08 07:41:09 +01:00
e34fbb60aa Added logic to append received messages 2021-12-08 07:36:54 +01:00
f03ee54703 Added find function to client repo 2021-12-08 07:14:50 +01:00
9bae6c3c13 Improved database on_ready 2021-12-07 17:36:19 +01:00
e73ebeb052 Added UserJoinedServer Repo 2021-12-07 17:15:13 +01:00
5fce7318ae Removed unused sql statement 2021-12-07 16:53:03 +01:00
d1298606f3 Removed get_create_table_string 2021-12-07 16:42:47 +01:00
ca361b63cb Added migration logic 2021-12-07 16:38:42 +01:00
d5de1991eb Fixed loop and model handling 2021-12-07 15:16:39 +01:00
22b0c3ca6a Removed old imports 2021-12-02 18:08:19 +01:00
1d09ad80bf Added UserJoinedServer model 2021-12-02 18:07:43 +01:00
c949efea50 Improved database module 2021-12-02 17:51:11 +01:00
0fd99cc6ba Added repos to startup 2021-12-02 17:41:44 +01:00
2c29b45f5a Added known user repos 2021-12-02 17:40:23 +01:00
b8e340f661 Added known user model 2021-12-02 17:35:03 +01:00
026dfe0dfb Added logic to load clients on_ready 2021-12-01 20:49:58 +01:00
d27964372d Added getter 2021-12-01 20:30:27 +01:00
e15ae555be Added client repos 2021-12-01 20:19:34 +01:00
ce70e816fe Improved other models 2021-12-01 20:03:14 +01:00
60172e0cfe Added client model 2021-12-01 20:03:06 +01:00
62d56a2247 Created base module 2021-12-01 19:34:39 +01:00
be692326d6 Merge pull request 'A-0.2 - Datenbankverbindung' (#35) from 0.2 into Alpha
Reviewed-on: #35
2021-12-01 17:57:51 +01:00
074fa1ed46 Removed configs 2021-12-01 17:53:36 +01:00
93269908bc Improved database connection 2021-11-30 17:59:44 +01:00
0bb5024c6a Added intents 2021-11-30 17:22:37 +01:00
9c7b00e259 Fixed None check 2021-11-30 16:00:04 +01:00
1a5767edf0 Improved find 2021-11-30 15:56:35 +01:00
7bcd632b59 Added find by dc id to repos 2021-11-30 15:55:17 +01:00
20aedba23d Improved data repository 2021-11-30 15:41:10 +01:00
1d4a6c3e3b Improved db context logging 2021-11-30 15:18:07 +01:00
61101eb576 Improved database 2021-11-30 15:13:36 +01:00
14ecc46d92 Added database context 2021-11-30 14:51:58 +01:00
01cf17ef86 Build with new version 2021-11-30 13:49:33 +01:00
c5d2639e0a Updated cpl=2021.10 -> 2021.11 2021-11-30 13:48:50 +01:00
6356d455f4 Removed cpl-extension project 2021-11-30 13:46:53 +01:00
0029fc4ac8 Improved scripts 2021-11-29 09:56:19 +01:00
cbb73d7c86 Readded scripts 2021-11-29 09:31:17 +01:00
68694d2e13 Renamed project 2021-11-28 23:34:45 +01:00
762ae5fd4d Improved module loading 2021-11-28 23:31:36 +01:00
ed1cb24e9c Improved executable 2021-11-26 08:39:19 +01:00
e489787f01 Added executable 2021-11-26 08:26:56 +01:00
d668d0138f Improved working directory 2021-11-26 08:08:48 +01:00
7c77768697 Build projects 2021-11-26 08:01:45 +01:00
8108f83b92 Removed appsettings 2021-11-26 07:55:31 +01:00
afd024e991 Improved project files 2021-11-26 07:55:13 +01:00
e69955e6d2 Merge pull request '0.1 - Modularer Aufbau' (#13) from 0.1 into Alpha
Reviewed-on: #13
2021-11-25 21:02:12 +01:00
df26a66562 Fixed typo 2021-11-25 20:55:59 +01:00
c6f460c0ab Build packages 2021-11-25 20:45:16 +01:00
3390e09ef3 Added logic to prevent further event redirects if needed 2021-11-25 17:43:43 +01:00
ed9a3bc90c Improved custom commands 2021-11-25 17:29:31 +01:00
2e24a3b1f2 Improved module priority handling 2021-11-24 16:51:36 +01:00
f4c340796e Improved workspace scripts 2021-11-23 19:11:00 +01:00
4edda07cee Improved logging 2021-11-23 17:32:03 +01:00
e951baa358 Improved configs 2021-11-23 17:27:43 +01:00
2d261a6222 Improved config & chnaged logging 2021-11-23 17:23:11 +01:00
1f095c9415 Added imports 2021-11-23 17:19:46 +01:00
a8551f2f95 Added event redirect to modules 2021-11-23 17:18:06 +01:00
3806c36571 Improved event handling 2021-11-23 16:46:20 +01:00
a5f710177e Changed banner 2021-11-23 16:04:03 +01:00
5a91e31964 Improved event listeners 2021-11-22 21:16:09 +01:00
112b9d6208 Added logic to handle event priority 2021-11-22 21:11:45 +01:00
be810a6533 Improved event handling with commands.Cog.listener 2021-11-22 20:08:46 +01:00
9ebbd7ccf7 Removed unused import 2021-11-22 17:48:32 +01:00
0b5f47ab8a Improved bot banner 2021-11-22 17:42:57 +01:00
Cora Cordes
00a0c182be Removed unused lines 2021-11-20 19:42:06 +01:00
Cora Cordes
d7105b9d19 Merge branch '0.1' of https://git.sh-edraft.de/sh-edraft.de/sh_gismo into 0.1 2021-11-20 19:12:19 +01:00
Cora Cordes
73fedd31dc Added on_guild_integration_update event abc 2021-11-20 19:12:09 +01:00
Cora Cordes
c9a5f648a2 Added on_guild_channel_pins_update event abc 2021-11-20 19:10:41 +01:00
Cora Cordes
76642112ab Added on_guild_channel_update event abc 2021-11-20 19:09:40 +01:00
Cora Cordes
5e646d394b Added on_guild_channel_delete event abc 2021-11-20 19:08:36 +01:00
Cora Cordes
2ab2ef3776 Added on_private_channel_pins_update event abc 2021-11-20 19:07:00 +01:00
7780b43e11 Removed line break 2021-11-20 19:06:45 +01:00
Cora Cordes
ffad565520 Added on_private_channel_update event abc 2021-11-20 19:06:04 +01:00
f033eeaf87 Added on_voice_state_update event abc 2021-11-20 19:05:50 +01:00
3b4b81eba0 Added on_guild_unavailable event abc 2021-11-20 19:05:23 +01:00
Cora Cordes
4e00da99b5 Added on_private_channel_create event abc 2021-11-20 19:05:17 +01:00
3fc3b9548a Added on_guild_available event abc 2021-11-20 19:04:53 +01:00
9cbc589d62 Added on_guild_emojis_update event abc 2021-11-20 19:04:21 +01:00
Cora Cordes
e351b98fe4 Added on_guild_channel_create event abc 2021-11-20 19:04:17 +01:00
a2e52e473c Added on_guild_role_update event abc 2021-11-20 19:03:31 +01:00
463456711d Added on_guild_role_delete event abc 2021-11-20 19:03:02 +01:00
4d69250342 Added on_guild_role_create event abc 2021-11-20 19:02:27 +01:00
Cora Cordes
276910c86d Added on_private_channel_delete event abc 2021-11-20 19:02:25 +01:00
b0c75fa651 Added on_guild_update event abc 2021-11-20 19:01:57 +01:00
Cora Cordes
e81449031e Added on_reaction_clear_emoij event abc 2021-11-20 19:01:32 +01:00
4176db9f91 Added on_guild_remove event abc 2021-11-20 19:01:20 +01:00
14d543a587 Added on_guild_join event abc 2021-11-20 19:00:35 +01:00
d1740edda0 Added on_user_update event abc 2021-11-20 19:00:04 +01:00
Cora Cordes
1edcfe58d2 Added on_reaction_clear event abc 2021-11-20 18:59:56 +01:00
2c7755310d Added on_member_update event abc 2021-11-20 18:59:35 +01:00
aeef7ed477 Added on_member_remove event abc 2021-11-20 18:59:02 +01:00
e83982fc2a Added on_member_join event abc 2021-11-20 18:58:35 +01:00
Cora Cordes
acc106a567 Added on_reaction_remove event abc 2021-11-20 18:58:29 +01:00
67696bc63c Added on_webhooks_update event abc 2021-11-20 18:57:55 +01:00
Cora Cordes
c9f28ddc14 Added on_reaction_add event abc 2021-11-20 18:57:45 +01:00
Cora Cordes
b903ec5434 Added on_message_edit event abc 2021-11-20 18:54:59 +01:00
Cora Cordes
81bf7b6250 Merge branch '0.1' of https://git.sh-edraft.de/sh-edraft.de/sh_gismo into 0.1 2021-11-20 18:53:33 +01:00
Cora Cordes
bef8ea0a25 Added on_bulk_message_delete event abc 2021-11-20 18:51:48 +01:00
558b6628a3 Added on_bulk_message_delete event abc 2021-11-20 16:59:16 +01:00
15af3b1f63 Added import to on_typing event abc 2021-11-20 16:58:30 +01:00
a2ebf4e3b5 Merge branch '0.1' of https://git.sh-edraft.de/sh-edraft.de/sh_gismo into 0.1 2021-11-20 16:55:43 +01:00
Cora Cordes
3d56ef1dd5 Merge branch '0.1' of https://git.sh-edraft.de/sh-edraft.de/sh_gismo into 0.1 2021-11-20 16:54:55 +01:00
Cora Cordes
b429d60bcd Added on_message_delete event ABC 2021-11-20 16:53:54 +01:00
7edef25617 Added on_member_ban event abc 2021-11-20 16:47:59 +01:00
4d7c67a3b6 Added on_member_unban event abc 2021-11-20 16:42:12 +01:00
426772910f Added on_invite_create event abc 2021-11-20 16:41:29 +01:00
04179ce906 Added on_invite_delete event abc 2021-11-20 16:39:55 +01:00
Cora Cordes
c3e1aaf40f Added on_typing update event ABC 2021-11-20 16:39:36 +01:00
49ec7ea931 Added on_group_join event abc 2021-11-20 16:39:15 +01:00
Cora Cordes
c0d38817d4 Added on_error update event ABC 2021-11-20 16:38:46 +01:00
31682f2b83 Added on_group_remove event abc 2021-11-20 16:38:23 +01:00
Cora Cordes
a56bdf39f7 Added on_resume update event ABC 2021-11-20 16:36:52 +01:00
89c31c6392 Added on_relationship_add event abc 2021-11-20 16:36:22 +01:00
0730c5f915 Added on_relationship_remove event abc 2021-11-20 16:35:56 +01:00
Cora Cordes
ae7f6543f3 Added on_disconnect update event ABC 2021-11-20 16:35:21 +01:00
Cora Cordes
711819cdea Added config 2021-11-20 16:31:31 +01:00
85931926c3 Merge branch '0.1' of https://git.sh-edraft.de/sh-edraft.de/sh_gismo into 0.1 2021-11-20 16:24:27 +01:00
d99cec79b9 Added on_relationship_update event abc 2021-11-20 16:24:12 +01:00
Cora Cordes
8461d793de Added on_connect ABC 2021-11-20 16:19:18 +01:00
Cora Cordes
baa86b75e7 Rechtschreibfehler korregiert 2021-11-20 15:58:22 +01:00
Cora Cordes
652a3eeb47 Farbe geaendert 2021-11-20 15:57:46 +01:00
03d427b520 Improved config 2021-11-20 12:13:14 +01:00
7a9e127df3 Improved package files 2021-11-19 09:21:04 +01:00
118ba99b92 Renamed application class 2021-11-19 08:58:38 +01:00
2914308d65 Fixed typos 2021-11-19 08:55:42 +01:00
732d28e5dc Fixed typos 2021-11-18 17:42:45 +01:00
cb8c090ab3 Added event abc files 2021-11-18 09:05:10 +01:00
5cbd40ec03 Moved event abc & added event function (without content) to ModuleService 2021-11-18 08:51:15 +01:00
3832f9b8fc Added events to ModuleServiceABC 2021-11-18 08:46:19 +01:00
d6b65c42cc Removed vs code file 2021-11-17 19:44:23 +01:00
6509f628ca Added on_message handling 2021-11-17 19:43:00 +01:00
5b61de0bf1 Added ctrl+c support 2021-11-17 19:35:42 +01:00
5afbdb9b82 Added start script & helper file 2021-11-17 18:45:57 +01:00
880fe8a4c7 Added on_message to abc 2021-11-16 21:03:14 +01:00
12492cf596 Added on_message event 2021-11-16 21:01:16 +01:00
9584b34f8f Improved logging to message service 2021-11-16 20:48:53 +01:00
5e1caf713c Improved message service & added logic to send login message 2021-11-16 20:37:51 +01:00
c254114987 Added delete_message to ABC 2021-11-16 20:19:47 +01:00
81499ef8e6 Added logic to send context messages 2021-11-16 20:19:19 +01:00
b0b646bb2b Added logic to send dm messages 2021-11-16 20:12:42 +01:00
e8e6a28d87 Added logic to delete message & send channel message 2021-11-16 20:07:48 +01:00
26e1ed7496 Added message service 2021-11-16 19:06:09 +01:00
d2c233a855 Improved bot startup logic 2021-11-16 18:34:41 +01:00
2176037d08 Improved logging 2021-11-16 11:41:34 +01:00
16546b4d3c Improved imports 2021-11-16 11:12:42 +01:00
9c25ec9f24 Improved logging for BootLog module 2021-11-16 09:41:55 +01:00
d413ace721 Improved BootLog module 2021-11-16 09:12:44 +01:00
647e847d17 Improved logging 2021-11-15 21:54:06 +01:00
f2ee3d64f6 Improved dynamic modules support 2021-11-15 21:52:28 +01:00
4763c41b10 Improved log statements 2021-11-15 21:25:57 +01:00
562caeb10b Added support for dynamic loaded modules 2021-11-15 21:23:06 +01:00
a3bf5535f6 Improved BootLog module 2021-11-15 20:38:57 +01:00
26a93c5ea1 Added functionality to connect to discord web api 2021-11-15 20:34:15 +01:00
abe9a7b472 Improved files 2021-11-15 19:36:39 +01:00
97a3ba24a6 Added some config files 2021-11-15 18:09:34 +01:00
b1becbe866 Improved tools 2021-11-15 17:05:48 +01:00
059e345751 Added vs code settings 2021-11-15 11:29:10 +01:00
744501b3c2 Improved projects files 2021-11-15 01:27:32 +01:00
056335e84b Added project references 2021-11-15 01:24:10 +01:00
eda1caf36a Renamed projects 2021-11-15 01:22:20 +01:00
c82e8e3065 Added tool projects 2021-11-15 01:18:33 +01:00
bca2e02cc2 Added database projects 2021-11-15 01:09:41 +01:00
1927860206 Added boot-log project 2021-11-15 01:07:54 +01:00
24ae39d9f6 Added first projects 2021-11-15 00:52:49 +01:00
159 changed files with 6364 additions and 1 deletions

6
.gitignore vendored
View File

@ -138,3 +138,9 @@ dmypy.json
# Cython debug symbols
cython_debug/
# custom vs code
PythonImportHelper-v2-Completion.json
appsettings.*.json
# idea
.idea/

3
.gitmodules vendored Normal file
View File

@ -0,0 +1,3 @@
[submodule "src/gismo/config"]
path = src/gismo/config
url = https://git.sh-edraft.de/sh-edraft.de/sh_gismo_config.git

View File

@ -1,4 +1,4 @@
MIT License Copyright (c) <year> <copyright holders>
MIT License Copyright (c) 2021-2022 sh-edraft.de
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

33
cpl-workspace.json Normal file
View File

@ -0,0 +1,33 @@
{
"WorkspaceSettings": {
"DefaultProject": "gismo",
"Projects": {
"gismo": "src/gismo/gismo.json",
"gismo-cli": "src/gismo_cli/gismo-cli.json",
"gismo-core": "src/gismo_core/gismo-core.json",
"gismo-data": "src/gismo_data/gismo-data.json",
"boot-log": "src/modules/boot_log/boot-log.json",
"level-generator": "tools/level_generator/level-generator.json",
"ontime-calculator": "tools/ontime_calculator/ontime-calculator.json",
"database": "src/modules/database/database.json",
"base": "src/modules/base/base.json",
"permission": "src/modules/permission/permission.json"
},
"Scripts": {
"build-gismo": "cd src/gismo; echo 'gismo:'; cpl build; cd ../../;",
"build-gismo-cli": "cd src/gismo_cli; echo 'gismo-cli:'; cpl build; cd ../../;",
"build-start": "cpl build-gismo-cli; cpl build-gismo; cd dist/gismo/build/gismo; bash gismo",
"bs": "cpl build-start",
"build-all": "cpl build-gismo-cli; cpl build-gismo;",
"ba": "cpl build-all",
"pre-build": "cd ../gismo_cli; echo 'gismo-cli:'; cpl build; echo 'gismo:'",
"pre-start": "if [ -z $GISMO_ENVIRONMENT ]; then echo '!WARNING! You should start with the right environment!\nRun cpl start-ENV\nSee workspace for more details.'; sleep 2; fi",
"pre-dev": "echo 'development:';",
"dev": "export GISMO_ENVIRONMENT=development; export GISMO_NAME=Gismo-dev; cpl start",
"pre-test": "echo 'staging:';",
"test": "export GISMO_ENVIRONMENT=staging; export GISMO_NAME=Gismo-test; cpl start",
"pre-prod": "echo 'production:';",
"prod": "export GISMO_ENVIRONMENT=production; export GISMO_NAME=Gismo-prod; cpl start"
}
}
}

25
src/gismo/__init__.py Normal file
View File

@ -0,0 +1,25 @@
# -*- coding: utf-8 -*-
"""
gismo sh-edraft Gismo
~~~~~~~~~~~~~~~~~~~
sh-edraft Dicord bot Gismo
:copyright: (c) 2021 - 2022 sh-edraft.de
:license: MIT, see LICENSE for more details.
"""
__title__ = 'gismo'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2021 - 2022 sh-edraft.de'
__version__ = '0.4.2'
from collections import namedtuple
# imports:
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='0', minor='4', micro='2')

46
src/gismo/application.py Normal file
View File

@ -0,0 +1,46 @@
from cpl_core.application import ApplicationABC
from cpl_core.configuration import ConfigurationABC
from cpl_core.console import Console
from cpl_core.dependency_injection import ServiceProviderABC
from cpl_core.logging import LoggerABC
from gismo_core.abc.bot_service_abc import BotServiceABC
from gismo_core.configuration.bot_settings import BotSettings
from gismo_core.configuration.server_settings import ServerSettings
from gismo_core.service.bot_service import BotService
class Gismo(ApplicationABC):
def __init__(self, config: ConfigurationABC, services: ServiceProviderABC):
ApplicationABC.__init__(self, config, services)
self._bot: BotService = services.get_service(BotServiceABC)
self._logger: LoggerABC = services.get_service(LoggerABC)
self._bot_settings: BotSettings = config.get_configuration(BotSettings)
async def configure(self):
self._logger.debug(__name__, 'Try to load discord server configs')
for server in self._bot_settings.servers:
server: ServerSettings = server
self._logger.trace(__name__, f'Try to load config for server: {server.id}')
self._configuration.add_configuration(f'DSERVER_{server.id}', server)
self._logger.trace(__name__, f'Loaded config for server: {server.id}')
async def main(self):
try:
self._logger.debug(__name__, f'Starting...\n')
self._logger.trace(__name__, f'Try to start {BotService}')
await self._bot.start_async()
except Exception as e:
self._logger.error(__name__, 'Start failed', e)
async def stop_async(self):
try:
self._logger.trace(__name__, f'Try to stop {BotService}')
await self._bot.close()
self._logger.trace(__name__, f'Stopped {BotService}')
except Exception as e:
self._logger.error(__name__, 'stop failed', e)
Console.write_line()

1
src/gismo/config Submodule

@ -0,0 +1 @@
Subproject commit 83fd51adff8a99af2ef3456542901ec78d4e1946

24
src/gismo/gismo Normal file
View File

@ -0,0 +1,24 @@
#!/bin/bash
path="`dirname \"$0\"`" # relative
path="`( cd \"$path\" && pwd)`" # absolutized and normalized
cd "$path/../"
if [[ $1 == "-dev" ]]; then
export GISMO_ENVIRONMENT=development
export GISMO_NAME=Gismo-dev
elif [[ $1 == "-test" ]]; then
export GISMO_ENVIRONMENT=staging
export GISMO_NAME=Gismo-test
elif [[ $1 == "-server" ]]; then
export GISMO_ENVIRONMENT=production
export GISMO_NAME=Gismo
else
export GISMO_ENVIRONMENT=production
export GISMO_NAME=Gismo-prod
fi
export PYTHONPATH=./:$PYTHONPATH
python3.9 gismo/main.py

57
src/gismo/gismo.json Normal file
View File

@ -0,0 +1,57 @@
{
"ProjectSettings": {
"Name": "gismo",
"Version": {
"Major": "0",
"Minor": "4",
"Micro": "2"
},
"Author": "Sven Heidemann",
"AuthorEmail": "sven.heidemann@sh-edraft.de",
"Description": "sh-edraft Gismo",
"LongDescription": "sh-edraft Dicord bot Gismo",
"URL": "https://www.sh-edraft.de",
"CopyrightDate": "2021 - 2022",
"CopyrightName": "sh-edraft.de",
"LicenseName": "MIT",
"LicenseDescription": "MIT, see LICENSE for more details.",
"Dependencies": [
"cpl-core>=2022.6.0",
"discord.py==1.7.3",
"cpl-query>=2022.6.0"
],
"DevDependencies": [],
"PythonVersion": ">=3.9.2",
"PythonPath": {
"linux": "../../venv/bin/python"
},
"Classifiers": []
},
"BuildSettings": {
"ProjectType": "console",
"SourcePath": "",
"OutputPath": "../../dist",
"Main": "gismo.main",
"EntryPoint": "gismo",
"IncludePackageData": false,
"Included": [],
"Excluded": [
"*/__pycache__",
"*/logs",
"*/tests"
],
"PackageData": {
"cpl_cli": [
"*.json"
]
},
"ProjectReferences": [
"../gismo_core/gismo-core.json",
"../gismo_data/gismo-data.json",
"../modules/boot_log/boot-log.json",
"../modules/base/base.json",
"../modules/database/database.json",
"../modules/permission/permission.json"
]
}
}

47
src/gismo/main.py Normal file
View File

@ -0,0 +1,47 @@
import asyncio
from typing import Optional
from cpl_core.application import ApplicationBuilder
from gismo.application import Gismo
from gismo.startup import Startup
from modules.boot_log.boot_log_extension import BootLogExtension
from modules.database.database_extension import DatabaseExtension
class Main:
def __init__(self):
self._gismo: Optional[Gismo] = None
async def main(self):
app_builder = ApplicationBuilder(Gismo)
app_builder.use_extension(DatabaseExtension)
app_builder.use_extension(BootLogExtension)
app_builder.use_startup(Startup)
self._gismo = await app_builder.build_async()
await self._gismo.run_async()
async def stop(self):
await self._gismo.stop_async()
if __name__ == '__main__':
main = Main()
ml = asyncio.get_event_loop()
try:
ml.run_until_complete(main.main())
except KeyboardInterrupt:
ml.run_until_complete(main.stop())
# ((
# ( `)
# ; / ,
# / \/
# / |
# / ~/
# / ) ) ~ edraft
# ___// | /
# `--' \_~-,
# happy new year :)

126
src/gismo/startup.py Normal file
View File

@ -0,0 +1,126 @@
import os
from datetime import datetime
from typing import Optional
from cpl_core.application import StartupABC
from cpl_core.configuration import ConfigurationABC
from cpl_core.console import Console
from cpl_core.database import DatabaseSettings
from cpl_core.dependency_injection import ServiceCollectionABC, ServiceProviderABC
from cpl_core.environment import ApplicationEnvironment
from cpl_core.logging import LoggerABC
from gismo_core.abc.bot_service_abc import BotServiceABC
from gismo_core.abc.client_utils_service_abc import ClientUtilsServiceABC
from gismo_core.abc.command_abc import CommandABC
from gismo_core.abc.message_service_abc import MessageServiceABC
from gismo_core.service.bot_service import BotService
from gismo_core.service.client_utils_service import ClientUtilsService
from gismo_core.service.message_service import MessageService
from gismo_data.abc.known_user_repository_abc import KnownUserRepositoryABC
from gismo_data.abc.migration_abc import MigrationABC
from gismo_data.abc.server_repository_abc import ServerRepositoryABC
from gismo_data.abc.user_joined_server_repository_abc import UserJoinedServerRepositoryABC
from gismo_data.abc.user_joined_voice_channel_abc import UserJoinedVoiceChannelRepositoryABC
from gismo_data.abc.user_repository_abc import UserRepositoryABC
from gismo_data.db_context import DBContext
from gismo_data.migration.initial_migration import InitialMigration
from gismo_data.migration.migration_0_3 import Migration_0_3
from gismo_data.migration.migration_0_3_1 import Migration_0_3_1
from gismo_data.service.client_repository_service import (
ClientRepositoryABC, ClientRepositoryService)
from gismo_data.service.known_user_repository_service import \
KnownUserRepositoryService
from gismo_data.service.migration_service import MigrationService
from gismo_data.service.server_repository_service import \
ServerRepositoryService
from gismo_data.service.user_joined_server_repository_service import UserJoinedServerRepositoryService
from gismo_data.service.user_joined_voice_channel_service import UserJoinedVoiceChannelRepositoryService
from gismo_data.service.user_repository_service import UserRepositoryService
from modules.base.base import Base
from modules.base.service.afk_command_service import AFKCommandService
from modules.base.service.help_command_service import HelpCommandService
from modules.base.service.info_command_service import InfoCommandService
from modules.base.service.ping_command_service import PingCommandService
from modules.base.service.purge_command_service import PurgeCommandService
from modules.base.service.user_info_command_service import UserInfoCommandService
from modules.boot_log.boot_log import BootLog
from modules.database.database import Database
from modules.permission.abc.permission_service_abc import PermissionServiceABC
from modules.permission.permission import Permission
from gismo_core.abc.module_abc import ModuleABC
from gismo_core.abc.module_service_abc import ModuleServiceABC
from gismo_core.service.module_service import ModuleService
from modules.permission.service.permission_service import PermissionService
class Startup(StartupABC):
def __init__(self):
StartupABC.__init__(self)
self._start_time = datetime.now()
self._config: Optional[ConfigurationABC] = None
def configure_configuration(self, configuration: ConfigurationABC, environment: ApplicationEnvironment) -> ConfigurationABC:
environment.set_working_directory(os.path.dirname(os.path.realpath(__file__)))
configuration.add_environment_variables('GISMO_')
configuration.add_json_file(f'config/appsettings.json', optional=False)
configuration.add_json_file(f'config/appsettings.{environment.environment_name}.json', optional=True)
configuration.add_json_file(f'config/appsettings.{environment.host_name}.json', optional=True)
configuration.add_configuration('Startup_StartTime', str(self._start_time))
self._config = configuration
return configuration
def configure_services(self, services: ServiceCollectionABC, environment: ApplicationEnvironment) -> ServiceProviderABC:
services.add_logging()
services.add_db_context(DBContext, self._config.get_configuration(DatabaseSettings))
# general services
services.add_singleton(ModuleServiceABC, ModuleService)
services.add_singleton(BotServiceABC, BotService)
services.add_transient(MessageServiceABC, MessageService)
services.add_transient(MigrationService)
services.add_transient(ClientUtilsServiceABC, ClientUtilsService)
# data services
services.add_transient(ServerRepositoryABC, ServerRepositoryService)
services.add_transient(UserRepositoryABC, UserRepositoryService)
services.add_transient(ClientRepositoryABC, ClientRepositoryService)
services.add_transient(KnownUserRepositoryABC, KnownUserRepositoryService)
services.add_transient(UserJoinedServerRepositoryABC, UserJoinedServerRepositoryService)
services.add_transient(UserJoinedVoiceChannelRepositoryABC, UserJoinedVoiceChannelRepositoryService)
# module services
services.add_singleton(PermissionServiceABC, PermissionService)
# commands
services.add_transient(CommandABC, PingCommandService)
services.add_transient(CommandABC, PurgeCommandService)
services.add_transient(CommandABC, AFKCommandService)
services.add_transient(CommandABC, HelpCommandService)
services.add_transient(CommandABC, InfoCommandService)
services.add_transient(CommandABC, UserInfoCommandService)
# modules
services.add_transient(ModuleABC, Database)
services.add_transient(ModuleABC, BootLog)
services.add_singleton(ModuleABC, Permission)
services.add_singleton(ModuleABC, Base)
# migrations
services.add_transient(MigrationABC, InitialMigration)
services.add_transient(MigrationABC, Migration_0_3)
services.add_transient(MigrationABC, Migration_0_3_1)
startup_init_time = round((datetime.now() - datetime.strptime(self._config.get_configuration('Startup_StartTime'), '%Y-%m-%d %H:%M:%S.%f')).total_seconds(), 2)
self._config.add_configuration('Startup_InitTime', str(startup_init_time))
provider: ServiceProviderABC = services.build_service_provider()
logger: LoggerABC = provider.get_service(LoggerABC)
logger.debug(__name__, f'Startup Init time: {startup_init_time}s')
return provider

25
src/gismo_cli/__init__.py Normal file
View File

@ -0,0 +1,25 @@
# -*- coding: utf-8 -*-
"""
gismo-cli sh-edraft Gismo - CLI
~~~~~~~~~~~~~~~~~~~
sh-edraft Dicord bot Gismo - command line interface
:copyright: (c) 2021 - 2022 sh-edraft.de
:license: MIT, see LICENSE for more details.
"""
__title__ = 'gismo_cli'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2021 - 2022 sh-edraft.de'
__version__ = '0.1.0'
from collections import namedtuple
# imports:
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='0', minor='1', micro='0')

View File

@ -0,0 +1,16 @@
from cpl_core.application import ApplicationABC
from cpl_core.configuration import ConfigurationABC
from cpl_core.console import Console
from cpl_core.dependency_injection import ServiceProviderABC
class Application(ApplicationABC):
def __init__(self, config: ConfigurationABC, services: ServiceProviderABC):
ApplicationABC.__init__(self, config, services)
async def configure(self):
pass
async def main(self):
Console.write_line('Hello World')

View File

@ -0,0 +1,15 @@
{
"TimeFormatSettings": {
"DateFormat": "%Y-%m-%d",
"TimeFormat": "%H:%M:%S",
"DateTimeFormat": "%Y-%m-%d %H:%M:%S.%f",
"DateTimeLogFormat": "%Y-%m-%d_%H-%M-%S"
},
"LoggingSettings": {
"Path": "logs/",
"Filename": "log_$start_time.log",
"ConsoleLogLevel": "ERROR",
"FileLogLevel": "WARN"
}
}

View File

@ -0,0 +1,48 @@
{
"ProjectSettings": {
"Name": "gismo-cli",
"Version": {
"Major": "0",
"Minor": "1",
"Micro": "0"
},
"Author": "Sven Heidemann",
"AuthorEmail": "sven.heidemann@sh-edraft.de",
"Description": "sh-edraft Gismo - CLI",
"LongDescription": "sh-edraft Dicord bot Gismo - command line interface",
"URL": "https://www.sh-edraft.de",
"CopyrightDate": "2021 - 2022",
"CopyrightName": "sh-edraft.de",
"LicenseName": "MIT",
"LicenseDescription": "MIT, see LICENSE for more details.",
"Dependencies": [
"sh_cpl-core>=2021.11.0",
"sh_cpl-query>=2021.11.0"
],
"PythonVersion": ">=3.9.2",
"PythonPath": {
"linux": "../../venv/bin/python"
},
"Classifiers": []
},
"BuildSettings": {
"ProjectType": "console",
"SourcePath": "",
"OutputPath": "../../dist",
"Main": "gismo.main",
"EntryPoint": "gismo",
"IncludePackageData": false,
"Included": [],
"Excluded": [
"*/__pycache__",
"*/logs",
"*/tests"
],
"PackageData": {
"cpl_cli": [
"*.json"
]
},
"ProjectReferences": []
}
}

18
src/gismo_cli/main.py Normal file
View File

@ -0,0 +1,18 @@
import asyncio
from cpl_core.application import ApplicationBuilder
from gismo_cli.application import Application
from gismo_cli.startup import Startup
async def main():
app_builder = ApplicationBuilder(Application)
app_builder.use_startup(Startup)
app: Application = await app_builder.build_async()
await app.run_async()
if __name__ == '__main__':
ml = asyncio.get_event_loop()
ml.run_until_complete(main())

16
src/gismo_cli/startup.py Normal file
View File

@ -0,0 +1,16 @@
from cpl_core.application import StartupABC
from cpl_core.configuration import ConfigurationABC
from cpl_core.dependency_injection import ServiceProviderABC, ServiceCollectionABC
from cpl_core.environment import ApplicationEnvironment
class Startup(StartupABC):
def __init__(self):
StartupABC.__init__(self)
async def configure_configuration(self, configuration: ConfigurationABC, environment: ApplicationEnvironment) -> ConfigurationABC:
return configuration
async def configure_services(self, services: ServiceCollectionABC, environment: ApplicationEnvironment) -> ServiceProviderABC:
return services.build_service_provider()

View File

@ -0,0 +1,25 @@
# -*- coding: utf-8 -*-
"""
gismo sh-edraft Gismo
~~~~~~~~~~~~~~~~~~~
sh-edraft Dicord bot Gismo
:copyright: (c) 2021 - 2022 sh-edraft.de
:license: MIT, see LICENSE for more details.
"""
__title__ = 'gismo_core'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2021 - 2022 sh-edraft.de'
__version__ = '0.4.2'
from collections import namedtuple
# imports
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='0', minor='4', micro='2')

View File

@ -0,0 +1,25 @@
# -*- coding: utf-8 -*-
"""
gismo sh-edraft Gismo
~~~~~~~~~~~~~~~~~~~
sh-edraft Dicord bot Gismo
:copyright: (c) 2021 - 2022 sh-edraft.de
:license: MIT, see LICENSE for more details.
"""
__title__ = 'gismo_core.abc'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2021 - 2022 sh-edraft.de'
__version__ = '0.4.2'
from collections import namedtuple
# imports
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='0', minor='4', micro='2')

View File

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

View File

@ -0,0 +1,16 @@
from abc import ABC, abstractmethod
class ClientUtilsServiceABC(ABC):
@abstractmethod
def __init__(self): pass
@abstractmethod
def received_command(self, guild_id: int): pass
@abstractmethod
def moved_user(self, guild_id: int): pass
@abstractmethod
def get_client(self, dc_ic: int, guild_id: int): pass

View File

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

View File

@ -0,0 +1,25 @@
# -*- coding: utf-8 -*-
"""
gismo sh-edraft Gismo
~~~~~~~~~~~~~~~~~~~
sh-edraft Dicord bot Gismo
:copyright: (c) 2021 - 2022 sh-edraft.de
:license: MIT, see LICENSE for more details.
"""
__title__ = 'gismo_core.abc.events'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2021 - 2022 sh-edraft.de'
__version__ = '0.4.2'
from collections import namedtuple
# imports:
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='0', minor='4', micro='2')

View File

@ -0,0 +1,11 @@
from abc import ABC, abstractmethod
import discord
class OnBulkMessageDeleteABC(ABC):
@abstractmethod
def __init__(self): pass
@abstractmethod
async def on_bulk_message_delete(self, messages: list[discord.Message]): pass

View File

@ -0,0 +1,10 @@
from abc import ABC, abstractmethod
class OnConnectABC(ABC):
@abstractmethod
def __init__(self): pass
@abstractmethod
async def on_connect(self): pass

View File

@ -0,0 +1,10 @@
from abc import ABC, abstractmethod
class OnDisconnectABC(ABC):
@abstractmethod
def __init__(self): pass
@abstractmethod
async def on_disconnect(self): pass

View File

@ -0,0 +1,10 @@
from abc import ABC, abstractmethod
class OnErrorABC(ABC):
@abstractmethod
def __init__(self): pass
@abstractmethod
async def on_error(self, event: str, *args, **kwargs): pass

View File

@ -0,0 +1,12 @@
from abc import ABC, abstractmethod
import discord
class OnGroupJoinABC(ABC):
@abstractmethod
def __init__(self): pass
@abstractmethod
async def on_group_join(
self, chhanel: discord.GroupChannel, user: discord.User): pass

View File

@ -0,0 +1,11 @@
from abc import ABC, abstractmethod
import discord
class OnGroupRemoveABC(ABC):
@abstractmethod
def __init__(self): pass
@abstractmethod
async def on_group_remove(
self, chhanel: discord.GroupChannel, user: discord.User): pass

View File

@ -0,0 +1,11 @@
from abc import ABC, abstractmethod
import discord
class OnGuildAvailableABC(ABC):
@abstractmethod
def __init__(self): pass
@abstractmethod
async def on_guild_available(self, guild: discord.Guild): pass

View File

@ -0,0 +1,12 @@
from abc import ABC, abstractmethod
import discord
class OnGuildChannelCreateABC(ABC):
@abstractmethod
def __init__(self): pass
@abstractmethod
async def on_guild_channel_create(self, channel: discord.abc.GuildChannel): pass

View File

@ -0,0 +1,12 @@
from abc import ABC, abstractmethod
import discord
class OnGuildChannelDeleteABC(ABC):
@abstractmethod
def __init__(self): pass
@abstractmethod
async def on_guild_channel_delete(self, channel: discord.abc.GuildChannel): pass

View File

@ -0,0 +1,14 @@
from abc import ABC, abstractmethod
from datetime import datetime
from typing import Optional
import discord
class OnGuildChannelPinsUpdateABC(ABC):
@abstractmethod
def __init__(self): pass
@abstractmethod
async def on_guild_channel_pins_update(self, channel: discord.abc.GuildChannel, list_pin: Optional[datetime]): pass

View File

@ -0,0 +1,11 @@
from abc import ABC, abstractmethod
import discord
class OnGuildChannelUpdateABC(ABC):
@abstractmethod
def __init__(self): pass
@abstractmethod
async def on_guild_channel_update(self, before: discord.abc.GuildChannel, after: discord.abc.GuildChannel): pass

View File

@ -0,0 +1,12 @@
from abc import ABC, abstractmethod
from typing import Sequence
import discord
class OnGuildEmojisUpdateABC(ABC):
@abstractmethod
def __init__(self): pass
@abstractmethod
async def on_guild_emojis_update(self, guild: discord.Guild, before: Sequence[discord.Emoji], after: Sequence[discord.Emoji]): pass

View File

@ -0,0 +1,12 @@
from abc import ABC, abstractmethod
import discord
class OnGuildIntegrationsUpdateABC(ABC):
@abstractmethod
def __init__(self): pass
@abstractmethod
async def on_guild_integrations_update(self, guild: discord.Guild): pass

View File

@ -0,0 +1,11 @@
from abc import ABC, abstractmethod
import discord
class OnGuildJoinABC(ABC):
@abstractmethod
def __init__(self): pass
@abstractmethod
async def on_guild_join(self, guild: discord.Guild): pass

View File

@ -0,0 +1,10 @@
from abc import ABC, abstractmethod
import discord
class OnGuildRemoveABC(ABC):
@abstractmethod
def __init__(self): pass
@abstractmethod
async def on_guild_remove(self, guild: discord.Guild): pass

View File

@ -0,0 +1,11 @@
from abc import ABC, abstractmethod
import discord
class OnGuildRoleCreateABC(ABC):
@abstractmethod
def __init__(self): pass
@abstractmethod
async def on_guild_role_create(self, role: discord.Role): pass

View File

@ -0,0 +1,11 @@
from abc import ABC, abstractmethod
import discord
class OnGuildRoleDeleteABC(ABC):
@abstractmethod
def __init__(self): pass
@abstractmethod
async def on_guild_role_delete(self, role: discord.Role): pass

View File

@ -0,0 +1,11 @@
from abc import ABC, abstractmethod
import discord
class OnGuildRoleUpdateABC(ABC):
@abstractmethod
def __init__(self): pass
@abstractmethod
async def on_guild_role_update(self, before: discord.Role, after: discord.Role): pass

View File

@ -0,0 +1,11 @@
from abc import ABC, abstractmethod
import discord
class OnGuildUnavailableABC(ABC):
@abstractmethod
def __init__(self): pass
@abstractmethod
async def on_guild_unavailable(self, guild: discord.Guild): pass

View File

@ -0,0 +1,11 @@
from abc import ABC, abstractmethod
import discord
class OnGuildUpdateABC(ABC):
@abstractmethod
def __init__(self): pass
@abstractmethod
async def on_guild_update(self, before: discord.Guild, after: discord.Guild): pass

View File

@ -0,0 +1,12 @@
from abc import ABC, abstractmethod
import discord
class OnInviteCreateABC(ABC):
@abstractmethod
def __init__(self): pass
@abstractmethod
async def on_invite_create(self, invite: discord.Invite): pass

View File

@ -0,0 +1,11 @@
from abc import ABC, abstractmethod
import discord
class OnInviteDeleteABC(ABC):
@abstractmethod
def __init__(self): pass
@abstractmethod
async def on_invite_delete(self, invite: discord.Invite): pass

View File

@ -0,0 +1,11 @@
from abc import ABC, abstractmethod
import discord
class OnMemberBanABC(ABC):
@abstractmethod
def __init__(self): pass
@abstractmethod
async def on_member_ban(self, guild: discord.Guild, user: discord.User): pass

View File

@ -0,0 +1,12 @@
from abc import ABC, abstractmethod
import discord
class OnMemberJoinABC(ABC):
@abstractmethod
def __init__(self): pass
@abstractmethod
async def on_member_join(self, member: discord.Member): pass

View File

@ -0,0 +1,11 @@
from abc import ABC, abstractmethod
import discord
class OnMemberRemoveABC(ABC):
@abstractmethod
def __init__(self): pass
@abstractmethod
async def on_member_remove(self, member: discord.Member): pass

View File

@ -0,0 +1,11 @@
from abc import ABC, abstractmethod
import discord
class OnMemberUnbanABC(ABC):
@abstractmethod
def __init__(self): pass
@abstractmethod
async def on_member_unban(self, guild: discord.Guild, user: discord.User): pass

View File

@ -0,0 +1,11 @@
from abc import ABC, abstractmethod
import discord
class OnMemberUpdateABC(ABC):
@abstractmethod
def __init__(self): pass
@abstractmethod
async def on_member_update(self, before: discord.Member, after: discord.Member): pass

View File

@ -0,0 +1,11 @@
from abc import ABC, abstractmethod
import discord
class OnMessageABC(ABC):
@abstractmethod
def __init__(self): pass
@abstractmethod
async def on_message(self, message: discord.Message): pass

View File

@ -0,0 +1,11 @@
from abc import ABC, abstractmethod
import discord
class OnMessageDeleteABC(ABC):
@abstractmethod
def __init__(self): pass
@abstractmethod
async def on_message_delete(self, message: discord.Message): pass

View File

@ -0,0 +1,11 @@
from abc import ABC, abstractmethod
import discord
class OnMessageEditABC(ABC):
@abstractmethod
def __init__(self): pass
@abstractmethod
async def on_message_edit(self, before: discord.Message, after: discord.Message): pass

View File

@ -0,0 +1,12 @@
from abc import ABC, abstractmethod
import discord
class OnPrivateChannelCreateABC(ABC):
@abstractmethod
def __init__(self): pass
@abstractmethod
async def on_private_channel_create(self, channel: discord.abc.PrivateChannel): pass

View File

@ -0,0 +1,12 @@
from abc import ABC, abstractmethod
import discord
class OnPrivateChannelDeleteABC(ABC):
@abstractmethod
def __init__(self): pass
@abstractmethod
async def on_private_channel_delete(self, channel: discord.abc.PrivateChannel): pass

View File

@ -0,0 +1,14 @@
from abc import ABC, abstractmethod
from datetime import datetime
from typing import Optional
import discord
class OnPrivateChannelPinsUpdateABC(ABC):
@abstractmethod
def __init__(self): pass
@abstractmethod
async def on_private_channel_pins_update(self, channel: discord.abc.PrivateChannel, list_pin: Optional[datetime]): pass

View File

@ -0,0 +1,12 @@
from abc import ABC, abstractmethod
import discord
class OnPrivateChannelUpdateABC(ABC):
@abstractmethod
def __init__(self): pass
@abstractmethod
async def on_private_channel_update(self, before: discord.GroupChannel, after: discord.GroupChannel): pass

View File

@ -0,0 +1,12 @@
from abc import ABC, abstractmethod
import discord
class OnReactionAddABC(ABC):
@abstractmethod
def __init__(self): pass
@abstractmethod
async def on_reaction_add(self, reaction: discord.Reaction, user: discord.User): pass

View File

@ -0,0 +1,12 @@
from abc import ABC, abstractmethod
import discord
class OnReactionClearABC(ABC):
@abstractmethod
def __init__(self): pass
@abstractmethod
async def on_reaction_clear(self, message: discord.Message, reactions: list[discord.Reaction]): pass

View File

@ -0,0 +1,12 @@
from abc import ABC, abstractmethod
import discord
class OnReactionClearEmojiABC(ABC):
@abstractmethod
def __init__(self): pass
@abstractmethod
async def on_reaction_clear_emoji(self, reaction: discord.Reaction): pass

View File

@ -0,0 +1,12 @@
from abc import ABC, abstractmethod
import discord
class OnReactionRemoveABC(ABC):
@abstractmethod
def __init__(self): pass
@abstractmethod
async def on_reaction_remove(self, reaction: discord.Reaction, user: discord.User): pass

View File

@ -0,0 +1,10 @@
from abc import ABC, abstractmethod
class OnReadyABC(ABC):
@abstractmethod
def __init__(self): pass
@abstractmethod
async def on_ready(self): pass

View File

@ -0,0 +1,11 @@
from abc import ABC, abstractmethod
import discord
class OnRelationshipAddABC(ABC):
@abstractmethod
def __init__(self): pass
@abstractmethod
async def on_relationship_add(self, relationship: discord.Relationship): pass

View File

@ -0,0 +1,11 @@
from abc import ABC, abstractmethod
import discord
class OnRelationshipRemoveABC(ABC):
@abstractmethod
def __init__(self): pass
@abstractmethod
async def on_relationship_remove(self, relationship: discord.Relationship): pass

View File

@ -0,0 +1,12 @@
from abc import ABC, abstractmethod
import discord
class OnRelationshipUpdateABC(ABC):
@abstractmethod
def __init__(self): pass
@abstractmethod
async def on_relationship_update(
self, before: discord.Relationship, after: discord.Relationship): pass

View File

@ -0,0 +1,10 @@
from abc import ABC, abstractmethod
class OnResumeABC(ABC):
@abstractmethod
def __init__(self): pass
@abstractmethod
async def on_resume(self): pass

View File

@ -0,0 +1,13 @@
from abc import ABC, abstractmethod
from datetime import datetime
from typing import Union
import discord
class OnTypingABC(ABC):
@abstractmethod
def __init__(self): pass
@abstractmethod
async def on_typing(self, channel: discord.abc.Messageable, user: Union[discord.User, discord.Member], when: datetime): pass

View File

@ -0,0 +1,11 @@
from abc import ABC, abstractmethod
import discord
class OnUserUpdateABC(ABC):
@abstractmethod
def __init__(self): pass
@abstractmethod
async def on_user_update(self, before: discord.User, after: discord.User): pass

View File

@ -0,0 +1,11 @@
from abc import ABC, abstractmethod
import discord
class OnVoiceStateUpdateABC(ABC):
@abstractmethod
def __init__(self): pass
@abstractmethod
async def on_voice_state_update(self, member: discord.Member, before: discord.VoiceState,after: discord.VoiceState): pass

View File

@ -0,0 +1,12 @@
from abc import ABC, abstractmethod
import discord
class OnWebhooksUpdateABC(ABC):
@abstractmethod
def __init__(self): pass
@abstractmethod
async def on_webhooks_update(self, channel: discord.abc.GuildChannel): pass

View File

@ -0,0 +1,27 @@
from abc import ABC, abstractmethod
from typing import Union
import discord
from cpl_query.extension import List
from discord.ext.commands import Context
class MessageServiceABC(ABC):
@abstractmethod
def __init__(self): pass
@abstractmethod
async def delete_messages(self, messages: List[discord.Message], guild_id: int): pass
@abstractmethod
async def delete_message(self, message: discord.Message): pass
@abstractmethod
async def send_channel_message(self, channel: discord.TextChannel, message: Union[str, discord.Embed]): pass
@abstractmethod
async def send_dm_message(self, message: Union[str, discord.Embed], receiver: Union[discord.User, discord.Member]): pass
@abstractmethod
async def send_ctx_msg(self, ctx: Context, message: Union[str, discord.Embed], file: discord.File = None, is_persistent: bool = False, wait_before_delete: int = None): pass

View File

@ -0,0 +1,27 @@
from abc import ABC, abstractmethod
from typing import Optional
class ModuleABC(ABC):
@abstractmethod
def __init__(self, priorities: dict[type, int], settings_types: list[Optional[type]]):
self._priorities = priorities
self._success = True
self._settings_types = settings_types
@property
def success(self) -> bool:
return self._success
@property
def settings_types(self) -> list[type]:
return self._settings_types
def get_priority(self, t: type) -> int:
if t not in self._priorities:
raise Exception(f'Priority for {t} not found!')
return self._priorities[t]
def stop_propagation(self):
self._success = False

View File

@ -0,0 +1,155 @@
from abc import ABC, abstractmethod
from datetime import datetime
from typing import Optional, Sequence, Union
import discord
class ModuleServiceABC(ABC):
@abstractmethod
def __init__(self): pass
@abstractmethod
def load_modules(self): pass
@abstractmethod
async def on_connect(self): pass
@abstractmethod
async def on_disconnect(self): pass
@abstractmethod
async def on_ready(self): pass
@abstractmethod
async def on_resume(self): pass
@abstractmethod
async def on_error(self, event: str, *args, **kwargs): pass
@abstractmethod
async def on_typing(self, channel: discord.abc.Messageable, user: Union[discord.User, discord.Member], when: datetime): pass
@abstractmethod
async def on_message(self, message: discord.Message): pass
@abstractmethod
async def on_message_delete(self, message: discord.Message): pass
@abstractmethod
async def on_bulk_message_delete(self, messages: list[discord.Message]): pass
@abstractmethod
async def on_message_edit(self, before: discord.Message, after: discord.Message): pass
@abstractmethod
async def on_reaction_add(self, reaction: discord.Reaction, user: discord.User): pass
@abstractmethod
async def on_reaction_remove(self, reaction: discord.Reaction, user: discord.User): pass
@abstractmethod
async def on_reaction_clear(self, message: discord.Message, reactions: list[discord.Reaction]): pass
@abstractmethod
async def on_reaction_clear_emoji(self, reaction: discord.Reaction): pass
@abstractmethod
async def on_private_channel_delete(self, channel: discord.abc.PrivateChannel): pass
@abstractmethod
async def on_private_channel_create(self, channel: discord.abc.PrivateChannel): pass
@abstractmethod
async def on_private_channel_update(self, before: discord.GroupChannel, after: discord.GroupChannel): pass
@abstractmethod
async def on_private_channel_pins_update(self, channel: discord.abc.PrivateChannel, list_pin: Optional[datetime]): pass
@abstractmethod
async def on_guild_channel_delete(self, channel: discord.abc.GuildChannel): pass
@abstractmethod
async def on_guild_channel_create(self, channel: discord.abc.GuildChannel): pass
@abstractmethod
async def on_guild_channel_update(self, before: discord.abc.GuildChannel, after: discord.abc.GuildChannel): pass
@abstractmethod
async def on_guild_channel_pins_update(self, channel: discord.abc.GuildChannel, list_pin: Optional[datetime]): pass
@abstractmethod
async def on_guild_integrations_update(self, guild: discord.Guild): pass
@abstractmethod
async def on_webhooks_update(self, channel: discord.abc.GuildChannel): pass
@abstractmethod
async def on_member_join(self, member: discord.Member): pass
@abstractmethod
async def on_member_remove(self, member: discord.Member): pass
@abstractmethod
async def on_member_update(self, before: discord.Member, after: discord.Member): pass
@abstractmethod
async def on_user_update(self, before: discord.User, after: discord.User): pass
@abstractmethod
async def on_guild_join(self, guild: discord.Guild): pass
@abstractmethod
async def on_guild_remove(self, guild: discord.Guild): pass
@abstractmethod
async def on_guild_update(self, before: discord.Guild, after: discord.Guild): pass
@abstractmethod
async def on_guild_role_create(self, role: discord.Role): pass
@abstractmethod
async def on_guild_role_delete(self, role: discord.Role): pass
@abstractmethod
async def on_guild_role_update(self, before: discord.Role, after: discord.Role): pass
@abstractmethod
async def on_guild_emojis_update(self, guild: discord.Guild, before: Sequence[discord.Emoji], after: Sequence[discord.Emoji]): pass
@abstractmethod
async def on_guild_available(self, guild: discord.Guild): pass
@abstractmethod
async def on_guild_unavailable(self, guild: discord.Guild): pass
@abstractmethod
async def on_voice_state_update(self, member: discord.Member, before: discord.VoiceState,after: discord.VoiceState): pass
@abstractmethod
async def on_member_ban(self, guild: discord.Guild, user: discord.User): pass
@abstractmethod
async def on_member_unban(self, guild: discord.Guild, user: discord.User): pass
@abstractmethod
async def on_invite_create(self, invite: discord.Invite): pass
@abstractmethod
async def on_invite_delete(self, invite: discord.Invite): pass
@abstractmethod
async def on_group_join(self, chhanel: discord.GroupChannel, user: discord.User): pass
@abstractmethod
async def on_group_remove(self, chhanel: discord.GroupChannel, user: discord.User): pass
@abstractmethod
async def on_relationship_add(self, relationship: discord.Relationship): pass
@abstractmethod
async def on_relationship_remove(self, relationship: discord.Relationship): pass
@abstractmethod
async def on_relationship_update(self, before: discord.Relationship, after: discord.Relationship): pass

View File

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

View File

@ -0,0 +1,25 @@
# -*- coding: utf-8 -*-
"""
gismo sh-edraft Gismo
~~~~~~~~~~~~~~~~~~~
sh-edraft Dicord bot Gismo
:copyright: (c) 2021 - 2022 sh-edraft.de
:license: MIT, see LICENSE for more details.
"""
__title__ = 'gismo_core.configuration'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2021 - 2022 sh-edraft.de'
__version__ = '0.4.2'
from collections import namedtuple
# imports
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='0', minor='4', micro='2')

View File

@ -0,0 +1,36 @@
import traceback
from cpl_core.configuration import ConfigurationModelABC
from cpl_core.console import Console
from cpl_query.extension import List
from gismo_core.configuration.server_settings import ServerSettings
class BotSettings(ConfigurationModelABC):
def __init__(self):
ConfigurationModelABC.__init__(self)
self._prefix: str = ''
self._servers: List[ServerSettings] = List()
@property
def prefix(self) -> str:
return self._prefix
@property
def servers(self) -> List[ServerSettings]:
return self._servers
def from_dict(self, settings: dict):
try:
self._prefix = settings['Prefix']
servers = List(ServerSettings)
for s in settings['Servers']:
st = ServerSettings()
st.from_dict(s)
servers.append(st)
self._servers = servers
except Exception as e:
Console.error(f'[ ERROR ] [ {__name__} ]: Reading error in settings')
Console.error(f'[ EXCEPTION ] [ {__name__} ]: {e} -> {traceback.format_exc()}')

View File

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

View File

@ -0,0 +1,53 @@
import traceback
from typing import Optional
from cpl_core.configuration.configuration_model_abc import ConfigurationModelABC
from cpl_core.console import Console
from cpl_query.extension import List
from gismo_core.model.embed_description import EmbedDescription
from gismo_core.model.embed_description_field import EmbedDescriptionField
class EmbedDescriptionSettings(ConfigurationModelABC):
def __init__(self):
ConfigurationModelABC.__init__(self)
self._embed_description: Optional[EmbedDescription] = None
@property
def embed_description(self) -> EmbedDescription:
return self._embed_description
def from_dict(self, settings: dict):
try:
title = ''
description = ''
url = ''
color = ''
fields = List(EmbedDescriptionField)
footer = ''
for key in settings:
if key == 'Title':
title = settings[key]
elif key == 'Description':
description = settings[key]
elif key == 'URL':
url = settings[key]
elif key == 'Color':
color = settings[key]
elif key == 'Fields':
for field in settings[key]:
fields.append(EmbedDescriptionField(field['Name'], field['Value'], bool(field['Inline'])))
elif key == 'Footer':
footer = settings[key]
else:
raise Exception(f'Unexpected key {key}')
self._embed_description = EmbedDescription(title, description, url, color, fields, footer)
except Exception as e:
Console.error(f'[ ERROR ] [ {__name__} ]: Reading error in {self.__name__} settings')
Console.error(f'[ EXCEPTION ] [ {__name__} ]: {e} -> {traceback.format_exc()}')

View File

@ -0,0 +1,35 @@
import traceback
from cpl_core.configuration.configuration_model_abc import ConfigurationModelABC
from cpl_core.console import Console
class ServerSettings(ConfigurationModelABC):
def __init__(self):
ConfigurationModelABC.__init__(self)
self._id: int = 0
self._message_delete_timer: int = 0
self._bot_has_no_permission_message: str = ''
@property
def id(self) -> int:
return self._id
@property
def message_delete_timer(self) -> int:
return self._message_delete_timer
@property
def bot_has_no_permission_message(self) -> str:
return self._bot_has_no_permission_message
def from_dict(self, settings: dict):
try:
self._id = int(settings['Id'])
self._message_delete_timer = int(settings['MessageDeleteTimer'])
self._bot_has_no_permission_message = settings['BotHasNoPermissionMessage']
except Exception as e:
Console.error(f'[ ERROR ] [ {__name__} ]: Reading error in settings')
Console.error(f'[ EXCEPTION ] [ {__name__} ]: {e} -> {traceback.format_exc()}')

View File

@ -0,0 +1,44 @@
{
"ProjectSettings": {
"Name": "gismo-core",
"Version": {
"Major": "0",
"Minor": "1",
"Micro": "0"
},
"Author": "Sven Heidemann",
"AuthorEmail": "sven.heidemann@sh-edraft.de",
"Description": "sh-edraft Gismo - core",
"LongDescription": "sh-edraft Dicord bot Gismo - core library",
"URL": "https://www.sh-edraft.de",
"CopyrightDate": "2021 - 2022",
"CopyrightName": "sh-edraft.de",
"LicenseName": "MIT",
"LicenseDescription": "MIT, see LICENSE for more details.",
"Dependencies": [
"sh_cpl-core>=2021.11.0",
"sh_cpl-query>=2021.11.0"
],
"PythonVersion": ">=3.9.2",
"PythonPath": {
"linux": "../../venv/bin/python"
},
"Classifiers": []
},
"BuildSettings": {
"ProjectType": "library",
"SourcePath": "",
"OutputPath": "../../dist",
"Main": "",
"EntryPoint": "",
"IncludePackageData": false,
"Included": [],
"Excluded": [
"*/__pycache__",
"*/logs",
"*/tests"
],
"PackageData": {},
"ProjectReferences": []
}
}

View File

@ -0,0 +1,25 @@
# -*- coding: utf-8 -*-
"""
gismo sh-edraft Gismo
~~~~~~~~~~~~~~~~~~~
sh-edraft Dicord bot Gismo
:copyright: (c) 2021 - 2022 sh-edraft.de
:license: MIT, see LICENSE for more details.
"""
__title__ = 'gismo_core.model'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2021 - 2022 sh-edraft.de'
__version__ = '0.4.2'
from collections import namedtuple
# imports
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='0', minor='4', micro='2')

View File

@ -0,0 +1,60 @@
from cpl_query.extension import List
from gismo_core.model.embed_description_field import EmbedDescriptionField
class EmbedDescription:
def __init__(
self,
title: str = None,
description: str = None,
url: str = None,
color: str = None,
fields: list[EmbedDescriptionField] = None,
footer: str = None
):
self._title = title
self._description = description
self._url = url
self._color = color
self._fields = fields
self._footer = footer
@property
def title(self) -> str:
return self._title
@title.setter
def title(self, value: str):
self._title = value
@property
def description(self) -> str:
return self._description
@description.setter
def description(self, value: str):
self._description = value
@property
def url(self) -> str:
return self._url
@property
def color(self) -> str:
return self._color
@property
def fields(self) -> list[EmbedDescriptionField]:
return self._fields
@fields.setter
def fields(self, value: list[EmbedDescriptionField]):
self._fields = value
@property
def footer(self) -> str:
return self._footer

View File

@ -0,0 +1,27 @@
class EmbedDescriptionField:
def __init__(
self,
name: str,
value: str,
inline: bool
):
self._name = name
self._value = value
self._inline = inline
@property
def name(self) -> str:
return self._name
@property
def value(self) -> str:
return self._value
@value.setter
def value(self, value: str):
self._value = value
@property
def inline(self) -> bool:
return self._inline

View File

@ -0,0 +1,25 @@
# -*- coding: utf-8 -*-
"""
gismo sh-edraft Gismo
~~~~~~~~~~~~~~~~~~~
sh-edraft Dicord bot Gismo
:copyright: (c) 2021 - 2022 sh-edraft.de
:license: MIT, see LICENSE for more details.
"""
__title__ = 'gismo_core.service'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2021 - 2022 sh-edraft.de'
__version__ = '0.4.2'
from collections import namedtuple
# imports
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='0', minor='4', micro='2')

View File

@ -0,0 +1,64 @@
import discord
from cpl_core.configuration import ConfigurationABC
from cpl_core.console import Console
from cpl_core.environment import ApplicationEnvironmentABC
from cpl_core.logging import LoggerABC, LoggingLevelEnum, LoggingSettings
from discord.ext import commands
from gismo_core.abc.bot_service_abc import BotServiceABC
from gismo_core.configuration.bot_settings import BotSettings
from gismo_core.configuration.discord_settings import DiscordSettings
from gismo_core.configuration.server_settings import ServerSettings
from gismo_core.abc.module_service_abc import ModuleServiceABC
from gismo_core.service.module_service import ModuleService
class BotService(BotServiceABC, commands.Bot):
def __init__(
self,
config: ConfigurationABC,
logger: LoggerABC,
modules: ModuleService,
discord_settings: DiscordSettings,
bot_settings: BotSettings,
env: ApplicationEnvironmentABC,
logging_st: LoggingSettings,
):
# services
self._logger = logger
self._modules = modules
self._env = env
self._logging_st = logging_st
# settings
self._discord_settings = discord_settings
# setup super
commands.Bot.__init__(self, command_prefix=bot_settings.prefix, help_command=None, intents=discord.Intents().all())
async def start_async(self):
self._logger.trace(__name__, 'Try to connect to discord')
self._modules.load_modules()
await self.start(self._discord_settings.token)
# continue at on_ready
async def stop_async(self):
self._logger.debug(__name__, f'Try to stop {BotService}')
try:
pass
# save data
except Exception as e:
self._logger.error(__name__, 'Stop failed', e)
async def on_ready(self):
self._logger.info(__name__, 'Connected to discord')
self._logger.header(f'{self.user.name}:')
if self._logging_st.console.value >= LoggingLevelEnum.INFO.value:
Console.banner(self._env.application_name if self._env.application_name != '' else 'Gismo')
self.add_cog(self._modules)
await self._modules.on_ready()

View File

@ -0,0 +1,41 @@
from cpl_core.database.context import DatabaseContextABC
from gismo_core.abc.bot_service_abc import BotServiceABC
from gismo_core.abc.client_utils_service_abc import ClientUtilsServiceABC
from gismo_data.abc.client_repository_abc import ClientRepositoryABC
from gismo_data.abc.server_repository_abc import ServerRepositoryABC
class ClientUtilsService(ClientUtilsServiceABC):
def __init__(
self,
bot: BotServiceABC,
servers: ServerRepositoryABC,
clients: ClientRepositoryABC,
db: DatabaseContextABC
):
ClientUtilsServiceABC.__init__(self)
self._bot = bot
self._servers = servers
self._clients = clients
self._db = db
def received_command(self, guild_id: int):
server = self._servers.get_server_by_discord_id(guild_id)
client = self._clients.find_client_by_discord_id_and_server_id(self._bot.user.id, server.server_id)
client.received_command_count += 1
self._clients.update_client(client)
self._db.save_changes()
def moved_user(self, guild_id: int):
server = self._servers.get_server_by_discord_id(guild_id)
client = self._clients.find_client_by_discord_id_and_server_id(self._bot.user.id, server.server_id)
client.moved_users_count += 1
self._clients.update_client(client)
self._db.save_changes()
def get_client(self, dc_ic: int, guild_id: int):
server = self._servers.get_server_by_discord_id(guild_id)
client = self._clients.find_client_by_discord_id_and_server_id(self._bot.user.id, server.server_id)
return client

View File

@ -0,0 +1,23 @@
import discord
from gismo_core.model.embed_description import EmbedDescription
class EmbedService:
@staticmethod
def get_embed(description: EmbedDescription) -> discord.Embed:
embed = discord.Embed(
title=description.title,
url=description.url,
description=description.description,
color=int(description.color, 16)
)
for field in description.fields:
embed.add_field(name=field.name, value=field.value, inline=field.inline)
if description.footer is not None:
embed.set_footer(text=description.footer)
return embed

View File

@ -0,0 +1,105 @@
import asyncio
from typing import Union
import discord
from cpl_core.configuration.configuration_abc import ConfigurationABC
from cpl_core.database.context.database_context_abc import DatabaseContextABC
from cpl_core.logging import LoggerABC
from cpl_query.extension import List
from discord.ext.commands import Context
from gismo_core.abc.bot_service_abc import BotServiceABC
from gismo_core.abc.message_service_abc import MessageServiceABC
from gismo_core.configuration.server_settings import ServerSettings
from gismo_data.abc.client_repository_abc import ClientRepositoryABC
class MessageService(MessageServiceABC):
def __init__(self, config: ConfigurationABC, logger: LoggerABC, bot: BotServiceABC, clients: ClientRepositoryABC, db: DatabaseContextABC):
self._config = config
self._logger = logger
self._bot = bot
self._clients = clients
self._db = db
async def delete_messages(self, messages: List[discord.Message], guild_id: int):
self._logger.debug(__name__, f'Try to delete {messages.count()} messages')
server_st: ServerSettings = self._config.get_configuration(f'DSERVER_{guild_id}')
await asyncio.sleep(server_st.message_delete_timer)
for message in messages:
await self.delete_message(message, mass_delete=True)
self._logger.debug(__name__, 'Deleting messages finished')
async def delete_message(self, message: discord.Message, mass_delete=False):
server_st: ServerSettings = self._config.get_configuration(f'DSERVER_{message.guild.id}')
if not mass_delete:
await asyncio.sleep(server_st.message_delete_timer)
self._logger.debug(__name__, f'Try to delete message:\n\t{message}\n\t{message.content}')
guild_id = message.guild.id
try:
await message.delete()
except Exception as e:
self._logger.error(__name__, f'Deleting message failed', e)
else:
self._clients.append_deleted_message_count(self._bot.user.id, guild_id, 1)
self._db.save_changes()
self._logger.info(__name__, f'Deleted message {message}')
async def send_channel_message(self, channel: discord.TextChannel, message: Union[str, discord.Embed]):
self._logger.debug(__name__, f'Try to send message\n\t{message}\n\tto: {channel}')
msg = None
try:
if isinstance(message, discord.Embed):
msg = await channel.send(embed=message)
else:
msg = await channel.send(message)
except Exception as e:
self._logger.error(__name__, f'Send message to channel {channel.id} failed', e)
else:
self._logger.info(__name__, f'Sent message to channel {channel.id}')
self._clients.append_sent_message_count(self._bot.user.id, channel.guild.id, 1)
self._db.save_changes()
await self.delete_message(msg)
async def send_dm_message(self, message: Union[str, discord.Embed], receiver: Union[discord.User, discord.Member]):
self._logger.debug(__name__, f'Try to send message\n\t{message}\n\tto: {receiver}')
try:
if isinstance(message, discord.Embed):
msg = await receiver.send(embed=message)
else:
msg = await receiver.send(message)
except Exception as e:
self._logger.error(__name__, f'Send message to user {receiver.id} failed', e)
else:
self._clients.append_sent_message_count(self._bot.user.id, receiver.guild.id, 1)
self._db.save_changes()
self._logger.info(__name__, f'Sent message to user {receiver.id}')
async def send_ctx_msg(self, ctx: Context, message: Union[str, discord.Embed], file: discord.File = None, is_persistent: bool = False, wait_before_delete: int = None):
if ctx is None:
self._logger.warn(__name__, 'Message context is empty')
self._logger.debug(__name__, f'Message: {message}')
return
self._logger.debug(__name__, f'Try to send message\t\t{message}\n\tto: {ctx.channel}')
msg = None
try:
if isinstance(message, discord.Embed):
msg = await ctx.send(embed=message, file=file)
else:
msg = await ctx.send(message, file=file)
except Exception as e:
self._logger.error(__name__, f'Send message to channel {ctx.channel.id} failed', e)
else:
self._logger.info(__name__, f'Sent message to channel {ctx.channel.id}')
self._clients.append_sent_message_count(self._bot.user.id, ctx.guild.id, 1)
self._db.save_changes()
if wait_before_delete is not None:
await asyncio.sleep(wait_before_delete)
if is_persistent:
await self.delete_message(ctx.message)
return
await self.delete_messages(List(discord.Message, [msg, ctx.message]), ctx.guild.id)

View File

@ -0,0 +1,357 @@
from abc import ABC, ABCMeta
from datetime import datetime
import json
from typing import Optional, Sequence, Union, Type
import discord
from cpl_core.configuration import ConfigurationModelABC, ConfigurationABC
from cpl_core.dependency_injection import ServiceProviderABC
from cpl_core.environment import ApplicationEnvironmentABC
from cpl_core.logging import LoggerABC
from cpl_core.utils import String
from cpl_query.extension import List, OrderedIterableABC
from discord.ext import commands
from gismo_core.abc.events.on_bulk_message_delete_abc import OnBulkMessageDeleteABC
from gismo_core.abc.events.on_connect_abc import OnConnectABC
from gismo_core.abc.events.on_disconnect_abc import OnDisconnectABC
from gismo_core.abc.events.on_group_join_abc import OnGroupJoinABC
from gismo_core.abc.events.on_group_remove_abc import OnGroupRemoveABC
from gismo_core.abc.events.on_guild_available_abc import OnGuildAvailableABC
from gismo_core.abc.events.on_guild_channel_create_abc import OnGuildChannelCreateABC
from gismo_core.abc.events.on_guild_channel_delete_abc import OnGuildChannelDeleteABC
from gismo_core.abc.events.on_guild_channel_pins_update_abc import OnGuildChannelPinsUpdateABC
from gismo_core.abc.events.on_guild_channel_update_abc import OnGuildChannelUpdateABC
from gismo_core.abc.events.on_guild_emojis_update_abc import OnGuildEmojisUpdateABC
from gismo_core.abc.events.on_guild_integrations_update_abc import OnGuildIntegrationsUpdateABC
from gismo_core.abc.events.on_guild_join_abc import OnGuildJoinABC
from gismo_core.abc.events.on_guild_remove_abc import OnGuildRemoveABC
from gismo_core.abc.events.on_guild_role_create_abc import OnGuildRoleCreateABC
from gismo_core.abc.events.on_guild_role_delete_abc import OnGuildRoleDeleteABC
from gismo_core.abc.events.on_guild_role_update_abc import OnGuildRoleUpdateABC
from gismo_core.abc.events.on_guild_unavailable_abc import OnGuildUnavailableABC
from gismo_core.abc.events.on_guild_update_abc import OnGuildUpdateABC
from gismo_core.abc.events.on_invite_create_abc import OnInviteCreateABC
from gismo_core.abc.events.on_invite_delete_abc import OnInviteDeleteABC
from gismo_core.abc.events.on_member_ban_abc import OnMemberBanABC
from gismo_core.abc.events.on_member_join_abc import OnMemberJoinABC
from gismo_core.abc.events.on_member_remove_abc import OnMemberRemoveABC
from gismo_core.abc.events.on_member_unban_abc import OnMemberUnbanABC
from gismo_core.abc.events.on_member_update_abc import OnMemberUpdateABC
from gismo_core.abc.events.on_message_abc import OnMessageABC
from gismo_core.abc.events.on_message_delete_abc import OnMessageDeleteABC
from gismo_core.abc.events.on_message_edit_abc import OnMessageEditABC
from gismo_core.abc.events.on_private_channel_create_abc import OnPrivateChannelCreateABC
from gismo_core.abc.events.on_private_channel_delete_abc import OnPrivateChannelDeleteABC
from gismo_core.abc.events.on_private_channel_pins_update_abc import OnPrivateChannelPinsUpdateABC
from gismo_core.abc.events.on_private_channel_update_abc import OnPrivateChannelUpdateABC
from gismo_core.abc.events.on_reaction_add_abc import OnReactionAddABC
from gismo_core.abc.events.on_reaction_clear_abc import OnReactionClearABC
from gismo_core.abc.events.on_reaction_clear_emoji_abc import OnReactionClearEmojiABC
from gismo_core.abc.events.on_reaction_remove_abc import OnReactionRemoveABC
from gismo_core.abc.events.on_ready_abc import OnReadyABC
from gismo_core.abc.events.on_relationship_add_abc import OnRelationshipAddABC
from gismo_core.abc.events.on_relationship_remove_abc import OnRelationshipRemoveABC
from gismo_core.abc.events.on_relationship_update_abc import OnRelationshipUpdateABC
from gismo_core.abc.events.on_resume_abc import OnResumeABC
from gismo_core.abc.events.on_typing_abc import OnTypingABC
from gismo_core.abc.events.on_user_update_abc import OnUserUpdateABC
from gismo_core.abc.events.on_voice_state_update_abc import OnVoiceStateUpdateABC
from gismo_core.abc.events.on_webhooks_update_abc import OnWebhooksUpdateABC
from gismo_core.abc.module_abc import ModuleABC
from gismo_core.abc.module_service_abc import ModuleServiceABC
from gismo_core.commands_meta import CommandsMeta
class ModuleService(ModuleServiceABC, commands.Cog, metaclass=CommandsMeta):
def __init__(self, logger: LoggerABC, config: ConfigurationABC, services: ServiceProviderABC, env: ApplicationEnvironmentABC):
self._logger = logger
self._config = config
self._services = services
self._env = env
self._modules_types: List[Type[ModuleABC]] = List()
self._modules_types.extend(ModuleABC.__subclasses__())
self._modules: List[ModuleABC] = List(ModuleABC)
async def _handle_event(self, event: type, *args):
self._logger.debug(__name__, f'Start {event} modules')
# modules = self._get_modules(event)
modules = self._modules.where(lambda m: isinstance(m, event)).order_by(lambda m: m.get_priority(event))
if modules.count() < 1:
self._logger.debug(__name__, f'Stopped {event} modules')
return
try:
func_name = String.convert_to_snake_case(event.__name__.split('ABC')[0])
for module in modules:
self._logger.trace(__name__, f'Start {type(module)} module')
func = getattr(module, func_name)
await func(*args)
if not module.success:
self._logger.debug(__name__, f'Stopped propagation for {event} from {type(module)}')
break
except Exception as e:
self._logger.error(__name__, f'Start {event} modules failed', e)
self._logger.debug(__name__, f'Stopped {event} modules')
def load_modules(self):
self._logger.debug(__name__, f'Start loading modules')
for module_type in self._modules_types:
module: ModuleABC = self._services.get_service(module_type)
if module is None:
self._logger.warn(__name__, f'Module {module_type} not found in services!')
break
loaded_settings: list[str] = []
for settings_type in module.settings_types:
settings_name = settings_type.__name__.split('Settings')[0]
if settings_name in loaded_settings:
continue
with open(f'config/{String.convert_to_snake_case(settings_name).lower()}.json', encoding='utf-8') as cfg:
json_cfg = json.load(cfg)
for index in json_cfg:
settings: ConfigurationModelABC = settings_type()
settings.from_dict(json_cfg[index])
self._config.add_configuration(f'{type(module).__name__}_{index}', settings)
self._logger.debug(__name__, f'Added config: {type(module).__name__}_{index}')
loaded_settings.append(settings_name)
self._modules.append(module)
@commands.Cog.listener()
async def on_connect(self):
self._logger.trace(__name__, f'Received on_connect')
await self._handle_event(OnConnectABC)
@commands.Cog.listener()
async def on_disconnect(self):
self._logger.trace(__name__, f'Received on_disconnect')
await self._handle_event(OnDisconnectABC)
async def on_ready(self):
self._logger.trace(__name__, f'Received on_ready')
await self._handle_event(OnReadyABC)
@commands.Cog.listener()
async def on_resume(self):
self._logger.trace(__name__, f'Received on_resume')
await self._handle_event(OnResumeABC)
@commands.Cog.listener()
async def on_error(self, event: str, *args, **kwargs):
self._logger.trace(__name__, f'Received on_error:\n\t{event}\n\t{args}\n\t{kwargs}')
await self._handle_event(OnReadyABC, event, *args, **kwargs)
@commands.Cog.listener()
async def on_typing(self, channel: discord.abc.Messageable, user: Union[discord.User, discord.Member], when: datetime):
self._logger.trace(__name__, f'Received on_typing:\n\t{channel}\n\t{user}\n\t{when}')
await self._handle_event(OnTypingABC, channel, user, when)
@commands.Cog.listener()
async def on_message(self, message: discord.Message):
self._logger.trace(__name__, f'Received on_message:\n\t{message}\n\t{message.content}')
await self._handle_event(OnMessageABC, message)
@commands.Cog.listener()
async def on_message_delete(self, message: discord.Message):
self._logger.trace(__name__, f'Received on_message_delete:\n\t{message}\n\t{message.content}')
await self._handle_event(OnMessageDeleteABC, message)
@commands.Cog.listener()
async def on_bulk_message_delete(self, messages: list[discord.Message]):
self._logger.trace(__name__, f'Received on_bulk_message_delete:\n\t{len(messages)}')
await self._handle_event(OnBulkMessageDeleteABC, messages)
@commands.Cog.listener()
async def on_message_edit(self, before: discord.Message, after: discord.Message):
self._logger.trace(__name__, f'Received on_message_edit:\n\t{before}\n\t{after}')
await self._handle_event(OnMessageEditABC, before, after)
@commands.Cog.listener()
async def on_reaction_add(self, reaction: discord.Reaction, user: discord.User):
self._logger.trace(__name__, f'Received on_reaction_add:\n\t{reaction}\n\t{user}')
await self._handle_event(OnReactionAddABC, reaction, user)
@commands.Cog.listener()
async def on_reaction_remove(self, reaction: discord.Reaction, user: discord.User):
self._logger.trace(__name__, f'Received on_reaction_remove:\n\t{reaction}\n\t{user}')
await self._handle_event(OnReactionRemoveABC, reaction, user)
@commands.Cog.listener()
async def on_reaction_clear(self, message: discord.Message, reactions: list[discord.Reaction]):
self._logger.trace(__name__, f'Received on_reaction_reon_reaction_clearmove:\n\t{message}\n\t{len(reactions)}')
await self._handle_event(OnReactionClearABC, message, reactions)
@commands.Cog.listener()
async def on_reaction_clear_emoji(self, reaction: discord.Reaction):
self._logger.trace(__name__, f'Received on_reaction_clear_emoji:\n\t{reaction}')
await self._handle_event(OnReactionClearEmojiABC, reaction)
@commands.Cog.listener()
async def on_private_channel_delete(self, channel: discord.abc.PrivateChannel):
self._logger.trace(__name__, f'Received on_private_channel_delete:\n\t{channel}')
await self._handle_event(OnPrivateChannelDeleteABC, channel)
@commands.Cog.listener()
async def on_private_channel_create(self, channel: discord.abc.PrivateChannel):
self._logger.trace(__name__, f'Received on_private_channel_create:\n\t{channel}')
await self._handle_event(OnPrivateChannelCreateABC, channel)
@commands.Cog.listener()
async def on_private_channel_update(self, before: discord.GroupChannel, after: discord.GroupChannel):
self._logger.trace(__name__, f'Received on_private_channel_update:\n\t{before}\n\t{after}')
await self._handle_event(OnPrivateChannelUpdateABC, before, after)
@commands.Cog.listener()
async def on_private_channel_pins_update(self, channel: discord.abc.PrivateChannel, list_pin: Optional[datetime]):
self._logger.trace(__name__, f'Received on_private_channel_pins_update:\n\t{channel}\n\t{list_pin}')
await self._handle_event(OnPrivateChannelPinsUpdateABC, channel, list_pin)
@commands.Cog.listener()
async def on_guild_channel_delete(self, channel: discord.abc.GuildChannel):
self._logger.trace(__name__, f'Received on_guild_channel_delete:\n\t{channel}')
await self._handle_event(OnGuildChannelDeleteABC, channel)
@commands.Cog.listener()
async def on_guild_channel_create(self, channel: discord.abc.GuildChannel):
self._logger.trace(__name__, f'Received on_guild_channel_create:\n\t{channel}')
await self._handle_event(OnGuildChannelCreateABC, channel)
@commands.Cog.listener()
async def on_guild_channel_update(self, before: discord.abc.GuildChannel, after: discord.abc.GuildChannel):
self._logger.trace(__name__, f'Received on_guild_channel_update:\n\t{before}\n\t{after}')
await self._handle_event(OnGuildChannelUpdateABC, before, after)
@commands.Cog.listener()
async def on_guild_channel_pins_update(self, channel: discord.abc.GuildChannel, list_pin: Optional[datetime]):
self._logger.trace(__name__, f'Received on_guild_channel_pins_update:\n\t{channel}\n\t{list_pin}')
await self._handle_event(OnGuildChannelPinsUpdateABC, channel, list_pin)
@commands.Cog.listener()
async def on_guild_integrations_update(self, guild: discord.Guild):
self._logger.trace(__name__, f'Received on_guild_integrations_update:\n\t{guild}')
await self._handle_event(OnGuildIntegrationsUpdateABC, guild)
@commands.Cog.listener()
async def on_webhooks_update(self, channel: discord.abc.GuildChannel):
self._logger.trace(__name__, f'Received on_webhooks_update:\n\t{channel}')
await self._handle_event(OnWebhooksUpdateABC, channel)
@commands.Cog.listener()
async def on_member_join(self, member: discord.Member):
self._logger.trace(__name__, f'Received on_member_join:\n\t{member}')
await self._handle_event(OnMemberJoinABC, member)
@commands.Cog.listener()
async def on_member_remove(self, member: discord.Member):
self._logger.trace(__name__, f'Received on_member_remove:\n\t{member}')
await self._handle_event(OnMemberRemoveABC, member)
@commands.Cog.listener()
async def on_member_update(self, before: discord.Member, after: discord.Member):
self._logger.trace(__name__, f'Received on_member_update:\n\t{before}\n\t{after}')
await self._handle_event(OnMemberUpdateABC, before, after)
@commands.Cog.listener()
async def on_user_update(self, before: discord.User, after: discord.User):
self._logger.trace(__name__, f'Received on_user_update:\n\t{before}\n\t{after}')
await self._handle_event(OnUserUpdateABC, before, after)
@commands.Cog.listener()
async def on_guild_join(self, guild: discord.Guild):
self._logger.trace(__name__, f'Received on_guild_join:\n\t{guild}')
await self._handle_event(OnGuildJoinABC, guild)
@commands.Cog.listener()
async def on_guild_remove(self, guild: discord.Guild):
self._logger.trace(__name__, f'Received on_guild_remove:\n\t{guild}')
await self._handle_event(OnGuildRemoveABC, guild)
@commands.Cog.listener()
async def on_guild_update(self, before: discord.Guild, after: discord.Guild):
self._logger.trace(__name__, f'Received on_guild_update:\n\t{before}\n\t{after}')
await self._handle_event(OnGuildUpdateABC, before, after)
@commands.Cog.listener()
async def on_guild_role_create(self, role: discord.Role):
self._logger.trace(__name__, f'Received on_guild_role_create:\n\t{role}')
await self._handle_event(OnGuildRoleCreateABC, role)
@commands.Cog.listener()
async def on_guild_role_delete(self, role: discord.Role):
self._logger.trace(__name__, f'Received on_guild_role_delete:\n\t{role}')
await self._handle_event(OnGuildRoleDeleteABC, role)
@commands.Cog.listener()
async def on_guild_role_update(self, before: discord.Role, after: discord.Role):
self._logger.trace(__name__, f'Received on_guild_role_update:\n\t{before}\n\t{after}')
await self._handle_event(OnGuildRoleUpdateABC, before, after)
@commands.Cog.listener()
async def on_guild_emojis_update(self, guild: discord.Guild, before: Sequence[discord.Emoji], after: Sequence[discord.Emoji]):
self._logger.trace(__name__, f'Received on_guild_emojis_update:\n\t{guild}\n\t{before}\n\t{after}')
await self._handle_event(OnGuildEmojisUpdateABC, guild, before, after)
@commands.Cog.listener()
async def on_guild_available(self, guild: discord.Guild):
self._logger.trace(__name__, f'Received on_guild_available:\n\t{guild}')
await self._handle_event(OnGuildAvailableABC, guild)
@commands.Cog.listener()
async def on_guild_unavailable(self, guild: discord.Guild):
self._logger.trace(__name__, f'Received on_guild_unavailable:\n\t{guild}')
await self._handle_event(OnGuildUnavailableABC, guild)
@commands.Cog.listener()
async def on_voice_state_update(self, member: discord.Member, before: discord.VoiceState, after: discord.VoiceState):
self._logger.trace(__name__, f'Received on_voice_state_update:\n\t{member}\n\t{before}\n\t{after}')
await self._handle_event(OnVoiceStateUpdateABC, member, before, after)
@commands.Cog.listener()
async def on_member_ban(self, guild: discord.Guild, user: discord.User):
self._logger.trace(__name__, f'Received on_member_ban:\n\t{guild}\n\t{user}')
await self._handle_event(OnMemberBanABC, guild, user)
@commands.Cog.listener()
async def on_member_unban(self, guild: discord.Guild, user: discord.User):
self._logger.trace(__name__, f'Received on_member_unban:\n\t{guild}\n\t{user}')
await self._handle_event(OnMemberUnbanABC, guild, user)
@commands.Cog.listener()
async def on_invite_create(self, invite: discord.Invite):
self._logger.trace(__name__, f'Received on_invite_create:\n\t{invite}')
await self._handle_event(OnInviteCreateABC, invite)
@commands.Cog.listener()
async def on_invite_delete(self, invite: discord.Invite):
self._logger.trace(__name__, f'Received on_invite_create:\n\t{invite}')
await self._handle_event(OnInviteDeleteABC, invite)
@commands.Cog.listener()
async def on_group_join(self, channel: discord.GroupChannel, user: discord.User):
self._logger.trace(__name__, f'Received on_group_join:\n\t{channel}\n\t{user}')
await self._handle_event(OnGroupJoinABC, channel, user)
@commands.Cog.listener()
async def on_group_remove(self, channel: discord.GroupChannel, user: discord.User):
self._logger.trace(__name__, f'Received on_group_remove:\n\t{channel}\n\t{user}')
await self._handle_event(OnGroupRemoveABC, channel, user)
@commands.Cog.listener()
async def on_relationship_add(self, relationship: discord.Relationship):
self._logger.trace(__name__, f'Received on_relationship_add:\n\t{relationship}')
await self._handle_event(OnRelationshipAddABC, relationship)
@commands.Cog.listener()
async def on_relationship_remove(self, relationship: discord.Relationship):
self._logger.trace(__name__, f'Received on_relationship_remove:\n\t{relationship}')
await self._handle_event(OnRelationshipRemoveABC, relationship)
@commands.Cog.listener()
async def on_relationship_update(self, before: discord.Relationship, after: discord.Relationship):
self._logger.trace(__name__, f'Received on_relationship_update:\n\t{before}\n\t{after}')
await self._handle_event(OnRelationshipUpdateABC, before, after)

View File

@ -0,0 +1,25 @@
# -*- coding: utf-8 -*-
"""
gismo sh-edraft Gismo
~~~~~~~~~~~~~~~~~~~
sh-edraft Dicord bot Gismo
:copyright: (c) 2021 - 2022 sh-edraft.de
:license: MIT, see LICENSE for more details.
"""
__title__ = 'gismo_data'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2021 - 2022 sh-edraft.de'
__version__ = '0.4.2'
from collections import namedtuple
# imports
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='0', minor='4', micro='2')

View File

@ -0,0 +1,25 @@
# -*- coding: utf-8 -*-
"""
gismo sh-edraft Gismo
~~~~~~~~~~~~~~~~~~~
sh-edraft Dicord bot Gismo
:copyright: (c) 2021 - 2022 sh-edraft.de
:license: MIT, see LICENSE for more details.
"""
__title__ = 'gismo_data.abc'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2021 - 2022 sh-edraft.de'
__version__ = '0.4.2'
from collections import namedtuple
# imports
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='0', minor='4', micro='2')

View File

@ -0,0 +1,53 @@
from abc import ABC, abstractmethod
from typing import Optional
from cpl_query.extension import List
from gismo_data.model.client import Client
class ClientRepositoryABC(ABC):
@abstractmethod
def __init__(self): pass
@abstractmethod
def get_clients(self) -> List[Client]: pass
@abstractmethod
def get_client_by_id(self, client_id: int) -> Client: pass
@abstractmethod
def get_client_by_discord_id(self, discord_id: int) -> Client: pass
@abstractmethod
def find_client_by_discord_id(self, discord_id: int) -> Optional[Client]: pass
@abstractmethod
def find_client_by_server_id(self, server_id: int) -> Optional[Client]: pass
@abstractmethod
def find_client_by_discord_id_and_server_id(self, discord_id: int, server_id: int) -> Optional[Client]: pass
@abstractmethod
def add_client(self, client: Client): pass
@abstractmethod
def update_client(self, client: Client): pass
@abstractmethod
def delete_client(self, client: Client): pass
@abstractmethod
def append_sent_message_count(self, client_id: int, server_id: int, value: int): pass
@abstractmethod
def append_received_message_count(self, client_id: int, server_id: int, value: int): pass
@abstractmethod
def append_deleted_message_count(self, client_id: int, server_id: int, value: int): pass
@abstractmethod
def append_received_command_count(self, client_id: int, server_id: int, value: int): pass
@abstractmethod
def append_moved_users_count(self, client_id: int, server_id: int, value: int): pass

View File

@ -0,0 +1,30 @@
from abc import ABC, abstractmethod
from typing import Optional
from cpl_query.extension import List
from gismo_data.model.known_user import KnownUser
class KnownUserRepositoryABC(ABC):
@abstractmethod
def __init__(self): pass
@abstractmethod
def get_users(self) -> List[KnownUser]: pass
@abstractmethod
def get_user_by_id(self, id: int) -> KnownUser: pass
@abstractmethod
def get_user_by_discord_id(self, discord_id: int) -> KnownUser: pass
@abstractmethod
def find_user_by_discord_id(self, discord_id: int) -> Optional[KnownUser]: pass
@abstractmethod
def add_user(self, known_user: KnownUser): pass
@abstractmethod
def delete_user(self, known_user: KnownUser): pass

View File

@ -0,0 +1,13 @@
from abc import ABC, abstractmethod
class MigrationABC(ABC):
@abstractmethod
def __init__(self): pass
@abstractmethod
def upgrade(self): pass
@abstractmethod
def downgrade(self): pass

View File

@ -0,0 +1,33 @@
from abc import ABC, abstractmethod
from typing import Optional
from cpl_query.extension import List
from gismo_data.model.server import Server
class ServerRepositoryABC(ABC):
@abstractmethod
def __init__(self): pass
@abstractmethod
def get_servers(self) -> List[Server]: pass
@abstractmethod
def get_server_by_id(self, id: int) -> Server: pass
@abstractmethod
def get_server_by_discord_id(self, discord_id: int) -> Server: pass
@abstractmethod
def find_server_by_discord_id(self, discord_id: int) -> Optional[Server]: pass
@abstractmethod
def add_server(self, server: Server): pass
@abstractmethod
def update_server(self, server: Server): pass
@abstractmethod
def delete_server(self, server: Server): pass

View File

@ -0,0 +1,35 @@
from abc import ABC, abstractmethod
from typing import Optional
from cpl_query.extension import List
from gismo_data.model.user_joined_server import UserJoinedServer
class UserJoinedServerRepositoryABC(ABC):
@abstractmethod
def __init__(self): pass
@abstractmethod
def get_user_joined_servers(self) -> List[UserJoinedServer]: pass
@abstractmethod
def get_user_joined_server_by_id(self, id: int) -> UserJoinedServer: pass
@abstractmethod
def get_user_joined_servers_by_user_id(self, user_id: int) -> list[UserJoinedServer]: pass
@abstractmethod
def get_active_user_joined_server_by_user_id(self, user_id: int) -> UserJoinedServer: pass
@abstractmethod
def find_active_user_joined_server_by_user_id(self, user_id: int) -> Optional[UserJoinedServer]: pass
@abstractmethod
def add_user_joined_server(self, user_joined_server: UserJoinedServer): pass
@abstractmethod
def update_user_joined_server(self, user_joined_server: UserJoinedServer): pass
@abstractmethod
def delete_user_joined_server(self, user_joined_server: UserJoinedServer): pass

View File

@ -0,0 +1,37 @@
from abc import ABC, abstractmethod
from typing import Optional
from cpl_query.extension import List
from gismo_data.model.user_joined_voice_channel import UserJoinedVoiceChannel
class UserJoinedVoiceChannelRepositoryABC(ABC):
@abstractmethod
def __init__(self): pass
@abstractmethod
def get_user_joined_voice_channels(self) -> List[UserJoinedVoiceChannel]: pass
@abstractmethod
def get_user_joined_voice_channel_by_id(self, id: int) -> UserJoinedVoiceChannel: pass
@abstractmethod
def get_user_joined_voice_channels_by_user_id(self, user_id: int) -> list[UserJoinedVoiceChannel]: pass
@abstractmethod
def get_active_user_joined_voice_channel_by_user_id(self, user_id: int) -> UserJoinedVoiceChannel: pass
@abstractmethod
def find_active_user_joined_voice_channel_by_user_id(self, user_id: int) -> Optional[UserJoinedVoiceChannel]: pass
@abstractmethod
def find_active_user_joined_voice_channels_by_user_id(self, user_id: int) -> List[Optional[UserJoinedVoiceChannel]]: pass
@abstractmethod
def add_user_joined_voice_channel(self, user_joined_voice_channel: UserJoinedVoiceChannel): pass
@abstractmethod
def update_user_joined_voice_channel(self, user_joined_voice_channel: UserJoinedVoiceChannel): pass
@abstractmethod
def delete_user_joined_voice_channel(self, user_joined_voice_channel: UserJoinedVoiceChannel): pass

View File

@ -0,0 +1,36 @@
from abc import ABC, abstractmethod
from typing import Optional
from cpl_query.extension import List
from gismo_data.model.user import User
class UserRepositoryABC(ABC):
@abstractmethod
def __init__(self): pass
@abstractmethod
def get_users(self) -> List[User]: pass
@abstractmethod
def get_user_by_id(self, id: int) -> User: pass
@abstractmethod
def get_users_by_discord_id(self, discord_id: int) -> List[User]: pass
@abstractmethod
def get_user_by_discord_id_and_server_id(self, discord_id: int, server_id: int) -> User: pass
@abstractmethod
def find_user_by_discord_id_and_server_id(self, discord_id: int, server_id: int) -> Optional[User]: pass
@abstractmethod
def add_user(self, user: User): pass
@abstractmethod
def update_user(self, user: User): pass
@abstractmethod
def delete_user(self, user: User): pass

View File

@ -0,0 +1,33 @@
from cpl_core.database import DatabaseSettings
from cpl_core.database.context import DatabaseContext
from cpl_core.logging import LoggerABC
class DBContext(DatabaseContext):
def __init__(self, logger: LoggerABC):
self._logger = logger
DatabaseContext.__init__(self)
def connect(self, database_settings: DatabaseSettings):
try:
self._logger.debug(__name__, "Connecting to database")
self._db.connect(database_settings)
self.save_changes()
self._logger.info(__name__, "Connected to database")
except Exception as e:
self._logger.fatal(__name__, "Connecting to database failed", e)
def save_changes(self):
try:
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]:
return super(DBContext, self).select(statement)

View File

@ -0,0 +1,44 @@
{
"ProjectSettings": {
"Name": "gismo-data",
"Version": {
"Major": "0",
"Minor": "1",
"Micro": "0"
},
"Author": "Sven Heidemann",
"AuthorEmail": "sven.heidemann@sh-edraft.de",
"Description": "sh-edraft Gismo - data",
"LongDescription": "sh-edraft Dicord bot Gismo - data library",
"URL": "https://www.sh-edraft.de",
"CopyrightDate": "2021 - 2022",
"CopyrightName": "sh-edraft.de",
"LicenseName": "MIT",
"LicenseDescription": "MIT, see LICENSE for more details.",
"Dependencies": [
"sh_cpl-core>=2021.11.0",
"sh_cpl-query>=2021.11.0"
],
"PythonVersion": ">=3.9.2",
"PythonPath": {
"linux": "../../venv/bin/python"
},
"Classifiers": []
},
"BuildSettings": {
"ProjectType": "library",
"SourcePath": "",
"OutputPath": "../../dist",
"Main": "",
"EntryPoint": "",
"IncludePackageData": false,
"Included": [],
"Excluded": [
"*/__pycache__",
"*/logs",
"*/tests"
],
"PackageData": {},
"ProjectReferences": []
}
}

Some files were not shown because too many files have changed in this diff Show More