-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
385 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,34 @@ | ||
|
||
# nyawer-hook | ||
Contoh web server saweria webhook mengirim notifikasi donasi ke discord webhook. | ||
|
||
## Contoh | ||
<img src="https://github.com/JadlionHD/nyawer-hook/blob/master/.github/img/contoh3.png?raw=true"> | ||
<img src="https://github.com/JadlionHD/nyawer-hook/blob/master/.github/img/contoh1.png?raw=true" width=350> | ||
|
||
## Cara kerjanya? | ||
Cara kerjanya lumayan mudah, yaitu menggunakan salah satu integrations yang disediakan [Saweria](https://saweria.co) yaitu webhook. | ||
<img src="https://github.com/JadlionHD/nyawer-hook/blob/master/.github/img/example1.png?raw=true"> | ||
Cara kerjanya menggunakan salah satu integrations yang disediakan [Saweria](https://saweria.co) yaitu webhook. | ||
<img src="https://github.com/JadlionHD/nyawer-hook/blob/master/.github/img/contoh2.png?raw=true"> | ||
Jadi ini adalah gambaran cara kerjanya: | ||
- Saweria webhook > Website kamu > Discord webhook | ||
|
||
|
||
## Install | ||
Untuk sekarang masih belum selesai dibuat. | ||
Dokumentasi belum lengkap, tapi ini sedikit instalisasinya sebagai berikut: | ||
- Buatlah .env file lalu isi beberapa line berikut ini | ||
``` | ||
SECRET=TOKENRAHASIA // token websitemu | ||
DISCORD_WEBHOOK=URL // discord webhook url | ||
PORT=NOMOR // port website yang akan dibuka | ||
``` | ||
- Lalu install modules yang diperlukan dengan cara: | ||
```bash | ||
$ npm install | ||
``` | ||
- Setelah semuanya selesai, maka untuk memulainya ketik: | ||
```bash | ||
$ npm start | ||
``` | ||
|
||
## Contribution | ||
Kalo kalian menemukan sebuah bug, dengan senang hati membuka issues agar dibahas lebih lanjut. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"embeds": [ | ||
{ | ||
"title": "Sankyu {donator_name}! telah nyawer Rp{amount}", | ||
"description": "Pesan: ```{message}```", | ||
"image": { | ||
"url": "https://c.tenor.com/z89eTLYza68AAAAd/yuudachi-poi.gif" | ||
}, | ||
"thumbnail": { | ||
"url": "https://saweria.co/twitter_card.png" | ||
}, | ||
"footer": { | ||
"text": "https://saweria.co/JadlionHD" | ||
}, | ||
"color": "#d41138" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,23 @@ | ||
const express = require("express"); | ||
const path = require("path"); | ||
const app = express(); | ||
const fs = require("fs"); | ||
require("dotenv").config(); | ||
const { handlePostReq } = require("./Saweria.js"); | ||
const { handlePostReq, handleEditEmbed } = require("./Saweria.js"); | ||
|
||
app.use(express.json()); | ||
app.use(express.urlencoded({ extended: true })); | ||
app.set("view engine", "ejs"); | ||
app.set("views", path.join(__dirname, "/web/views")); | ||
app.use(express.static(path.join(__dirname, "/web/public"))); | ||
|
||
app.post("/callback/discord", handlePostReq); | ||
app.get("/", (req, res) => { | ||
const embed = JSON.parse(fs.readFileSync("src/embed.json", "utf8")); | ||
res.render("index.ejs", {embed: embed.embeds[0]}); | ||
}); | ||
app.post("/edit/embed", handleEditEmbed); | ||
|
||
app.listen(parseInt(process.env.PORT), () => { | ||
console.log("Server siap!"); | ||
app.listen(process.env.PORT, () => { | ||
console.log("Web Server siap!"); | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
body { | ||
margin: 0; | ||
padding: 0; | ||
font-family: "Century Gothic Bold", sans-serif; | ||
color: white; | ||
} | ||
|
||
.main { | ||
background-color: #151515; | ||
padding-top: 2rem; | ||
} | ||
|
||
#titleEmbed { | ||
width: 50%; | ||
} | ||
#descEmbed { | ||
width: 75%; | ||
} | ||
|
||
.container { | ||
background-color: #525252; | ||
padding: 1.5rem; | ||
border-radius: 10px; | ||
} | ||
|
||
.pfooter { | ||
padding: 1rem; | ||
text-align: center; | ||
} | ||
|
||
.heartd { | ||
text-decoration: none; | ||
color: white; | ||
transition: 0.3s; | ||
} | ||
|
||
.heartd:hover { | ||
color: red; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous"> | ||
<link rel="stylesheet" href="css/style.css"> | ||
<title>Saweria - Hook</title> | ||
</head> | ||
<body> | ||
<div class="main"> | ||
<div class="container"> | ||
<h2>Nyawer-hook Embed Editor</h2> | ||
<form action="/edit/embed" method="post" target="_self" id="main-form"> | ||
|
||
<div class="mb-3"> | ||
<label for="titleCheckbox">Title</label><br> | ||
<input type="text" class="form-control" id="titleEmbed" name="title" placeholder="Hai shikikan" maxlength="256" value="<%=embed.title%>"> | ||
</div> | ||
|
||
<div class="mb-3"> | ||
<label for="descCheckbox">Description</label><br> | ||
<textarea class="form-control" id="descEmbed" name="description" rows="3" placeholder="Shikikan-san you got some donation" maxlength="4096"><%=embed.description%></textarea> | ||
</div> | ||
|
||
<div class="row"> | ||
<div class="col"> | ||
<label for="footerCheckbox">Footer Text</label><br> | ||
<input type="text" class="form-control" id="footerEmbed" name="footerText" placeholder="Sankyuu~!" maxlength="2048" value="<%=embed.footer.text%>"> | ||
</div> | ||
|
||
<div class="col"> | ||
<label for="imageUrlCheckbox">Image URL</label><br> | ||
<input type="text" class="form-control" id="imageEmbed" name="imageUrl" placeholder="https://example.com/image.jpg" value="<%=embed.image.url%>"> | ||
</div> | ||
|
||
<div class="col"> | ||
<label for="thumbnailCheckbox">Thumbnail URL</label><br> | ||
<input type="text" class="form-control" id="thumbnailEmbed" name="thumbnailUrl" placeholder="https://example.com/image.jpg" value="<%=embed.thumbnail.url%>"><br> | ||
</div> | ||
</div> | ||
|
||
<div class="mb-3"> | ||
<label for="secretToken">Token (<a href="#" style="text-decoration: none;" data-bs-toggle="tooltip" data-bs-placement="top" title="You can find the token from environment variable (.env)">?</a>)</label> | ||
<input type="password" class="form-control" id="secretToken" name="token" placeholder="Your Secret Token"> | ||
</div> | ||
|
||
<div class="mb-3"> | ||
<label for="colorCheckbox">Embed Color</label><br> | ||
<input type="color" id="colorEmbed" name="color" value="<%=embed.color%>"> | ||
</div> | ||
|
||
<input type="submit" value="Save" class="btn btn-primary"> | ||
</form> | ||
</div> | ||
<footer class="pfooter"> | ||
<h4>Made with <a href="#" class="heartd">❤</a> <a href="https://github.com/JadlionHD" style="text-decoration: none; color: white; font-size: 25px;">JadlionHD</a></h4> | ||
</footer> | ||
</div> | ||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.bundle.min.js" integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM" crossorigin="anonymous"></script> | ||
<script> | ||
var tooltipTriggerList = [].slice.call(document.querySelectorAll('[data-bs-toggle="tooltip"]')) | ||
var tooltipList = tooltipTriggerList.map(function (tooltipTriggerEl) { | ||
return new bootstrap.Tooltip(tooltipTriggerEl) | ||
}) | ||
</script> | ||
|
||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous"> | ||
<link rel="stylesheet" href="../public/css/style.css"> | ||
<title>Saweria - Hook</title> | ||
</head> | ||
<body> | ||
<div class="main"> | ||
<div class="container"> | ||
<h2>Nyawer-hook Embed Editor</h2> | ||
<form action="/edit/embed" method="post" target="_top" id="main-form"> | ||
|
||
<div class="mb-3"> | ||
<label for="titleCheckbox">Title</label><br> | ||
<input type="text" class="form-control" id="titleEmbed" name="title" placeholder="Hai shikikan" maxlength="256" required> | ||
</div> | ||
|
||
<div class="mb-3"> | ||
<label for="descCheckbox">Description</label><br> | ||
<textarea class="form-control" id="descEmbed" name="description" rows="3" placeholder="Shikikan-san you got some donation" maxlength="4096"></textarea> | ||
</div> | ||
|
||
<div class="row"> | ||
<div class="col"> | ||
<label for="footerCheckbox">Footer Text</label><br> | ||
<input type="text" class="form-control" id="footerEmbed" name="footerText" placeholder="Sankyuu~!" maxlength="2048"> | ||
</div> | ||
|
||
<div class="col"> | ||
<label for="imageUrlCheckbox">Image URL</label><br> | ||
<input type="text" class="form-control" id="imageEmbed" name="imageUrl" placeholder="https://example.com/image.jpg"> | ||
</div> | ||
|
||
<div class="col"> | ||
<label for="thumbnailCheckbox">Thumbnail URL</label><br> | ||
<input type="text" class="form-control" id="thumbnailEmbed" name="thumbnailUrl" placeholder="https://example.com/image.jpg"><br> | ||
</div> | ||
</div> | ||
|
||
<div class="mb-3"> | ||
<label for="secretToken">Token (<a href="#" style="text-decoration: none;" data-bs-toggle="tooltip" data-bs-placement="top" title="You can find the token from environment variable (.env)">?</a>)</label> | ||
<input type="password" class="form-control" id="secretToken" name="token" placeholder="Your Secret Token"> | ||
</div> | ||
|
||
<div class="mb-3"> | ||
<label for="colorCheckbox">Embed Color</label><br> | ||
<input type="color" id="colorEmbed" name="color"> | ||
</div> | ||
|
||
<input type="submit" value="Save" class="btn btn-primary"> | ||
</form> | ||
</div> | ||
<footer class="pfooter"> | ||
<h4>Made with <a href="#" class="heartd">❤</a> <a href="https://github.com/JadlionHD" style="text-decoration: none; color: white; font-size: 25px;">JadlionHD</a></h4> | ||
</footer> | ||
</div> | ||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.bundle.min.js" integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM" crossorigin="anonymous"></script> | ||
<script> | ||
var tooltipTriggerList = [].slice.call(document.querySelectorAll('[data-bs-toggle="tooltip"]')) | ||
var tooltipList = tooltipTriggerList.map(function (tooltipTriggerEl) { | ||
return new bootstrap.Tooltip(tooltipTriggerEl) | ||
}) | ||
</script> | ||
|
||
</body> | ||
</html> |
Oops, something went wrong.