Skip to content
This repository was archived by the owner on Mar 31, 2026. It is now read-only.

Development has moved #48

Development has moved

Development has moved #48

name: Telegram Notifications
on:
issues:
types: [opened]
issue_comment:
types: [created]
permissions:
contents: read
jobs:
notify:
runs-on: ubuntu-latest
steps:
- uses: actions/github-script@v7
env:
TELEGRAM_BOT_TOKEN: ${{ secrets.TELEGRAM_BOT_TOKEN }}
TELEGRAM_CHAT_ID: ${{ secrets.TELEGRAM_CHAT_ID }}
with:
script: |
const token = process.env.TELEGRAM_BOT_TOKEN;
const chatId = process.env.TELEGRAM_CHAT_ID;
if (!token || !chatId) return;
function mdToHtml(md) {
let s = md;
// Escape HTML entities first
s = s.replace(/&/g, '&');
s = s.replace(/</g, '&lt;');
s = s.replace(/>/g, '&gt;');
// Markdown headings → bold
s = s.replace(/^#{1,6}\s+(.+)$/gm, '<b>$1</b>');
// Inline code (before bold/italic to avoid conflicts)
s = s.replace(/`([^`]+)`/g, '<code>$1</code>');
// Bold **text** or __text__
s = s.replace(/\*\*(.+?)\*\*/g, '<b>$1</b>');
s = s.replace(/__(.+?)__/g, '<b>$1</b>');
// Italic *text* or _text_ (not inside words)
s = s.replace(/(?<!\w)\*([^*]+)\*(?!\w)/g, '<i>$1</i>');
s = s.replace(/(?<!\w)_([^_]+)_(?!\w)/g, '<i>$1</i>');
// Links [text](url)
s = s.replace(/\[([^\]]+)\]\(([^)]+)\)/g, '<a href="$2">$1</a>');
return s;
}
let text = '';
const event = context.eventName;
const repo = context.payload.repository.full_name;
if (event === 'issues' && context.payload.action === 'opened') {
// Skip bot-created issues
if (context.payload.issue.user.type === 'Bot') return;
const i = context.payload.issue;
text = `📋 <b>New Issue #${i.number}</b>: ${i.title}\n\nby ${i.user.login}\n<a href="${i.html_url}">View issue</a>`;
} else if (event === 'issue_comment' && context.payload.action === 'created') {
// Only post maintainer comments
const c = context.payload.comment;
if (c.user.login !== 'dvershinin') return;
// Skip auto-reply bot comments
if (c.user.type === 'Bot') return;
const i = context.payload.issue;
const snippet = mdToHtml(c.body.substring(0, 2000));
text = `💬 <b>Comment on #${i.number}</b>: ${i.title}\n\n${snippet}\n\n<a href="${c.html_url}">View comment</a>`;
}
if (!text) return;
await fetch(`https://api.telegram.org/bot${token}/sendMessage`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
chat_id: chatId,
text: text,
parse_mode: 'HTML',
disable_web_page_preview: true
})
});