Skip to content

Commit

Permalink
actually use action in template
Browse files Browse the repository at this point in the history
  • Loading branch information
DEVTomatoCake committed Nov 2, 2023
1 parent 132d54f commit 28db045
Show file tree
Hide file tree
Showing 52 changed files with 224 additions and 3 deletions.
1 change: 1 addition & 0 deletions generate.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ Object.keys(events).forEach(event => {
"module.exports = [\n" +
events[event].map(action => {
return "\t{\n" +
"\t\taction: \"" + action + "\",\n" +
"\t\tembeds: [{\n" +
"\t\t\tauthor: {\n" +
"\t\t\t\tname: \"{{ sender.login }}\",\n" +
Expand Down
4 changes: 1 addition & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ const ratelimit30s = {}
const ratelimit5m = {}
let ratelimitGlobal5m = 0
app.use((req, res, next) => {
const ip = req.headers["cf-connecting-ip"]
if (!req.headers["cf-connecting-ip"]) return res.status(400).send("Direct access is not allowed")
const ip = "%" + req.headers["cf-connecting-ip"]

if (req.path.startsWith("/hook/")) return next()

Expand All @@ -33,10 +33,8 @@ app.use((req, res, next) => {

if (ratelimit30s[ip]) ratelimit30s[ip]++
else ratelimit30s[ip] = 1

if (ratelimit5m[ip]) ratelimit5m[ip]++
else ratelimit5m[ip] = 1

ratelimitGlobal5m++

setTimeout(() => {
Expand Down
2 changes: 2 additions & 0 deletions templates/branch_protection_configuration.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
module.exports = [
{
action: "disabled",
embeds: [{
author: {
name: "{{ sender.login }}",
Expand All @@ -10,6 +11,7 @@ module.exports = [
}]
},
{
action: "enabled",
embeds: [{
author: {
name: "{{ sender.login }}",
Expand Down
3 changes: 3 additions & 0 deletions templates/branch_protection_rule.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
module.exports = [
{
action: "created",
embeds: [{
author: {
name: "{{ sender.login }}",
Expand All @@ -10,6 +11,7 @@ module.exports = [
}]
},
{
action: "edited",
embeds: [{
author: {
name: "{{ sender.login }}",
Expand All @@ -20,6 +22,7 @@ module.exports = [
}]
},
{
action: "deleted",
embeds: [{
author: {
name: "{{ sender.login }}",
Expand Down
4 changes: 4 additions & 0 deletions templates/check_run.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
module.exports = [
{
action: "completed",
embeds: [{
author: {
name: "{{ sender.login }}",
Expand All @@ -10,6 +11,7 @@ module.exports = [
}]
},
{
action: "created",
embeds: [{
author: {
name: "{{ sender.login }}",
Expand All @@ -20,6 +22,7 @@ module.exports = [
}]
},
{
action: "requested_action",
embeds: [{
author: {
name: "{{ sender.login }}",
Expand All @@ -30,6 +33,7 @@ module.exports = [
}]
},
{
action: "rerequested",
embeds: [{
author: {
name: "{{ sender.login }}",
Expand Down
3 changes: 3 additions & 0 deletions templates/check_suite.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
module.exports = [
{
action: "completed",
embeds: [{
author: {
name: "{{ sender.login }}",
Expand All @@ -10,6 +11,7 @@ module.exports = [
}]
},
{
action: "requested",
embeds: [{
author: {
name: "{{ sender.login }}",
Expand All @@ -20,6 +22,7 @@ module.exports = [
}]
},
{
action: "rerequested",
embeds: [{
author: {
name: "{{ sender.login }}",
Expand Down
6 changes: 6 additions & 0 deletions templates/code_scanning_alert.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
module.exports = [
{
action: "appeared_in_branch",
embeds: [{
author: {
name: "{{ sender.login }}",
Expand All @@ -10,6 +11,7 @@ module.exports = [
}]
},
{
action: "closed_by_user",
embeds: [{
author: {
name: "{{ sender.login }}",
Expand All @@ -20,6 +22,7 @@ module.exports = [
}]
},
{
action: "created",
embeds: [{
author: {
name: "{{ sender.login }}",
Expand All @@ -30,6 +33,7 @@ module.exports = [
}]
},
{
action: "fixed",
embeds: [{
author: {
name: "{{ sender.login }}",
Expand All @@ -40,6 +44,7 @@ module.exports = [
}]
},
{
action: "reopened",
embeds: [{
author: {
name: "{{ sender.login }}",
Expand All @@ -50,6 +55,7 @@ module.exports = [
}]
},
{
action: "reopened_by_user",
embeds: [{
author: {
name: "{{ sender.login }}",
Expand Down
3 changes: 3 additions & 0 deletions templates/custom_property.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
module.exports = [
{
action: "created",
embeds: [{
author: {
name: "{{ sender.login }}",
Expand All @@ -10,6 +11,7 @@ module.exports = [
}]
},
{
action: "deleted",
embeds: [{
author: {
name: "{{ sender.login }}",
Expand All @@ -20,6 +22,7 @@ module.exports = [
}]
},
{
action: "updated",
embeds: [{
author: {
name: "{{ sender.login }}",
Expand Down
7 changes: 7 additions & 0 deletions templates/dependabot_alert.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
module.exports = [
{
action: "auto_dismissed",
embeds: [{
author: {
name: "{{ sender.login }}",
Expand All @@ -10,6 +11,7 @@ module.exports = [
}]
},
{
action: "auto_reopened",
embeds: [{
author: {
name: "{{ sender.login }}",
Expand All @@ -20,6 +22,7 @@ module.exports = [
}]
},
{
action: "created",
embeds: [{
author: {
name: "{{ sender.login }}",
Expand All @@ -30,6 +33,7 @@ module.exports = [
}]
},
{
action: "dismissed",
embeds: [{
author: {
name: "{{ sender.login }}",
Expand All @@ -40,6 +44,7 @@ module.exports = [
}]
},
{
action: "fixed",
embeds: [{
author: {
name: "{{ sender.login }}",
Expand All @@ -50,6 +55,7 @@ module.exports = [
}]
},
{
action: "reintroduced",
embeds: [{
author: {
name: "{{ sender.login }}",
Expand All @@ -60,6 +66,7 @@ module.exports = [
}]
},
{
action: "reopened",
embeds: [{
author: {
name: "{{ sender.login }}",
Expand Down
2 changes: 2 additions & 0 deletions templates/deploy_key.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
module.exports = [
{
action: "created",
embeds: [{
author: {
name: "{{ sender.login }}",
Expand All @@ -10,6 +11,7 @@ module.exports = [
}]
},
{
action: "deleted",
embeds: [{
author: {
name: "{{ sender.login }}",
Expand Down
3 changes: 3 additions & 0 deletions templates/deployment_review.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
module.exports = [
{
action: "approved",
embeds: [{
author: {
name: "{{ sender.login }}",
Expand All @@ -10,6 +11,7 @@ module.exports = [
}]
},
{
action: "rejected",
embeds: [{
author: {
name: "{{ sender.login }}",
Expand All @@ -20,6 +22,7 @@ module.exports = [
}]
},
{
action: "requested",
embeds: [{
author: {
name: "{{ sender.login }}",
Expand Down
Loading

0 comments on commit 28db045

Please sign in to comment.