Skip to content

Commit 29fb8bc

Browse files
committed
change message and add ci
1 parent 001310e commit 29fb8bc

File tree

6 files changed

+129
-50
lines changed

6 files changed

+129
-50
lines changed

.env.example

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
PRIVATE_KEY=your_nostr_private_key
1+
NOSTR_PRIVATE_KEY=your_nostr_private_key
22
BOT_TOKEN=your_telegram_bot_token
33
TELEGRAM_CHAT_ID=your_telegram_chat_id
44
NOSTR_RELAYS=wss://jellyfish.land,wss://relay.nostr.band

.github/workflows/packages.yml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: Create and publish a Docker image
2+
3+
# This workflow is wrote based on this document: https://docs.github.com/en/packages/managing-github-packages-using-github-actions-workflows/publishing-and-installing-a-package-with-github-actions
4+
5+
on:
6+
push:
7+
tags:
8+
- 'v*'
9+
10+
env:
11+
REGISTRY: ghcr.io
12+
IMAGE_NAME: ${{ github.repository }}
13+
14+
15+
jobs:
16+
build-and-push-image:
17+
runs-on: ubuntu-latest
18+
19+
permissions:
20+
contents: read
21+
packages: write
22+
attestations: write
23+
id-token: write
24+
25+
steps:
26+
- name: Checkout repository
27+
uses: actions/checkout@v4
28+
29+
- name: Log in to the Container registry
30+
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
31+
with:
32+
registry: ${{ env.REGISTRY }}
33+
username: ${{ github.actor }}
34+
password: ${{ secrets.GITHUB_TOKEN }}
35+
36+
- name: Extract metadata (tags, labels) for Docker
37+
id: meta
38+
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
39+
with:
40+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
41+
42+
- name: Build and push Docker image
43+
id: push
44+
uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
45+
with:
46+
context: .
47+
push: true
48+
tags: ${{ steps.meta.outputs.tags }}
49+
labels: ${{ steps.meta.outputs.labels }}
50+
51+
- name: Generate artifact attestation
52+
uses: actions/attest-build-provenance@v1
53+
with:
54+
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}}
55+
subject-digest: ${{ steps.push.outputs.digest }}
56+
push-to-registry: true

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ Contributions are welcome! If you have ideas for features or improvements, pleas
3535

3636
Stay connected with us on social media:
3737

38-
- **Nostr**: [@your_nostr_handle](https://nostr.com/@your_nostr_handle) (Replace with your actual Nostr handle)
39-
- **Telegram**: [Join our Telegram group](https://t.me/your_telegram_group) (Replace with your actual Telegram group link)
38+
- **Nostr**: [@Zapounty](https://njump.me/npub1ulvrsldmdlwrzh026plfylr22rl8c068yd4uu7ww0s0s8zac486qzwrlwd) (Replace with your actual Nostr handle)
39+
<!-- - **Telegram**: [Join our Telegram group](https://t.me/your_telegram_group) (Replace with your actual Telegram group link) -->
4040

4141
## License
4242

src/main.ts

Lines changed: 66 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -3,49 +3,46 @@ import { TransporterFactory } from "./transporter.factory";
33
import { name, version } from "../package.json";
44

55
export default (app: Probot) => {
6-
console.info(`running ${name}: ${version}`);
6+
console.info(`Running ${name}: ${version}`);
7+
78
app.on("issues.labeled", async (context) => {
8-
const issue = context.payload.issue;
9-
const label = context.payload.label?.name;
9+
try {
10+
const issue = context.payload.issue;
11+
const label = context.payload.label?.name;
1012

11-
if (label === "zap reward") {
12-
const comments = await context.octokit.issues.listComments({
13-
owner: context.payload.repository.owner.login,
14-
repo: context.payload.repository.name,
15-
issue_number: issue.number,
16-
});
13+
if (label === "zap reward") {
14+
const comments = await context.octokit.issues.listComments({
15+
owner: context.payload.repository.owner.login,
16+
repo: context.payload.repository.name,
17+
issue_number: issue.number,
18+
});
1719

18-
const zapRequest = comments.data.map((comment) => parseZapReward(comment.body ?? "")).find((request) => request !== null);
20+
const zapRequest = comments.data
21+
.map((comment) => parseZapReward(comment.body ?? ""))
22+
.find((request) => request !== null);
1923

20-
if (zapRequest) {
21-
const message =
22-
`🌟 **Zap Reward Request** 🌟\n\n` +
23-
`**Amount:** ${zapRequest.amount} ${zapRequest.currency}\n` +
24-
`**Expires On:** ${zapRequest.expireAt}\n\n` +
25-
`This reward has been requested for the following issue:\n` +
26-
`🔗 [View Issue Here](${issue.html_url})\n\n` +
27-
`Thank you for your participation! 🎉`;
28-
await sendToAll(message);
24+
if (zapRequest) {
25+
const message = generateMessage(zapRequest.amount, issue.title, issue.html_url);
26+
await sendToAll(message);
27+
}
2928
}
29+
} catch (error) {
30+
console.error("Error processing labeled issue:", error);
3031
}
3132
});
3233

3334
app.on("issue_comment.created", async (context) => {
34-
const comment = context.payload.comment.body;
35-
const issueUrl = context.payload.issue.html_url;
36-
37-
const parsedData = parseZapReward(comment);
35+
try {
36+
const comment = context.payload.comment.body;
37+
const issue = context.payload.issue;
38+
const zapRequest = parseZapReward(comment);
3839

39-
if (parsedData) {
40-
const message =
41-
`🌟 **Zap Reward Request** 🌟\n\n` +
42-
`**Amount:** ${parsedData.amount} ${parsedData.currency}\n` +
43-
`**Expires On:** ${parsedData.expireAt}\n\n` +
44-
`This reward has been requested for the following issue:\n` +
45-
`🔗 [View Issue Here](${issueUrl})\n\n` +
46-
`Thank you for your participation! 🎉`;
47-
48-
await sendToAll(message);
40+
if (zapRequest) {
41+
const message = generateMessage(zapRequest.amount, issue.title, issue.html_url);
42+
await sendToAll(message);
43+
}
44+
} catch (error) {
45+
console.error("Error processing issue comment:", error);
4946
}
5047
});
5148
};
@@ -54,26 +51,49 @@ export default (app: Probot) => {
5451
* Sends a message to both Telegram and Nostr.
5552
*/
5653
async function sendToAll(message: string) {
57-
// const telegram = TransporterFactory.create("telegram");
58-
// await telegram.send(message);
54+
try {
55+
const telegram = TransporterFactory.create("telegram");
56+
await telegram.send(message);
57+
} catch (error) {
58+
console.error("Error sending message to Telegram:", error);
59+
}
5960

60-
const nostr = TransporterFactory.create("nostr");
61-
await nostr.send(message);
61+
try {
62+
const nostr = TransporterFactory.create("nostr");
63+
await nostr.send(message);
64+
} catch (error) {
65+
console.error("Error sending message to Nostr:", error);
66+
}
6267
}
6368

6469
/**
6570
* Parses a Zap Reward template from the comment.
6671
*/
6772
function parseZapReward(comment: string) {
68-
const zapRegex = /zap reward:\s*amount:\s*(\d+)\s*currency:\s*(Sats|BTC)\s*expire at:\s*([\d-]+)/i;
69-
const match = comment.match(zapRegex);
73+
try {
74+
const zapRegex = /zap reward:\s*amount:\s*(\d+)/i;
75+
const match = comment.match(zapRegex);
7076

71-
if (match) {
72-
return {
73-
amount: parseInt(match[1], 10),
74-
currency: match[2],
75-
expireAt: match[3],
76-
};
77+
if (match) {
78+
return {
79+
amount: parseInt(match[1], 10),
80+
};
81+
}
82+
return null;
83+
} catch (error) {
84+
console.error("Error parsing Zap Reward:", error);
85+
return null;
7786
}
78-
return null;
87+
}
88+
89+
function generateMessage(amount: number, title: string, link: string): string {
90+
return (
91+
`🌟 New Zap Reward Request 🌟\n\n` +
92+
`**Issue:** 📌 ${title}\n\n` +
93+
`**Amount:** ${amount} Sats ⚡ \n\n` +
94+
`This reward has been requested for the following issue:\n` +
95+
`🔗 View Issue Here:\n${link}\n\n` +
96+
`Thank you for your participation! 🎉\n\n` +
97+
`#devstr #dev #bounty #zap #job #jobstr`
98+
);
7999
}

src/transporter/nostr.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export class NostrTransporter implements ITransporter {
3535
let event = {
3636
kind: 1,
3737
created_at: createdAt,
38-
tags: [],
38+
tags: [["t","devstr"],["t","dev"], ["t","zap"], ["t","bounty"], ["t","job"], ["t","jobstr"]],
3939
content: message,
4040
};
4141

src/transporter/telegram.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ export class TelegramTransporter implements ITransporter {
2222
await axios.post(`https://api.telegram.org/bot${this.botToken}/sendMessage`, {
2323
chat_id: this.chatId,
2424
text: message,
25+
parse_mode: "Markdown",
2526
});
27+
28+
console.info("send new message to telegram")
2629
}
2730
}

0 commit comments

Comments
 (0)