mirror of
https://github.com/xHyroM/bun-discord-bot.git
synced 2024-11-14 02:48:07 +01:00
tags
This commit is contained in:
parent
1e6fc5f73b
commit
fc6c3a6be6
5 changed files with 242 additions and 177 deletions
5
.prettierrc
Normal file
5
.prettierrc
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
{
|
||||||
|
"tabWidth": 4,
|
||||||
|
"singleQuote": true,
|
||||||
|
"trailingComma": "es5"
|
||||||
|
}
|
|
@ -1,10 +1,7 @@
|
||||||
[bun]
|
[bun]
|
||||||
keywords = ["bun", "bun.sh"]
|
keywords = ["bun", "bun.sh"]
|
||||||
content = """
|
content = """
|
||||||
Bun is a modern JavaScript runtime like Node or Deno. It was built from scratch to focus on three main things:
|
Bun is an all-in-one JavaScript runtime & toolkit designed for speed, complete with a bundler, test runner, and Node.js-compatible package manager.
|
||||||
• Start fast (it has the edge in mind).
|
|
||||||
• New levels of performance (extending JavaScriptCore, the engine).
|
|
||||||
• Being a great and complete tool (bundler, transpiler, package manager).
|
|
||||||
|
|
||||||
Read more [here](<https://bun.sh/>)
|
Read more [here](<https://bun.sh/>)
|
||||||
"""
|
"""
|
||||||
|
@ -13,42 +10,24 @@ Read more [here](<https://bun.sh/>)
|
||||||
keywords = ["bug", "report", "bugs"]
|
keywords = ["bug", "report", "bugs"]
|
||||||
content = """
|
content = """
|
||||||
Found a bug in bun?
|
Found a bug in bun?
|
||||||
• If you are unsure, first discuss your bug in <#887787428973281300> or <#995247410794217553>
|
- If you are unsure, first discuss your bug in <#887787428973281300> or <#995247410794217553>
|
||||||
• [Open an issue on GitHub](<https://github.com/oven-sh/bun/issues/new?template=1-bug-report.yml>) and fill out the given template
|
- [Open an issue on GitHub](<https://github.com/oven-sh/bun/issues/new?template=1-bug-report.yml>) and fill out the given template
|
||||||
"""
|
"""
|
||||||
|
|
||||||
[feature-request]
|
[feature-request]
|
||||||
keywords = ["feature-request", "feature", "request"]
|
keywords = ["feature-request", "feature", "request"]
|
||||||
content = """
|
content = """
|
||||||
Any idea what to add to bun?
|
Any idea what to add to bun?
|
||||||
• Please consider if this is a request for bun, not for other 3rd party packages
|
- Please consider if this is a request for bun, not for other 3rd party packages
|
||||||
• [Open an issue on GitHub](<https://github.com/oven-sh/bun/issues/new?template=2-feature-request.yml>) and fill out the given template
|
- [Open an issue on GitHub](<https://github.com/oven-sh/bun/issues/new?template=2-feature-request.yml>) and fill out the given template
|
||||||
"""
|
"""
|
||||||
|
|
||||||
[contributing-tags]
|
[tags]
|
||||||
keywords = ["contributing-tags", "contributing", "tags"]
|
keywords = ["contributing-tags", "contributing", "tags"]
|
||||||
content = """
|
content = """
|
||||||
To create or update tag, check [xHyroM/bun-discord-bot#contributing-tags](<https://github.com/xHyroM/bun-discord-bot/#contributing-tags>)
|
To create or update tag, check [xHyroM/bun-discord-bot#contributing-tags](<https://github.com/xHyroM/bun-discord-bot/#contributing-tags>)
|
||||||
"""
|
"""
|
||||||
|
|
||||||
[hono]
|
|
||||||
keywords = ["hono", "express", "server", "routes"]
|
|
||||||
content = """
|
|
||||||
**Hono - [炎] means flame🔥 in Japanese**
|
|
||||||
• Is a small, simple, and ultrafast web framework for Cloudflare Workers, Deno, Bun, and others
|
|
||||||
|
|
||||||
[Bun supports partially express, but you can also use hono.](<https://github.com/honojs/hono#bun>)
|
|
||||||
"""
|
|
||||||
|
|
||||||
[not-same-file-system]
|
|
||||||
keywords = ["not-same-file-system", "backend copyfile", "copyfile"]
|
|
||||||
content = """
|
|
||||||
**error: NotSameFileSystem installing [package]**
|
|
||||||
|
|
||||||
You have old bun. Use `bun upgrade` to upgrade.
|
|
||||||
If you have problems with upgrade, reinstall bun using `curl https://bun.sh/install | bash`
|
|
||||||
"""
|
|
||||||
|
|
||||||
[windows]
|
[windows]
|
||||||
keywords = ["windows", "windows support"]
|
keywords = ["windows", "windows support"]
|
||||||
content = """
|
content = """
|
||||||
|
@ -65,11 +44,11 @@ To fix this error, you need to update Linux kernel.
|
||||||
If you are using the Windows Subsystem for Linux, do:
|
If you are using the Windows Subsystem for Linux, do:
|
||||||
**1.** Open powershell as administrator
|
**1.** Open powershell as administrator
|
||||||
**2.** Run:
|
**2.** Run:
|
||||||
• wsl --set-version <disto name> 2
|
- wsl --set-version <disto name> 2
|
||||||
• If it throws `Please enable the Virtual Machine Platform Windows feature and ensure virtualization is enabled in the BIOS.`, turn on Virtual Machine Platform in Windows Features and then rerun this command.
|
- If it throws `Please enable the Virtual Machine Platform Windows feature and ensure virtualization is enabled in the BIOS.`, turn on Virtual Machine Platform in Windows Features and then rerun this command.
|
||||||
• PS: You can get distro name from `wsl --list -v`
|
- PS: You can get distro name from `wsl --list -v`
|
||||||
• wsl --update
|
- wsl --update
|
||||||
• wsl --shutdown
|
- wsl --shutdown
|
||||||
|
|
||||||
If that doesn't work (and you're on a Windows machine), try this:
|
If that doesn't work (and you're on a Windows machine), try this:
|
||||||
**1.** Open Windows Update
|
**1.** Open Windows Update
|
||||||
|
@ -89,10 +68,23 @@ curl https://bun.sh/install | bash
|
||||||
or install latest *-baseline build from [GitHub Releases](<https://github.com/oven-sh/bun/releases>)
|
or install latest *-baseline build from [GitHub Releases](<https://github.com/oven-sh/bun/releases>)
|
||||||
"""
|
"""
|
||||||
|
|
||||||
[why-zig]
|
# common questions
|
||||||
keywords = ["why-zig", "zig", "zig-lang", "zig lang bun"]
|
|
||||||
content = """
|
|
||||||
[**Zig**](<https://ziglang.org/>) is a general-purpose programming language and toolchain for maintaining **robust**, **optimal** and **reusable** software.
|
|
||||||
|
|
||||||
Its **low-level control over memory** and **lack of hidden control flow**, whilst retaining **simplicity** and **flexibility**, makes building _fast_ software (in development time as well) relatively easier.
|
[ts] # 'how do i use typescript or jsx?'
|
||||||
|
keywords = ["typescript", "tsc"]
|
||||||
|
content = """
|
||||||
|
Bun supports TypeScript and JSX out of the box. They can be run directly with [`bun run`](https://bun.sh/docs/cli/run).
|
||||||
|
For setting up IDE support, [documentation page on TypeScript](https://bun.sh/docs/runtime/typescript)
|
||||||
|
"""
|
||||||
|
|
||||||
|
[nix] # 'it doesnt work on nixos'
|
||||||
|
keywords = ["nix", "nixos"]
|
||||||
|
content = """
|
||||||
|
To use Bun on NixOS, you must install it through the nix package manager using [the `bun` package in nixpkgs](https://search.nixos.org/packages?channel=unstable&show=bun&from=0&size=1&sort=relevance&type=packages&query=bun):
|
||||||
|
|
||||||
|
+++
|
||||||
|
nix-env -iA nixos.bun
|
||||||
|
+++
|
||||||
|
|
||||||
|
Using `bun upgrade` or the curl installer will not work because NixOS does not provide `ld.so` which means any non-nixos linux executables will not work (you'll see "File not found" when trying to run them, even though the binary is there).
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -1,8 +1,5 @@
|
||||||
[github]
|
[github]
|
||||||
repositories = [
|
repositories = [
|
||||||
"oven-sh/bun",
|
"oven-sh/bun",
|
||||||
"oven-sh/docs",
|
|
||||||
"oven-sh/bun-dependencies",
|
|
||||||
"oven-sh/bun-types",
|
|
||||||
"xHyroM/bun-discord-bot"
|
"xHyroM/bun-discord-bot"
|
||||||
]
|
]
|
||||||
|
|
|
@ -1,9 +1,14 @@
|
||||||
import { APIApplicationCommandInteractionDataStringOption, ApplicationCommandOptionType, InteractionResponseType, MessageFlags } from 'discord-api-types/v10';
|
import {
|
||||||
|
APIApplicationCommandInteractionDataStringOption,
|
||||||
|
ApplicationCommandOptionType,
|
||||||
|
InteractionResponseType,
|
||||||
|
MessageFlags,
|
||||||
|
} from 'discord-api-types/v10';
|
||||||
import { Command } from '../structures/Command';
|
import { Command } from '../structures/Command';
|
||||||
import { findTags, getTag } from '../utils/tagsUtils';
|
import { findTags, getTag } from '../utils/tagsUtils';
|
||||||
|
|
||||||
new Command({
|
new Command({
|
||||||
name: 'tags',
|
name: 'tag',
|
||||||
description: 'Send a tag by name or alias',
|
description: 'Send a tag by name or alias',
|
||||||
options: [
|
options: [
|
||||||
{
|
{
|
||||||
|
@ -13,18 +18,21 @@ new Command({
|
||||||
required: true,
|
required: true,
|
||||||
run: (ctx) => {
|
run: (ctx) => {
|
||||||
return ctx.respond(findTags(ctx.value));
|
return ctx.respond(findTags(ctx.value));
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'target',
|
name: 'target',
|
||||||
description: 'User to mention',
|
description: 'User to mention',
|
||||||
type: ApplicationCommandOptionType.User,
|
type: ApplicationCommandOptionType.User,
|
||||||
required: false
|
required: false,
|
||||||
}
|
},
|
||||||
],
|
],
|
||||||
run: (ctx) => {
|
run: (ctx) => {
|
||||||
const query: APIApplicationCommandInteractionDataStringOption = ctx.options[0] as APIApplicationCommandInteractionDataStringOption;
|
const query: APIApplicationCommandInteractionDataStringOption = ctx
|
||||||
const target = ctx?.resolved?.users ? Object.values(ctx?.resolved?.users)[0] : null;
|
.options[0] as APIApplicationCommandInteractionDataStringOption;
|
||||||
|
const target = ctx?.resolved?.users
|
||||||
|
? Object.values(ctx?.resolved?.users)[0]
|
||||||
|
: null;
|
||||||
|
|
||||||
const tag = getTag(query.value, false);
|
const tag = getTag(query.value, false);
|
||||||
if (!tag)
|
if (!tag)
|
||||||
|
@ -32,13 +40,15 @@ new Command({
|
||||||
type: InteractionResponseType.ChannelMessageWithSource,
|
type: InteractionResponseType.ChannelMessageWithSource,
|
||||||
data: {
|
data: {
|
||||||
content: `\`❌\` Could not find a tag \`${query.value}\``,
|
content: `\`❌\` Could not find a tag \`${query.value}\``,
|
||||||
flags: MessageFlags.Ephemeral
|
flags: MessageFlags.Ephemeral,
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
return ctx.respond([
|
return ctx.respond(
|
||||||
|
[
|
||||||
target ? `*Tag suggestion for <@${target.id}>:*` : '',
|
target ? `*Tag suggestion for <@${target.id}>:*` : '',
|
||||||
tag.content
|
tag.content,
|
||||||
].join('\n'));
|
].join('\n')
|
||||||
}
|
);
|
||||||
})
|
},
|
||||||
|
});
|
147
src/index.ts
147
src/index.ts
|
@ -6,18 +6,33 @@ import { Logger } from './utils/Logger';
|
||||||
import config from '../files/config.toml';
|
import config from '../files/config.toml';
|
||||||
import loadCommands from './utils/loadCommands';
|
import loadCommands from './utils/loadCommands';
|
||||||
import { verifyGithubKey, verifyKey } from './utils/verify';
|
import { verifyGithubKey, verifyKey } from './utils/verify';
|
||||||
import { APIPingInteraction, APIApplicationCommandInteraction, APIMessageComponentInteraction, InteractionType, InteractionResponseType, ApplicationCommandType, APIApplicationCommandAutocompleteInteraction, ApplicationCommandOptionType } from 'discord-api-types/v10';
|
import {
|
||||||
|
APIPingInteraction,
|
||||||
|
APIApplicationCommandInteraction,
|
||||||
|
APIMessageComponentInteraction,
|
||||||
|
InteractionType,
|
||||||
|
InteractionResponseType,
|
||||||
|
ApplicationCommandType,
|
||||||
|
APIApplicationCommandAutocompleteInteraction,
|
||||||
|
ApplicationCommandOptionType,
|
||||||
|
} from 'discord-api-types/v10';
|
||||||
import { CommandContext } from './structures/contexts/CommandContext';
|
import { CommandContext } from './structures/contexts/CommandContext';
|
||||||
import { Commands } from './managers/CommandManager';
|
import { Commands } from './managers/CommandManager';
|
||||||
import registerCommands from './utils/registerCommands';
|
import registerCommands from './utils/registerCommands';
|
||||||
import { Option, OptionOptions } from './structures/Option';
|
import { Option, OptionOptions } from './structures/Option';
|
||||||
import { AutocompleteContext } from './structures/contexts/AutocompleteContext';
|
import { AutocompleteContext } from './structures/contexts/AutocompleteContext';
|
||||||
import { deleteIssueOrPR, fetchIssues, fetchPullRequests, setIssue, setPullRequest } from './utils/githubUtils';
|
import {
|
||||||
|
deleteIssueOrPR,
|
||||||
|
fetchIssues,
|
||||||
|
fetchPullRequests,
|
||||||
|
setIssue,
|
||||||
|
setPullRequest,
|
||||||
|
} from './utils/githubUtils';
|
||||||
import { removeExclamationFromNicknames } from './utils/discord';
|
import { removeExclamationFromNicknames } from './utils/discord';
|
||||||
|
|
||||||
await fetchIssues();
|
await fetchIssues();
|
||||||
await fetchPullRequests();
|
await fetchPullRequests();
|
||||||
(async() => {
|
(async () => {
|
||||||
Logger.info('Removing exclamation marks from nicknames...');
|
Logger.info('Removing exclamation marks from nicknames...');
|
||||||
await removeExclamationFromNicknames(config.client.token);
|
await removeExclamationFromNicknames(config.client.token);
|
||||||
Logger.info('Removing is done!');
|
Logger.info('Removing is done!');
|
||||||
|
@ -25,73 +40,105 @@ await fetchPullRequests();
|
||||||
await loadCommands();
|
await loadCommands();
|
||||||
try {
|
try {
|
||||||
await registerCommands(config.client.token, config.client.id);
|
await registerCommands(config.client.token, config.client.id);
|
||||||
} catch(e) {
|
} catch (e) {
|
||||||
console.log(e);
|
console.log(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
const app = new Hono();
|
const app = new Hono();
|
||||||
app.get('*', (c) => c.redirect('https://www.youtube.com/watch?v=FMhScnY0dME')); // fireship :D
|
app.get('*', (c) => c.redirect('https://www.youtube.com/watch?v=FMhScnY0dME')); // fireship :D
|
||||||
|
|
||||||
app.post('/interaction', bodyParse(), async(c) => {
|
app.post('/interaction', bodyParse(), async (c) => {
|
||||||
const signature = c.req.headers.get('X-Signature-Ed25519');
|
const signature = c.req.headers.get('X-Signature-Ed25519');
|
||||||
const timestamp = c.req.headers.get('X-Signature-Timestamp');
|
const timestamp = c.req.headers.get('X-Signature-Timestamp');
|
||||||
if (!signature || !timestamp) return c.redirect('https://www.youtube.com/watch?v=FMhScnY0dME'); // fireship :D
|
if (!signature || !timestamp)
|
||||||
if (!await verifyKey(JSON.stringify(c.req.parsedBody), signature, timestamp, config.client.public_key)) return c.redirect('https://www.youtube.com/watch?v=FMhScnY0dME'); // fireship :D
|
return c.redirect('https://www.youtube.com/watch?v=FMhScnY0dME'); // fireship :D
|
||||||
|
if (
|
||||||
|
!(await verifyKey(
|
||||||
|
JSON.stringify(c.req.parsedBody),
|
||||||
|
signature,
|
||||||
|
timestamp,
|
||||||
|
config.client.public_key
|
||||||
|
))
|
||||||
|
)
|
||||||
|
return c.redirect('https://www.youtube.com/watch?v=FMhScnY0dME'); // fireship :D
|
||||||
|
|
||||||
const interaction = c.req.parsedBody as unknown as APIPingInteraction | APIApplicationCommandInteraction | APIMessageComponentInteraction | APIApplicationCommandAutocompleteInteraction;
|
const interaction = c.req.parsedBody as unknown as
|
||||||
|
| APIPingInteraction
|
||||||
|
| APIApplicationCommandInteraction
|
||||||
|
| APIMessageComponentInteraction
|
||||||
|
| APIApplicationCommandAutocompleteInteraction;
|
||||||
|
|
||||||
if (interaction.type === InteractionType.Ping) {
|
if (interaction.type === InteractionType.Ping) {
|
||||||
return new CommandContext(c).respond({
|
return new CommandContext(c).respond({
|
||||||
type: InteractionResponseType.Pong
|
type: InteractionResponseType.Pong,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (interaction.type === InteractionType.ApplicationCommandAutocomplete && interaction.data.type === ApplicationCommandType.ChatInput) {
|
if (
|
||||||
|
interaction.type === InteractionType.ApplicationCommandAutocomplete &&
|
||||||
|
interaction.data.type === ApplicationCommandType.ChatInput
|
||||||
|
) {
|
||||||
const command = Commands.get(interaction.data.name);
|
const command = Commands.get(interaction.data.name);
|
||||||
let options = command.options;
|
let options = command.options;
|
||||||
const subCommandGroup = interaction.data.options.find(option => option.type === ApplicationCommandOptionType.SubcommandGroup)
|
const subCommandGroup = interaction.data.options.find(
|
||||||
const subCommand = interaction.data.options.find(option => option.type === ApplicationCommandOptionType.Subcommand);
|
(option) =>
|
||||||
|
option.type === ApplicationCommandOptionType.SubcommandGroup
|
||||||
|
);
|
||||||
|
const subCommand = interaction.data.options.find(
|
||||||
|
(option) => option.type === ApplicationCommandOptionType.Subcommand
|
||||||
|
);
|
||||||
|
|
||||||
// @ts-expect-error ?? find
|
// @ts-expect-error ?? find
|
||||||
if (subCommandGroup) options = options.find(option => option.name === subCommandGroup.name)?.options;
|
if (subCommandGroup)
|
||||||
|
options = options.find(
|
||||||
|
(option) => option.name === subCommandGroup.name
|
||||||
|
)?.options;
|
||||||
// @ts-expect-error ?? find
|
// @ts-expect-error ?? find
|
||||||
if (subCommand) options = options.find(option => option.name === subCommand.name)?.options;
|
if (subCommand)
|
||||||
|
options = options.find(
|
||||||
|
(option) => option.name === subCommand.name
|
||||||
|
)?.options;
|
||||||
|
|
||||||
// @ts-expect-error i dont want waste time
|
// @ts-expect-error i dont want waste time
|
||||||
const focused: APIApplicationCommandBasicOption = interaction.data.options.find(option => option.focused === true);
|
const focused: APIApplicationCommandBasicOption =
|
||||||
|
interaction.data.options.find((option) => option.focused === true);
|
||||||
// @ts-expect-error ?? find
|
// @ts-expect-error ?? find
|
||||||
const option: Option | OptionOptions = options.find(option => option.name === focused.name);
|
const option: Option | OptionOptions = options.find(
|
||||||
|
(option) => option.name === focused.name
|
||||||
|
);
|
||||||
|
|
||||||
return option.run(new AutocompleteContext(
|
return option.run(
|
||||||
|
new AutocompleteContext(
|
||||||
c,
|
c,
|
||||||
option,
|
option,
|
||||||
focused.value,
|
focused.value,
|
||||||
interaction.data.options as any
|
interaction.data.options as any
|
||||||
));
|
)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (interaction.type === InteractionType.ApplicationCommand && interaction.data.type === ApplicationCommandType.ChatInput) {
|
if (
|
||||||
|
interaction.type === InteractionType.ApplicationCommand &&
|
||||||
|
interaction.data.type === ApplicationCommandType.ChatInput
|
||||||
|
) {
|
||||||
const commands = Commands.get(interaction.data.name);
|
const commands = Commands.get(interaction.data.name);
|
||||||
return await commands.run(new CommandContext(
|
return await commands.run(new CommandContext(c, commands, interaction));
|
||||||
c,
|
|
||||||
commands,
|
|
||||||
interaction
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return new CommandContext(c).respond({
|
return new CommandContext(c).respond({
|
||||||
type: InteractionResponseType.ChannelMessageWithSource,
|
type: InteractionResponseType.ChannelMessageWithSource,
|
||||||
data: {
|
data: {
|
||||||
content: 'Beep boop. Boop beep?'
|
content: 'Beep boop. Boop beep?',
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
})
|
});
|
||||||
|
|
||||||
app.post('/github_webhook', bodyParse(), (c) => {
|
app.post('/github_webhook', bodyParse(), (c) => {
|
||||||
if (
|
if (
|
||||||
!c.req.headers.get('User-Agent').startsWith('GitHub-Hookshot/') ||
|
!c.req.headers.get('User-Agent').startsWith('GitHub-Hookshot/') ||
|
||||||
typeof c.req?.parsedBody !== 'object'
|
typeof c.req?.parsedBody !== 'object'
|
||||||
) return c.redirect('https://www.youtube.com/watch?v=FMhScnY0dME'); // fireship :D
|
)
|
||||||
|
return c.redirect('https://www.youtube.com/watch?v=FMhScnY0dME'); // fireship :D
|
||||||
|
|
||||||
if (
|
if (
|
||||||
!verifyGithubKey(
|
!verifyGithubKey(
|
||||||
|
@ -99,14 +146,18 @@ app.post('/github_webhook', bodyParse(), (c) => {
|
||||||
c.req.headers.get('X-Hub-Signature-256'),
|
c.req.headers.get('X-Hub-Signature-256'),
|
||||||
config.api.github_webhooks_secret
|
config.api.github_webhooks_secret
|
||||||
)
|
)
|
||||||
) return c.redirect('https://www.youtube.com/watch?v=FMhScnY0dME'); // fireship :D
|
)
|
||||||
|
return c.redirect('https://www.youtube.com/watch?v=FMhScnY0dME'); // fireship :D
|
||||||
|
|
||||||
const issueOrPr = c.req.parsedBody;
|
const issueOrPr = c.req.parsedBody;
|
||||||
if (issueOrPr.action !== 'deleted') {
|
if (issueOrPr.action !== 'deleted') {
|
||||||
if ('issue' in issueOrPr) {
|
if ('issue' in issueOrPr) {
|
||||||
setIssue({
|
setIssue({
|
||||||
id: issueOrPr.issue.number,
|
id: issueOrPr.issue.number,
|
||||||
repository: issueOrPr.issue.repository_url.replace('https://api.github.com/repos/', ''),
|
repository: issueOrPr.issue.repository_url.replace(
|
||||||
|
'https://api.github.com/repos/',
|
||||||
|
''
|
||||||
|
),
|
||||||
title: issueOrPr.issue.title,
|
title: issueOrPr.issue.title,
|
||||||
number: issueOrPr.issue.number,
|
number: issueOrPr.issue.number,
|
||||||
state: issueOrPr.issue.state,
|
state: issueOrPr.issue.state,
|
||||||
|
@ -116,12 +167,13 @@ app.post('/github_webhook', bodyParse(), (c) => {
|
||||||
user_login: issueOrPr.issue.user.login,
|
user_login: issueOrPr.issue.user.login,
|
||||||
user_html_url: issueOrPr.issue.user.html_url,
|
user_html_url: issueOrPr.issue.user.html_url,
|
||||||
type: '(IS)',
|
type: '(IS)',
|
||||||
})
|
});
|
||||||
}
|
} else if ('pull_request' in issueOrPr) {
|
||||||
else if('pull_request' in issueOrPr) {
|
|
||||||
setPullRequest({
|
setPullRequest({
|
||||||
id: issueOrPr.pull_request.number,
|
id: issueOrPr.pull_request.number,
|
||||||
repository: issueOrPr.pull_request.html_url.replace('https://github.com/', '').replace(`/pull/${issueOrPr.pull_request.number}`, ''),
|
repository: issueOrPr.pull_request.html_url
|
||||||
|
.replace('https://github.com/', '')
|
||||||
|
.replace(`/pull/${issueOrPr.pull_request.number}`, ''),
|
||||||
title: issueOrPr.pull_request.title,
|
title: issueOrPr.pull_request.title,
|
||||||
number: issueOrPr.pull_request.number,
|
number: issueOrPr.pull_request.number,
|
||||||
state: issueOrPr.pull_request.state,
|
state: issueOrPr.pull_request.state,
|
||||||
|
@ -133,24 +185,33 @@ app.post('/github_webhook', bodyParse(), (c) => {
|
||||||
user_html_url: issueOrPr.pull_request.user.html_url,
|
user_html_url: issueOrPr.pull_request.user.html_url,
|
||||||
type: '(PR)',
|
type: '(PR)',
|
||||||
draft: issueOrPr.pull_request.draft,
|
draft: issueOrPr.pull_request.draft,
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if ('issue' in issueOrPr) deleteIssueOrPR(
|
if ('issue' in issueOrPr)
|
||||||
issueOrPr.issue.number, issueOrPr.issue.repository_url.replace('https://api.github.com/repos/', '')
|
deleteIssueOrPR(
|
||||||
|
issueOrPr.issue.number,
|
||||||
|
issueOrPr.issue.repository_url.replace(
|
||||||
|
'https://api.github.com/repos/',
|
||||||
|
''
|
||||||
|
)
|
||||||
);
|
);
|
||||||
else if('pull_request' in issueOrPr) deleteIssueOrPR(
|
else if ('pull_request' in issueOrPr)
|
||||||
|
deleteIssueOrPR(
|
||||||
issueOrPr.pull_request.number,
|
issueOrPr.pull_request.number,
|
||||||
issueOrPr.pull_request.html_url
|
issueOrPr.pull_request.html_url
|
||||||
.replace('https://github.com/', '')
|
.replace('https://github.com/', '')
|
||||||
.replace(`/pull/${issueOrPr.pull_request.number}`, '')
|
.replace(`/pull/${issueOrPr.pull_request.number}`, '')
|
||||||
)
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return c.json({
|
return c.json(
|
||||||
message: 'OK'
|
{
|
||||||
}, 200);
|
message: 'OK',
|
||||||
})
|
},
|
||||||
|
200
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
await Bun.serve({
|
await Bun.serve({
|
||||||
port: config.server.port,
|
port: config.server.port,
|
||||||
|
|
Loading…
Reference in a new issue