Compare commits
No commits in common. "4b09f99e9406ad1c80dbcbe69ef0f210d0af1036" and "8f3c67304dc3fdf1293fd77487c00d7a67e8fce2" have entirely different histories.
4b09f99e94
...
8f3c67304d
7 changed files with 1841 additions and 1257 deletions
|
@ -68,11 +68,17 @@ class MessageEventMixin:
|
||||||
|
|
||||||
async def checks(self, message: Message) -> None:
|
async def checks(self, message: Message) -> None:
|
||||||
"""Other message checks."""
|
"""Other message checks."""
|
||||||
|
# #tech
|
||||||
|
# channel = find(lambda x: x.id == 599068193339736096, message._mention_ids)
|
||||||
|
# if channel and message.author.id == 293795462752894976:
|
||||||
|
# await channel.send(
|
||||||
|
# content="https://cdn.discordapp.com/attachments/664621130044407838/805218508866453554/tech.gif"
|
||||||
|
# )
|
||||||
content = re.sub(r"\s+", "", message.content)
|
content = re.sub(r"\s+", "", message.content)
|
||||||
match = invites.search(content)
|
match = invites.search(content)
|
||||||
setting = await Setting.find_one(Setting.guild == str(message.guild.id), Setting.setting == "noinvite")
|
setting = await Setting.find_one(Setting.guild == message.guild.id, Setting.setting == "noinvite")
|
||||||
if not setting:
|
if not setting:
|
||||||
setting = Setting(guild=str(message.guild.id), setting="noinvite", value=False)
|
setting = Setting(guild=message.guild.id, setting="noinvite", value=True)
|
||||||
await setting.save()
|
await setting.save()
|
||||||
if match:
|
if match:
|
||||||
guild_invites = [x.code for x in await message.guild.fetch_invites()]
|
guild_invites = [x.code for x in await message.guild.fetch_invites()]
|
||||||
|
@ -282,12 +288,11 @@ class MessageEventMixin:
|
||||||
|
|
||||||
async def phishing(self, message: Message) -> None:
|
async def phishing(self, message: Message) -> None:
|
||||||
"""Check if the message contains any known phishing domains."""
|
"""Check if the message contains any known phishing domains."""
|
||||||
valid = False
|
|
||||||
for match in url.finditer(message.content):
|
for match in url.finditer(message.content):
|
||||||
if (m := match.group("domain")) in self.phishing_domains:
|
if (m := match.group("domain")) in self.phishing_domains:
|
||||||
pl = await Phishlist.find_one(Phishlist.url == m)
|
pl = await Phishlist.find_one(Phishlist.url == m)
|
||||||
if pl and pl.confirmed and not pl.valid:
|
if pl and pl.confirmed and not pl.valid:
|
||||||
continue
|
return False
|
||||||
self.logger.debug(
|
self.logger.debug(
|
||||||
f"Phishing url `{m}` detected in {message.guild.id}/{message.channel.id}/{message.id}"
|
f"Phishing url `{m}` detected in {message.guild.id}/{message.channel.id}/{message.id}"
|
||||||
)
|
)
|
||||||
|
@ -348,8 +353,8 @@ class MessageEventMixin:
|
||||||
|
|
||||||
await channel.send(embeds=embed, components=components)
|
await channel.send(embeds=embed, components=components)
|
||||||
|
|
||||||
valid = True
|
return True
|
||||||
return valid
|
return False
|
||||||
|
|
||||||
async def malicious_url(self, message: Message) -> None:
|
async def malicious_url(self, message: Message) -> None:
|
||||||
"""Check if the message contains any known phishing domains."""
|
"""Check if the message contains any known phishing domains."""
|
||||||
|
|
|
@ -32,9 +32,9 @@ class SettingsCog(Extension):
|
||||||
|
|
||||||
async def update_settings(self, setting: str, value: Any, guild: int) -> bool:
|
async def update_settings(self, setting: str, value: Any, guild: int) -> bool:
|
||||||
"""Update a guild setting."""
|
"""Update a guild setting."""
|
||||||
existing = await Setting.find_one(Setting.setting == setting, Setting.guild == str(guild))
|
existing = await Setting.find_one(Setting.setting == setting, Setting.guild == guild)
|
||||||
if not existing:
|
if not existing:
|
||||||
existing = Setting(setting=setting, guild=str(guild), value=value)
|
existing = Setting(setting=setting, guild=guild, value=value)
|
||||||
existing.value = value
|
existing.value = value
|
||||||
updated = await existing.save()
|
updated = await existing.save()
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ class SettingsCog(Extension):
|
||||||
|
|
||||||
async def delete_settings(self, setting: str, guild: int) -> bool:
|
async def delete_settings(self, setting: str, guild: int) -> bool:
|
||||||
"""Delete a guild setting."""
|
"""Delete a guild setting."""
|
||||||
existing = await Setting.find_one(Setting.setting == setting, Setting.guild == str(guild))
|
existing = await Setting.find_one(Setting.setting == setting, Setting.guild == guild)
|
||||||
if existing:
|
if existing:
|
||||||
return await existing.delete()
|
return await existing.delete()
|
||||||
return False
|
return False
|
||||||
|
@ -305,7 +305,7 @@ class SettingsCog(Extension):
|
||||||
timeout=60 * 5,
|
timeout=60 * 5,
|
||||||
)
|
)
|
||||||
if context.ctx.custom_id == f"{ctx.guild.id}|set_clear|yes":
|
if context.ctx.custom_id == f"{ctx.guild.id}|set_clear|yes":
|
||||||
async for setting in Setting.find(Setting.guild == str(ctx.guild.id)):
|
async for setting in Setting.find(Setting.guild == ctx.guild.id):
|
||||||
await setting.delete()
|
await setting.delete()
|
||||||
content = "Guild settings cleared"
|
content = "Guild settings cleared"
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -2,10 +2,11 @@
|
||||||
|
|
||||||
from interactions import Client
|
from interactions import Client
|
||||||
|
|
||||||
from jarvis.cogs.unique import ctc2, dbrand
|
from jarvis.cogs.unique import ctc2, dbrand, gl
|
||||||
|
|
||||||
|
|
||||||
def setup(bot: Client) -> None:
|
def setup(bot: Client) -> None:
|
||||||
"""Add guild-specific cogs to JARVIS"""
|
"""Add guild-specific cogs to JARVIS"""
|
||||||
ctc2.setup(bot)
|
ctc2.setup(bot)
|
||||||
dbrand.setup(bot)
|
dbrand.setup(bot)
|
||||||
|
gl.setup(bot)
|
||||||
|
|
445
jarvis/cogs/unique/gl.py
Normal file
445
jarvis/cogs/unique/gl.py
Normal file
|
@ -0,0 +1,445 @@
|
||||||
|
"""JARVIS GitLab Cog."""
|
||||||
|
|
||||||
|
import asyncio
|
||||||
|
import logging
|
||||||
|
from datetime import datetime
|
||||||
|
|
||||||
|
import gitlab
|
||||||
|
from interactions import Client, Extension, InteractionContext
|
||||||
|
from interactions.ext.paginators import Paginator
|
||||||
|
from interactions.models.discord.embed import Embed, EmbedField
|
||||||
|
from interactions.models.discord.modal import InputText, Modal, TextStyles
|
||||||
|
from interactions.models.discord.user import Member
|
||||||
|
from interactions.models.internal.application_commands import (
|
||||||
|
OptionType,
|
||||||
|
SlashCommand,
|
||||||
|
SlashCommandChoice,
|
||||||
|
slash_command,
|
||||||
|
slash_option,
|
||||||
|
)
|
||||||
|
|
||||||
|
from jarvis.config import load_config
|
||||||
|
from jarvis.utils import build_embed
|
||||||
|
|
||||||
|
guild_ids = [862402786116763668]
|
||||||
|
|
||||||
|
|
||||||
|
class GitlabCog(Extension):
|
||||||
|
"""JARVIS GitLab Cog."""
|
||||||
|
|
||||||
|
def __init__(self, bot: Client):
|
||||||
|
self.bot = bot
|
||||||
|
self.logger = logging.getLogger(__name__)
|
||||||
|
config = load_config()
|
||||||
|
self._gitlab = gitlab.Gitlab("https://git.zevaryx.com", private_token=config.gitlab_token)
|
||||||
|
# JARVIS GitLab ID is 29
|
||||||
|
self.project = self._gitlab.projects.get(29)
|
||||||
|
|
||||||
|
gl = SlashCommand(name="gl", description="Get GitLab info", scopes=guild_ids)
|
||||||
|
|
||||||
|
@gl.subcommand(
|
||||||
|
sub_cmd_name="issue",
|
||||||
|
sub_cmd_description="Get an issue from GitLab",
|
||||||
|
)
|
||||||
|
@slash_option(name="id", description="Issue ID", opt_type=OptionType.INTEGER, required=True)
|
||||||
|
async def _issue(self, ctx: InteractionContext, id: int) -> None:
|
||||||
|
try:
|
||||||
|
issue = self.project.issues.get(int(id))
|
||||||
|
except gitlab.exceptions.GitlabGetError:
|
||||||
|
await ctx.send("Issue does not exist.", ephemeral=True)
|
||||||
|
return
|
||||||
|
assignee = issue.assignee
|
||||||
|
if assignee:
|
||||||
|
assignee = assignee["name"]
|
||||||
|
else:
|
||||||
|
assignee = "None"
|
||||||
|
|
||||||
|
created_at = datetime.strptime(issue.created_at, "%Y-%m-%dT%H:%M:%S.%fZ").strftime("%Y-%m-%d %H:%M:%S UTC")
|
||||||
|
|
||||||
|
labels = issue.labels
|
||||||
|
if labels:
|
||||||
|
labels = "\n".join(issue.labels)
|
||||||
|
else:
|
||||||
|
labels = "None"
|
||||||
|
|
||||||
|
fields = [
|
||||||
|
EmbedField(name="State", value=issue.state.title()),
|
||||||
|
EmbedField(name="Assignee", value=assignee),
|
||||||
|
EmbedField(name="Labels", value=labels),
|
||||||
|
]
|
||||||
|
color = "#FC6D27"
|
||||||
|
if issue.labels:
|
||||||
|
color = self.project.labels.get(issue.labels[0]).color
|
||||||
|
fields.append(EmbedField(name="Created At", value=created_at))
|
||||||
|
if issue.state == "closed":
|
||||||
|
closed_at = datetime.strptime(issue.closed_at, "%Y-%m-%dT%H:%M:%S.%fZ").strftime("%Y-%m-%d %H:%M:%S UTC")
|
||||||
|
fields.append(EmbedField(name="Closed At", value=closed_at))
|
||||||
|
if issue.milestone:
|
||||||
|
fields.append(
|
||||||
|
EmbedField(
|
||||||
|
name="Milestone",
|
||||||
|
value=f"[{issue.milestone['title']}]({issue.milestone['web_url']})",
|
||||||
|
inline=False,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
if len(issue.title) > 200:
|
||||||
|
issue.title = issue.title[:200] + "..."
|
||||||
|
embed = build_embed(
|
||||||
|
title=f"[#{issue.iid}] {issue.title}",
|
||||||
|
description=issue.description,
|
||||||
|
fields=fields,
|
||||||
|
color=color,
|
||||||
|
url=issue.web_url,
|
||||||
|
)
|
||||||
|
embed.set_author(
|
||||||
|
name=issue.author["name"],
|
||||||
|
icon_url=issue.author["avatar_url"],
|
||||||
|
url=issue.author["web_url"],
|
||||||
|
)
|
||||||
|
embed.set_thumbnail(url="https://about.gitlab.com/images/press/logo/png/gitlab-icon-rgb.png")
|
||||||
|
await ctx.send(embeds=embed)
|
||||||
|
|
||||||
|
@gl.subcommand(
|
||||||
|
sub_cmd_name="milestone",
|
||||||
|
sub_cmd_description="Get a milestone from GitLab",
|
||||||
|
)
|
||||||
|
@slash_option(name="id", description="Milestone ID", opt_type=OptionType.INTEGER, required=True)
|
||||||
|
async def _milestone(self, ctx: InteractionContext, id: int) -> None:
|
||||||
|
try:
|
||||||
|
milestone = self.project.milestones.get(int(id))
|
||||||
|
except gitlab.exceptions.GitlabGetError:
|
||||||
|
await ctx.send("Milestone does not exist.", ephemeral=True)
|
||||||
|
return
|
||||||
|
|
||||||
|
created_at = datetime.strptime(milestone.created_at, "%Y-%m-%dT%H:%M:%S.%fZ").strftime("%Y-%m-%d %H:%M:%S UTC")
|
||||||
|
|
||||||
|
fields = [
|
||||||
|
EmbedField(
|
||||||
|
name="State",
|
||||||
|
value=milestone.state[0].upper() + milestone.state[1:],
|
||||||
|
),
|
||||||
|
EmbedField(name="Start Date", value=milestone.start_date),
|
||||||
|
EmbedField(name="Due Date", value=milestone.due_date),
|
||||||
|
EmbedField(name="Created At", value=created_at),
|
||||||
|
]
|
||||||
|
|
||||||
|
if milestone.updated_at:
|
||||||
|
updated_at = datetime.strptime(milestone.updated_at, "%Y-%m-%dT%H:%M:%S.%fZ").strftime(
|
||||||
|
"%Y-%m-%d %H:%M:%S UTC"
|
||||||
|
)
|
||||||
|
fields.append(EmbedField(name="Updated At", value=updated_at))
|
||||||
|
|
||||||
|
if len(milestone.title) > 200:
|
||||||
|
milestone.title = milestone.title[:200] + "..."
|
||||||
|
|
||||||
|
embed = build_embed(
|
||||||
|
title=f"[#{milestone.iid}] {milestone.title}",
|
||||||
|
description=milestone.description,
|
||||||
|
fields=fields,
|
||||||
|
color="#00FFEE",
|
||||||
|
url=milestone.web_url,
|
||||||
|
)
|
||||||
|
embed.set_author(
|
||||||
|
name="JARVIS",
|
||||||
|
url="https://git.zevaryx.com/jarvis",
|
||||||
|
icon_url="https://git.zevaryx.com/uploads/-/system/user/avatar/11/avatar.png",
|
||||||
|
)
|
||||||
|
embed.set_thumbnail(url="https://about.gitlab.com/images/press/logo/png/gitlab-icon-rgb.png")
|
||||||
|
await ctx.send(embeds=embed)
|
||||||
|
|
||||||
|
@gl.subcommand(
|
||||||
|
sub_cmd_name="mr",
|
||||||
|
sub_cmd_description="Get a merge request from GitLab",
|
||||||
|
)
|
||||||
|
@slash_option(name="id", description="Merge Request ID", opt_type=OptionType.INTEGER, required=True)
|
||||||
|
async def _mergerequest(self, ctx: InteractionContext, id: int) -> None:
|
||||||
|
try:
|
||||||
|
mr = self.project.mergerequests.get(int(id))
|
||||||
|
except gitlab.exceptions.GitlabGetError:
|
||||||
|
await ctx.send("Merge request does not exist.", ephemeral=True)
|
||||||
|
return
|
||||||
|
assignee = mr.assignee
|
||||||
|
if assignee:
|
||||||
|
assignee = assignee["name"]
|
||||||
|
else:
|
||||||
|
assignee = "None"
|
||||||
|
|
||||||
|
created_at = datetime.strptime(mr.created_at, "%Y-%m-%dT%H:%M:%S.%fZ").strftime("%Y-%m-%d %H:%M:%S UTC")
|
||||||
|
|
||||||
|
labels = mr.labels
|
||||||
|
if labels:
|
||||||
|
labels = "\n".join(mr.labels)
|
||||||
|
if not labels:
|
||||||
|
labels = "None"
|
||||||
|
|
||||||
|
fields = [
|
||||||
|
EmbedField(name="State", value=mr.state[0].upper() + mr.state[1:], inline=True),
|
||||||
|
EmbedField(name="Draft?", value=str(mr.draft), inline=True),
|
||||||
|
EmbedField(name="Assignee", value=assignee, inline=True),
|
||||||
|
EmbedField(name="Labels", value=labels, inline=True),
|
||||||
|
]
|
||||||
|
if mr.labels:
|
||||||
|
color = self.project.labels.get(mr.labels[0]).color
|
||||||
|
else:
|
||||||
|
color = "#00FFEE"
|
||||||
|
fields.append(EmbedField(name="Created At", value=created_at, inline=True))
|
||||||
|
if mr.state == "merged":
|
||||||
|
merged_at = datetime.strptime(mr.merged_at, "%Y-%m-%dT%H:%M:%S.%fZ").strftime("%Y-%m-%d %H:%M:%S UTC")
|
||||||
|
fields.append(EmbedField(name="Merged At", value=merged_at, inline=True))
|
||||||
|
elif mr.state == "closed":
|
||||||
|
closed_at = datetime.strptime(mr.closed_at, "%Y-%m-%dT%H:%M:%S.%fZ").strftime("%Y-%m-%d %H:%M:%S UTC")
|
||||||
|
fields.append(EmbedField(name="Closed At", value=closed_at, inline=True))
|
||||||
|
if mr.milestone:
|
||||||
|
fields.append(
|
||||||
|
EmbedField(
|
||||||
|
name="Milestone",
|
||||||
|
value=f"[{mr.milestone['title']}]({mr.milestone['web_url']})",
|
||||||
|
inline=False,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
if len(mr.title) > 200:
|
||||||
|
mr.title = mr.title[:200] + "..."
|
||||||
|
embed = build_embed(
|
||||||
|
title=f"[#{mr.iid}] {mr.title}",
|
||||||
|
description=mr.description,
|
||||||
|
fields=fields,
|
||||||
|
color=color,
|
||||||
|
url=mr.web_url,
|
||||||
|
)
|
||||||
|
embed.set_author(
|
||||||
|
name=mr.author["name"],
|
||||||
|
icon_url=mr.author["avatar_url"],
|
||||||
|
url=mr.author["web_url"],
|
||||||
|
)
|
||||||
|
embed.set_thumbnail(url="https://about.gitlab.com/images/press/logo/png/gitlab-icon-rgb.png")
|
||||||
|
await ctx.send(embeds=embed)
|
||||||
|
|
||||||
|
def build_embed_page(self, api_list: list, t_state: str, name: str) -> Embed:
|
||||||
|
"""Build an embed page for the paginator."""
|
||||||
|
title = ""
|
||||||
|
if t_state:
|
||||||
|
title = f"{t_state} "
|
||||||
|
title += f"JARVIS {name}s"
|
||||||
|
fields = []
|
||||||
|
for item in api_list:
|
||||||
|
description = item.description or "No description"
|
||||||
|
fields.append(
|
||||||
|
EmbedField(
|
||||||
|
name=f"[#{item.iid}] {item.title}",
|
||||||
|
value=(description[:200] + f"...\n\n[View this {name}]({item.web_url})"),
|
||||||
|
inline=False,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
embed = build_embed(
|
||||||
|
title=title,
|
||||||
|
description="",
|
||||||
|
fields=fields,
|
||||||
|
url=f"https://git.zevaryx.com/stark-industries/JARVIS/{name.replace(' ', '_')}s",
|
||||||
|
)
|
||||||
|
embed.set_author(
|
||||||
|
name="JARVIS",
|
||||||
|
url="https://git.zevaryx.com/jarvis",
|
||||||
|
icon_url="https://git.zevaryx.com/uploads/-/system/user/avatar/11/avatar.png",
|
||||||
|
)
|
||||||
|
embed.set_thumbnail(url="https://about.gitlab.com/images/press/logo/png/gitlab-icon-rgb.png")
|
||||||
|
return embed
|
||||||
|
|
||||||
|
@gl.subcommand(
|
||||||
|
sub_cmd_name="issues",
|
||||||
|
sub_cmd_description="Get issues from GitLab",
|
||||||
|
)
|
||||||
|
@slash_option(
|
||||||
|
name="state",
|
||||||
|
description="State of issues to get",
|
||||||
|
opt_type=OptionType.STRING,
|
||||||
|
required=False,
|
||||||
|
choices=[
|
||||||
|
SlashCommandChoice(name="Open", value="opened"),
|
||||||
|
SlashCommandChoice(name="Closed", value="closed"),
|
||||||
|
SlashCommandChoice(name="All", value="all"),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
async def _issues(self, ctx: InteractionContext, state: str = "opened") -> None:
|
||||||
|
await ctx.defer()
|
||||||
|
m_state = state
|
||||||
|
if m_state == "all":
|
||||||
|
m_state = None
|
||||||
|
issues = []
|
||||||
|
page = 1
|
||||||
|
try:
|
||||||
|
while curr_page := self.project.issues.list(
|
||||||
|
page=page,
|
||||||
|
state=m_state,
|
||||||
|
order_by="created_at",
|
||||||
|
sort="desc",
|
||||||
|
per_page=100,
|
||||||
|
):
|
||||||
|
issues += curr_page
|
||||||
|
page += 1
|
||||||
|
except gitlab.exceptions.GitlabGetError:
|
||||||
|
# Only send error on first page. Otherwise, use pages retrieved
|
||||||
|
if page == 1:
|
||||||
|
await ctx.send("Unable to get issues")
|
||||||
|
return
|
||||||
|
|
||||||
|
if len(issues) == 0:
|
||||||
|
await ctx.send("No issues match that criteria")
|
||||||
|
return
|
||||||
|
|
||||||
|
t_state = state
|
||||||
|
if t_state == "opened":
|
||||||
|
t_state = "open"
|
||||||
|
pages = []
|
||||||
|
t_state = t_state[0].upper() + t_state[1:]
|
||||||
|
for i in range(0, len(issues), 5):
|
||||||
|
pages.append(self.build_embed_page(issues[i : i + 5], t_state=t_state, name="issue"))
|
||||||
|
|
||||||
|
paginator = Paginator.create_from_embeds(self.bot, *pages, timeout=300)
|
||||||
|
|
||||||
|
await paginator.send(ctx)
|
||||||
|
|
||||||
|
@gl.subcommand(
|
||||||
|
sub_cmd_name="mrs",
|
||||||
|
sub_cmd_description="Get merge requests from GitLab",
|
||||||
|
)
|
||||||
|
@slash_option(
|
||||||
|
name="state",
|
||||||
|
description="State of merge requests to get",
|
||||||
|
opt_type=OptionType.STRING,
|
||||||
|
required=False,
|
||||||
|
choices=[
|
||||||
|
SlashCommandChoice(name="Open", value="opened"),
|
||||||
|
SlashCommandChoice(name="Closed", value="closed"),
|
||||||
|
SlashCommandChoice(name="All", value="all"),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
async def _mergerequests(self, ctx: InteractionContext, state: str = "opened") -> None:
|
||||||
|
await ctx.defer()
|
||||||
|
m_state = state
|
||||||
|
if m_state == "all":
|
||||||
|
m_state = None
|
||||||
|
merges = []
|
||||||
|
page = 1
|
||||||
|
try:
|
||||||
|
while curr_page := self.project.mergerequests.list(
|
||||||
|
page=page,
|
||||||
|
state=m_state,
|
||||||
|
order_by="created_at",
|
||||||
|
sort="desc",
|
||||||
|
per_page=100,
|
||||||
|
):
|
||||||
|
merges += curr_page
|
||||||
|
page += 1
|
||||||
|
except gitlab.exceptions.GitlabGetError:
|
||||||
|
# Only send error on first page. Otherwise, use pages retrieved
|
||||||
|
if page == 1:
|
||||||
|
await ctx.send("Unable to get merge requests")
|
||||||
|
return
|
||||||
|
|
||||||
|
if len(merges) == 0:
|
||||||
|
await ctx.send("No merge requests match that criteria")
|
||||||
|
return
|
||||||
|
|
||||||
|
t_state = state
|
||||||
|
if t_state == "opened":
|
||||||
|
t_state = "open"
|
||||||
|
pages = []
|
||||||
|
t_state = t_state[0].upper() + t_state[1:]
|
||||||
|
for i in range(0, len(merges), 5):
|
||||||
|
pages.append(self.build_embed_page(merges[i : i + 5], t_state=t_state, name="merge request"))
|
||||||
|
|
||||||
|
paginator = Paginator.create_from_embeds(self.bot, *pages, timeout=300)
|
||||||
|
|
||||||
|
await paginator.send(ctx)
|
||||||
|
|
||||||
|
@gl.subcommand(
|
||||||
|
sub_cmd_name="milestones",
|
||||||
|
sub_cmd_description="Get milestones from GitLab",
|
||||||
|
)
|
||||||
|
async def _milestones(self, ctx: InteractionContext) -> None:
|
||||||
|
await ctx.defer()
|
||||||
|
milestones = []
|
||||||
|
page = 1
|
||||||
|
try:
|
||||||
|
while curr_page := self.project.milestones.list(
|
||||||
|
page=page,
|
||||||
|
order_by="created_at",
|
||||||
|
sort="desc",
|
||||||
|
per_page=100,
|
||||||
|
):
|
||||||
|
milestones += curr_page
|
||||||
|
page += 1
|
||||||
|
except gitlab.exceptions.GitlabGetError:
|
||||||
|
# Only send error on first page. Otherwise, use pages retrieved
|
||||||
|
if page == 1:
|
||||||
|
await ctx.send("Unable to get milestones")
|
||||||
|
return
|
||||||
|
|
||||||
|
if len(milestones) == 0:
|
||||||
|
await ctx.send("No milestones exist")
|
||||||
|
return
|
||||||
|
|
||||||
|
pages = []
|
||||||
|
for i in range(0, len(milestones), 5):
|
||||||
|
pages.append(self.build_embed_page(milestones[i : i + 5], t_state=None, name="milestone"))
|
||||||
|
|
||||||
|
paginator = Paginator.create_from_embeds(self.bot, *pages, timeout=300)
|
||||||
|
|
||||||
|
await paginator.send(ctx)
|
||||||
|
|
||||||
|
@slash_command(name="issue", description="Report an issue on GitLab", scopes=guild_ids)
|
||||||
|
@slash_option(
|
||||||
|
name="user",
|
||||||
|
description="Credit someone else for this issue",
|
||||||
|
opt_type=OptionType.USER,
|
||||||
|
required=False,
|
||||||
|
)
|
||||||
|
async def _open_issue(self, ctx: InteractionContext, user: Member = None) -> None:
|
||||||
|
user = user or ctx.author
|
||||||
|
modal = Modal(
|
||||||
|
title="Open a new issue on GitLab",
|
||||||
|
components=[
|
||||||
|
InputText(
|
||||||
|
label="Issue Title",
|
||||||
|
placeholder="Descriptive Title",
|
||||||
|
style=TextStyles.SHORT,
|
||||||
|
custom_id="title",
|
||||||
|
max_length=200,
|
||||||
|
),
|
||||||
|
InputText(
|
||||||
|
label="Description (supports Markdown!)",
|
||||||
|
placeholder="Detailed Description",
|
||||||
|
style=TextStyles.PARAGRAPH,
|
||||||
|
custom_id="description",
|
||||||
|
),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
await ctx.send_modal(modal)
|
||||||
|
try:
|
||||||
|
resp = await self.bot.wait_for_modal(modal, author=ctx.author.id, timeout=60 * 5)
|
||||||
|
title = resp.responses.get("title")
|
||||||
|
desc = resp.responses.get("description")
|
||||||
|
except asyncio.TimeoutError:
|
||||||
|
return
|
||||||
|
if not title.startswith("[Discord]"):
|
||||||
|
title = "[Discord] " + title
|
||||||
|
desc = f"Opened by `@{user.username}` on Discord\n\n" + desc
|
||||||
|
issue = self.project.issues.create(data={"title": title, "description": desc})
|
||||||
|
embed = build_embed(
|
||||||
|
title=f"Issue #{issue.id} Created",
|
||||||
|
description=("Thank you for opening an issue!\n\n[View it online]({issue['web_url']})"),
|
||||||
|
fields=[],
|
||||||
|
color="#00FFEE",
|
||||||
|
)
|
||||||
|
await resp.send(embeds=embed)
|
||||||
|
|
||||||
|
|
||||||
|
def setup(bot: Client) -> None:
|
||||||
|
"""Add GitlabCog to JARVIS if Gitlab token exists."""
|
||||||
|
bot.logger.warn("GitlabCog is deprecated")
|
||||||
|
return
|
||||||
|
if load_config().gitlab_token:
|
||||||
|
GitlabCog(bot)
|
||||||
|
else:
|
||||||
|
bot.logger.info("Missing GitLab token, ignoring GitLab cog")
|
|
@ -1,3 +1,3 @@
|
||||||
"""JARVIS constants."""
|
"""JARVIS constants."""
|
||||||
|
|
||||||
__version__ = "2.5.5"
|
__version__ = "2.5.4"
|
||||||
|
|
2575
poetry.lock
generated
2575
poetry.lock
generated
File diff suppressed because it is too large
Load diff
|
@ -1,43 +1,43 @@
|
||||||
[tool.poetry]
|
[tool.poetry]
|
||||||
name = "jarvis"
|
name = "jarvis"
|
||||||
version = "2.5.5"
|
version = "2.5.4"
|
||||||
description = "JARVIS admin bot"
|
description = "JARVIS admin bot"
|
||||||
authors = ["Zevaryx <zevaryx@gmail.com>"]
|
authors = ["Zevaryx <zevaryx@gmail.com>"]
|
||||||
|
|
||||||
[tool.poetry.dependencies]
|
[tool.poetry.dependencies]
|
||||||
python = ">=3.11,<4"
|
python = ">=3.11,<4"
|
||||||
opencv-python = "^4.9.0.80"
|
opencv-python = "^4.5.5"
|
||||||
Pillow = "^10.3.0"
|
Pillow = "^9.0.0"
|
||||||
psutil = "^5.9.8"
|
psutil = "^5.9.0"
|
||||||
ulid-py = "^1.1.0"
|
ulid-py = "^1.1.0"
|
||||||
jarvis-core = { git = "https://git.zevs.me/stark-industries/jarvis/jarvis-core.git", rev = "main" } # Mine
|
jarvis-core = { git = "https://git.zevaryx.com/stark-industries/jarvis/jarvis-core.git", rev = "main" } # Mine
|
||||||
aiohttp = ">=3.9.0b0"
|
aiohttp = ">=3.9.0b0"
|
||||||
pastypy = "^1.0.3.post1" # Mine
|
pastypy = "^1.0.3.post1" # Mine
|
||||||
dateparser = "^1.2.0"
|
dateparser = "^1.1.1"
|
||||||
aiofile = "^3.8.8"
|
aiofile = "^3.8.1"
|
||||||
rich = "^13.7.1"
|
rich = "^12.3.0"
|
||||||
jurigged = "^0.5.7" # Contributed
|
jurigged = "^0.5.3" # Contributed
|
||||||
ansitoimg = "^2024.2"
|
ansitoimg = "^2022.1"
|
||||||
nest-asyncio = "^1.6.0"
|
nest-asyncio = "^1.5.5"
|
||||||
thefuzz = { extras = [
|
thefuzz = { extras = [
|
||||||
"speedup",
|
"speedup",
|
||||||
], git = "https://github.com/zevaryx/thefuzz.git", rev = "master" } # Forked
|
], git = "https://github.com/zevaryx/thefuzz.git", rev = "master" } # Forked
|
||||||
beautifulsoup4 = "^4.12.3"
|
beautifulsoup4 = "^4.11.1"
|
||||||
calculator = { git = "https://github.com/zevaryx/calculator.git" } # Mine
|
calculator = { git = "https://git.zevaryx.com/zevaryx/calculator.git" } # Mine
|
||||||
redis = "^5.0.4"
|
redis = "^4.4.0"
|
||||||
interactions-py = ">=5.13,<6"
|
interactions-py = ">=5.3,<6"
|
||||||
statipy = { git = "https://github.com/zevaryx/statipy", rev = "main" }
|
statipy = { git = "https://github.com/zevaryx/statipy", rev = "main" }
|
||||||
beanie = "^1.25.0"
|
beanie = "^1.17.0"
|
||||||
pydantic = ">=2.7.1,<3"
|
pydantic = ">=2.3.0,<3"
|
||||||
orjson = "^3.10.1"
|
orjson = "^3.8.8"
|
||||||
croniter = "^2.0.5"
|
croniter = "^1.4.1"
|
||||||
erapi = { git = "https://git.zevs.me/zevaryx-technologies/erapi.git" }
|
erapi = { git = "https://git.zevaryx.com/zevaryx-technologies/erapi.git" }
|
||||||
pydantic-settings = "^2.2.1"
|
pydantic-settings = "^2.2.1"
|
||||||
|
|
||||||
[tool.poetry.group.dev.dependencies]
|
[tool.poetry.group.dev.dependencies]
|
||||||
pre-commit = "^3.7.0"
|
pre-commit = "^3.6.2"
|
||||||
pandas = "^2.2.2"
|
pandas = "^1.5.3"
|
||||||
black = "^24.4.2"
|
black = "^23.1.0"
|
||||||
|
|
||||||
[build-system]
|
[build-system]
|
||||||
requires = ["poetry-core>=1.0.0"]
|
requires = ["poetry-core>=1.0.0"]
|
||||||
|
|
Loading…
Add table
Reference in a new issue