From 7aef7be6dd5f8975c042df6ba9b990f6f01362a6 Mon Sep 17 00:00:00 2001 From: Funky Waddle Date: Tue, 24 Jun 2025 01:34:26 -0500 Subject: [PATCH] Convert Language and Framework buttons to Database. Convert Twitch Live Watchlist to Database. --- __main__.py | 2 +- cogs/roles.py | 5 +- cogs/twitch_notifications.py | 7 ++- config.json | 13 ++--- data/TwitchLiveNotification.py | 0 data/bot.db | Bin 0 -> 20480 bytes data/models/Framework.py | 11 ++++ data/models/Language.py | 11 ++++ data/models/TwitchLiveNotification.py | 11 ++++ embeds/FrameworkRolesEmbed.py | 20 +++++++ embeds/MatrixRolesEmbed.py | 5 +- libs/Db.py | 31 ++++++----- libs/FrameworkButton.py | 27 ++++++++++ libs/LanguageButton.py | 25 ++++++--- libs/View.py | 28 ++++++++++ views/FrameworkButtons.py | 19 +++++++ views/LanguageButtons.py | 31 +++++------ views/MatrixButtons.py | 51 ++---------------- views/items/CSLanguageButton.py | 11 ---- views/items/JSLanguageButton.py | 11 ---- views/items/JavaLanguageButton.py | 11 ---- views/items/PHPLanguageButton.py | 11 ---- views/items/PythonLanguageButton.py | 11 ---- views/items/RubyLanguageButton.py | 11 ---- .../MatrixPenguinsButton.py | 0 .../MatrixRefuserPenguinsButton.py | 0 26 files changed, 199 insertions(+), 164 deletions(-) delete mode 100644 data/TwitchLiveNotification.py create mode 100644 data/bot.db create mode 100644 data/models/Framework.py create mode 100644 data/models/Language.py create mode 100644 data/models/TwitchLiveNotification.py create mode 100644 embeds/FrameworkRolesEmbed.py create mode 100644 libs/FrameworkButton.py create mode 100644 libs/View.py create mode 100644 views/FrameworkButtons.py delete mode 100644 views/items/CSLanguageButton.py delete mode 100644 views/items/JSLanguageButton.py delete mode 100644 views/items/JavaLanguageButton.py delete mode 100644 views/items/PHPLanguageButton.py delete mode 100644 views/items/PythonLanguageButton.py delete mode 100644 views/items/RubyLanguageButton.py rename views/items/{ => matrix_buttons}/MatrixPenguinsButton.py (100%) rename views/items/{ => matrix_buttons}/MatrixRefuserPenguinsButton.py (100%) diff --git a/__main__.py b/__main__.py index 1d5184d..d5afd0f 100644 --- a/__main__.py +++ b/__main__.py @@ -48,7 +48,7 @@ class FunkyBot(commands.Bot): the_channel = await Channels().get_channel(self.guild, channel) await the_channel.purge() if message is not None: - await the_channel.send(message) + # await the_channel.send(message) ... async def close(self): diff --git a/cogs/roles.py b/cogs/roles.py index 9a3589d..0fb459d 100644 --- a/cogs/roles.py +++ b/cogs/roles.py @@ -1,11 +1,13 @@ from discord.ext import commands from embeds.MatrixRolesEmbed import MatrixRolesEmbed from embeds.LanguageRolesEmbed import LanguageRolesEmbed +from embeds.FrameworkRolesEmbed import FrameworkRolesEmbed from libs.Channels import Channels from libs.Guilds import Guilds from libs.Cog import Cog from views.MatrixButtons import MatrixButtons from views.LanguageButtons import LanguageButtons +from views.FrameworkButtons import FrameworkButtons class RolesCog(Cog): @@ -22,7 +24,8 @@ class RolesCog(Cog): if channel is not None: await channel.purge() await channel.send(embed=MatrixRolesEmbed(), view=MatrixButtons()) - await channel.send(embed=LanguageRolesEmbed(), view=LanguageButtons()) + await channel.send(embed=LanguageRolesEmbed(), view=LanguageButtons(self.bot)) + await channel.send(embed=FrameworkRolesEmbed(), view=FrameworkButtons(self.bot)) async def setup(bot): diff --git a/cogs/twitch_notifications.py b/cogs/twitch_notifications.py index 57db973..a6f0aae 100644 --- a/cogs/twitch_notifications.py +++ b/cogs/twitch_notifications.py @@ -6,6 +6,7 @@ from libs.Channels import Channels from libs.Guilds import Guilds from embeds.TwitchGameNotificationEmbed import TwitchGameNotificationEmbed from discord.ext import commands, tasks +from data.models.TwitchLiveNotification import TwitchLiveNotification class TwitchNotificationsCog(Cog): @@ -65,7 +66,11 @@ class TwitchNotificationsCog(Cog): if not channel: return - online_notifications, offline_notifications = await self.twitch.get_notifications(self.config[self.guild.name]['twitch']['watchlist']) + watchlist_notifications = self.bot.db.session.query(TwitchLiveNotification).all() + watchlist = [notify.username for notify in watchlist_notifications] + print("WATCHLIST", watchlist) + + online_notifications, offline_notifications = await self.twitch.get_notifications(watchlist) print("online_notifications", online_notifications) print("offline_notifications", offline_notifications) diff --git a/config.json b/config.json index 9286fa5..3aad36f 100644 --- a/config.json +++ b/config.json @@ -12,15 +12,12 @@ }, "OgmaBotDev": { "twitch": { - "client_id": "[redacted]", - "client_secret": "[redacted]", - "access_token": "[redacted]", - "channel_id": "[redacted]", + "client_id": "p41kt8by26lf849jz63sdgri1plpqq", + "client_secret": "2wh0kjznetlf1nw19tkoedd73ilje7", + "access_token": "j1ourtl76gti896r5lllcfjikrsjap", + "channel_id": 1385668221582970981, "channel_name": "live-penguins", - "expire_date": "[redacted]", - "watchlist": [ - "funkywaddle" - ] + "expire_date": 1752548253 } } } \ No newline at end of file diff --git a/data/TwitchLiveNotification.py b/data/TwitchLiveNotification.py deleted file mode 100644 index e69de29..0000000 diff --git a/data/bot.db b/data/bot.db new file mode 100644 index 0000000000000000000000000000000000000000..35dbe0e0408d368800a6cb6daec2c15ad103ef28 GIT binary patch literal 20480 zcmeI(ziS(37zgn8d^(?Xmi^i_Mi^84+F5)w6dH%Ft}35wC#tNT)PRQ|UR$rMvrl*C z^q!0cL)9hZ56F}$BxGurhGYo@I(90Zx^(E!rCZ6Ct?wQ9hX#cjifQ2cg3$B4@7?jf zA4$WD-lz6;*^`2`!l=U~TO%_>)5sT$5u!pu4D~u|Sruf?67{ZKibsVrFxWNB{PME)-KpezzGy|fBTmBTsCyCV zMb|0R9ab-VS$5b(KU=l3UXyKC>dvO)vdT`KRlX^gZ!#+G^suW2VwEbX|?_GTsNTfOvjo4HQOah*!hsj;*EZhDtx z4@kz$FD+?o9w6gQ=_b%)z6Sr)o{$hmu|FwHCtDAY-)&}=ewMOIO6K|+? zIm-009U<00Izz00bZa0SG_<0uZ}!v$tUf86#JqnS|VtQ=(A}}CpTJgaMVBH&89Ds{r@Cw6Z)3^Nq?h1)7SI|`h-5B z59q1tMuPwZAOHafKmY;|fB*y_009U<;0gkBlNqAfR$X)@E1ex+nXpvnoN+G}xvYv7 z$7}sgD-8P9gv#{@z{}fB*y_009U<00Izz00ba# zT>_@1llkP}fSFZ+8>?U<4fgtJi9oe4+hH)SN(AQA-}`BKz#UZ&P}`5ZV`-}LfcYdf YRAs>IW@xIKfcXs`NkbI^%ocC_1JC0