Skip to content

Commit

Permalink
chore: Re-add deleted file
Browse files Browse the repository at this point in the history
  • Loading branch information
null2264 committed Jul 31, 2024
1 parent 54be826 commit b690fbe
Show file tree
Hide file tree
Showing 2 changed files with 97 additions and 10 deletions.
87 changes: 87 additions & 0 deletions src/main/migrations/models/0_20211009115827_init.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
-- upgrade --
CREATE TABLE IF NOT EXISTS "commands" (
"id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
"type" TEXT NOT NULL,
"name" TEXT NOT NULL,
"category" TEXT NOT NULL,
"description" TEXT,
"content" TEXT NOT NULL,
"url" TEXT,
"uses" BIGINT NOT NULL DEFAULT 0,
"ownerId" BIGINT NOT NULL,
"createdAt" TIMESTAMP NOT NULL,
"visibility" INT NOT NULL DEFAULT 0,
"enabled" INT NOT NULL DEFAULT 1
);
CREATE TABLE IF NOT EXISTS "guilds" (
"id" BIGINT NOT NULL PRIMARY KEY
);
CREATE TABLE IF NOT EXISTS "caseLog" (
"id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
"caseId" BIGINT NOT NULL,
"type" TEXT NOT NULL,
"modId" BIGINT NOT NULL,
"targetId" BIGINT NOT NULL,
"reason" TEXT NOT NULL,
"createdAt" TIMESTAMP NOT NULL,
"guild_id" BIGINT NOT NULL REFERENCES "guilds" ("id") ON DELETE CASCADE
);
CREATE TABLE IF NOT EXISTS "commandsLookup" (
"id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
"name" TEXT NOT NULL,
"cmd_id" BIGINT NOT NULL REFERENCES "commands" ("id") ON DELETE CASCADE,
"guild_id" BIGINT NOT NULL REFERENCES "guilds" ("id") ON DELETE CASCADE
);
CREATE TABLE IF NOT EXISTS "disabled" (
"id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
"command" TEXT NOT NULL,
"guild_id" BIGINT NOT NULL REFERENCES "guilds" ("id") ON DELETE CASCADE
);
CREATE TABLE IF NOT EXISTS "guildChannels" (
"id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
"welcomeCh" BIGINT,
"farewellCh" BIGINT,
"modlogCh" BIGINT,
"purgatoryCh" BIGINT,
"announcementCh" BIGINT,
"guild_id" BIGINT NOT NULL REFERENCES "guilds" ("id") ON DELETE CASCADE
);
CREATE TABLE IF NOT EXISTS "guildConfigs" (
"id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
"ccMode" INT NOT NULL DEFAULT 0,
"tagMode" INT NOT NULL DEFAULT 0,
"welcomeMsg" TEXT,
"farewellMsg" TEXT,
"guild_id" BIGINT NOT NULL REFERENCES "guilds" ("id") ON DELETE CASCADE
);
CREATE TABLE IF NOT EXISTS "guildMutes" (
"id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
"mutedId" BIGINT NOT NULL,
"guild_id" BIGINT NOT NULL REFERENCES "guilds" ("id") ON DELETE CASCADE
);
CREATE TABLE IF NOT EXISTS "guildRoles" (
"id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
"modRole" BIGINT,
"mutedRole" BIGINT,
"autoRole" BIGINT,
"guild_id" BIGINT NOT NULL REFERENCES "guilds" ("id") ON DELETE CASCADE
);
CREATE TABLE IF NOT EXISTS "prefixes" (
"id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
"prefix" TEXT NOT NULL,
"guild_id" BIGINT NOT NULL REFERENCES "guilds" ("id") ON DELETE CASCADE
);
CREATE TABLE IF NOT EXISTS "timer" (
"id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
"event" TEXT NOT NULL,
"extra" JSON NOT NULL,
"expires" TIMESTAMP NOT NULL,
"created" TIMESTAMP NOT NULL,
"owner" BIGINT NOT NULL
);
CREATE TABLE IF NOT EXISTS "aerich" (
"id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
"version" VARCHAR(255) NOT NULL,
"app" VARCHAR(20) NOT NULL,
"content" JSON NOT NULL
);
20 changes: 10 additions & 10 deletions src/zibot/exts/meta/meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

from ...core import checks
from ...core import commands as cmds
from ...core.data import ExpiringDict
from ...core.context import Context
from ...core.embed import ZEmbed, ZEmbedBuilder
from ...core.errors import DefaultError
Expand Down Expand Up @@ -305,7 +306,12 @@ async def onHighlight(self, message: discord.Message):
if message.author.bot or not message.content or not guild:
return

channel = message.channel
channelId = message.channel.id
authorId = message.author.id
msgId = message.id
if not self.lastSeen.get(channelId):
self.lastSeen[channelId] = ExpiringDict(maxAgeSeconds=1800)
self.lastSeen[channelId][authorId] = msgId

if not (guildHighlight := self.highlights.get(guild.id)):
return
Expand All @@ -315,8 +321,8 @@ async def onHighlight(self, message: discord.Message):
continue

# Getting context
msgs: List[discord.Message] = [message]
async for history in channel.history(limit=4, before=message.created_at):
msgs: list[discord.Message] = [message]
async for history in message.channel.history(limit=4, before=message.created_at):
msgs.append(history)

context = []
Expand All @@ -338,14 +344,8 @@ async def onHighlight(self, message: discord.Message):
if owner == message.author.id:
continue

# Check if member sent a message 30 minutes prior
if await channel.history(
after=utcnow() - dt.timedelta(minutes=30.0)
).get(author__id=owner):
continue

user = guild.get_member(owner) or await guild.fetch_member(owner)
if user:
if user and self.lastSeen.get(channelId, {}).get(user.id):
await user.send(
"In {0.channel.mention} ({0.guild})".format(message),
embed=e,
Expand Down

0 comments on commit b690fbe

Please sign in to comment.