mirror of
https://github.com/chainstacklabs/pumpfun-bonkfun-bot.git
synced 2026-08-17 09:18:05 +00:00
Add better error handling & rertries
This commit is contained in:
@@ -15,78 +15,86 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
script: |
|
script: |
|
||||||
const comment = context.payload.comment;
|
try {
|
||||||
const body = comment.body.toLowerCase();
|
const comment = context.payload.comment;
|
||||||
const author = comment.user.login;
|
const body = comment.body.toLowerCase();
|
||||||
|
const author = comment.user.login;
|
||||||
|
|
||||||
// Suspicious patterns
|
// Suspicious patterns
|
||||||
const suspiciousPatterns = [
|
const suspiciousPatterns = [
|
||||||
'support team',
|
'support team',
|
||||||
'customer service',
|
'customer service',
|
||||||
'telegram',
|
'telegram',
|
||||||
'whatsapp',
|
'whatsapp',
|
||||||
'contact us',
|
'contact us',
|
||||||
'click here',
|
'click here',
|
||||||
'support group',
|
'support group',
|
||||||
't.me/',
|
't.me/',
|
||||||
'wa.me/',
|
'wa.me/',
|
||||||
'support chat',
|
'support chat',
|
||||||
'live chat',
|
'live chat',
|
||||||
'support ticket',
|
'support ticket',
|
||||||
'ticket id',
|
'ticket id',
|
||||||
'live support',
|
'live support',
|
||||||
'support line',
|
'support line',
|
||||||
'support agent',
|
'support agent',
|
||||||
'support network',
|
'support network',
|
||||||
'dedicated support',
|
'dedicated support',
|
||||||
'personalized assistance',
|
'personalized assistance',
|
||||||
'opened for you',
|
'opened for you',
|
||||||
'kindly talk to',
|
'kindly talk to',
|
||||||
'we apologize',
|
'we apologize',
|
||||||
'live chat with an agent',
|
'live chat with an agent',
|
||||||
'chat button',
|
'chat button',
|
||||||
'dapp portal',
|
'dapp portal',
|
||||||
'decentralized dapp',
|
'decentralized dapp',
|
||||||
'access the portal',
|
'access the portal',
|
||||||
'report your request',
|
'report your request',
|
||||||
'start a conversation',
|
'start a conversation',
|
||||||
'click the chat',
|
'click the chat',
|
||||||
'for assistance',
|
'for assistance',
|
||||||
'reach out to',
|
'reach out to',
|
||||||
'through the chat',
|
'through the chat',
|
||||||
'portal',
|
'portal',
|
||||||
];
|
];
|
||||||
|
|
||||||
// Check for external links (excluding common legitimate domains)
|
// Check for external links (excluding common legitimate domains)
|
||||||
const hasExternalLinks = body.includes('http') || body.includes('www');
|
const hasExternalLinks = body.includes('http') || body.includes('www');
|
||||||
const hasGithubLinks = body.includes('github.com');
|
const hasGithubLinks = body.includes('github.com');
|
||||||
const suspiciousLinks = hasExternalLinks && !hasGithubLinks;
|
const suspiciousLinks = hasExternalLinks && !hasGithubLinks;
|
||||||
|
|
||||||
// Check for suspicious patterns
|
// Check for suspicious patterns
|
||||||
const foundPatterns = suspiciousPatterns.filter(pattern =>
|
const foundPatterns = suspiciousPatterns.filter(pattern =>
|
||||||
body.includes(pattern)
|
body.includes(pattern)
|
||||||
);
|
);
|
||||||
|
|
||||||
if (foundPatterns.length > 0 || suspiciousLinks) {
|
if (foundPatterns.length > 0 || suspiciousLinks) {
|
||||||
// Create a warning comment
|
try {
|
||||||
const warningMessage = `⚠️ Potential scam detected in comment by ${author}:
|
// Create a warning comment
|
||||||
- Suspicious patterns found: ${foundPatterns.join(', ')}
|
await github.rest.issues.createComment({
|
||||||
${suspiciousLinks ? '- Contains external links' : ''}
|
owner: context.repo.owner,
|
||||||
|
repo: context.repo.repo,
|
||||||
|
issue_number: context.payload.issue ? context.payload.issue.number : context.payload.pull_request.number,
|
||||||
|
body: warningMessage
|
||||||
|
});
|
||||||
|
} catch (e) {
|
||||||
|
console.log('Failed to create comment:', e);
|
||||||
|
}
|
||||||
|
|
||||||
@${context.repo.owner} Please review this comment.`;
|
try {
|
||||||
|
// Add 'potential-scam' label
|
||||||
await github.rest.issues.createComment({
|
await github.rest.issues.addLabels({
|
||||||
owner: context.repo.owner,
|
owner: context.repo.owner,
|
||||||
repo: context.repo.repo,
|
repo: context.repo.repo,
|
||||||
issue_number: context.payload.issue ? context.payload.issue.number : context.payload.pull_request.number,
|
issue_number: context.payload.issue ? context.payload.issue.number : context.payload.pull_request.number,
|
||||||
body: warningMessage
|
labels: ['potential-scam']
|
||||||
});
|
});
|
||||||
|
} catch (e) {
|
||||||
// Add 'potential-scam' label
|
console.log('Failed to add label:', e);
|
||||||
await github.rest.issues.addLabels({
|
}
|
||||||
owner: context.repo.owner,
|
}
|
||||||
repo: context.repo.repo,
|
} catch (e) {
|
||||||
issue_number: context.payload.issue ? context.payload.issue.number : context.payload.pull_request.number,
|
console.log('Workflow error:', e);
|
||||||
labels: ['potential-scam']
|
// Still mark as failure but with more context
|
||||||
});
|
core.setFailed(`Workflow failed: ${e.message}`);
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user