Skip to content

feat: Add Admin Panel pattern for Telegram bots #18

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jul 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
89 changes: 89 additions & 0 deletions .github/labeler.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
# Configuration for auto-labeling PRs based on changed files

# Core changes
core:
- changed-files:
- any-glob-to-any-file:
- 'src/core/**/*'
- 'src/interfaces/**/*'

# Connector changes
connectors:
- changed-files:
- any-glob-to-any-file:
- 'src/connectors/**/*'
- 'src/adapters/**/*'

# Documentation
documentation:
- changed-files:
- any-glob-to-any-file:
- '**/*.md'
- 'docs/**/*'
- 'examples/**/*'

# Tests
testing:
- changed-files:
- any-glob-to-any-file:
- '**/__tests__/**/*'
- '**/*.test.ts'
- '**/*.spec.ts'
- 'vitest.config.ts'

# CI/CD
ci/cd:
- changed-files:
- any-glob-to-any-file:
- '.github/**/*'
- '.gitignore'
- '.npmrc'

# Dependencies
dependencies:
- changed-files:
- any-glob-to-any-file:
- 'package.json'
- 'package-lock.json'
- 'tsconfig.json'

# Platform specific
platform/telegram:
- changed-files:
- any-glob-to-any-file:
- 'src/adapters/telegram/**/*'
- 'src/connectors/messaging/telegram/**/*'

platform/discord:
- changed-files:
- any-glob-to-any-file:
- 'src/connectors/messaging/discord/**/*'

platform/cloudflare:
- changed-files:
- any-glob-to-any-file:
- 'wrangler.toml'
- 'src/core/cloud/cloudflare/**/*'

# Contributions
contribution:
- changed-files:
- any-glob-to-any-file:
- 'contrib/**/*'
- 'src/contrib/**/*'

# Performance
performance:
- changed-files:
- any-glob-to-any-file:
- 'src/patterns/**/*'
- 'src/lib/cache/**/*'
- '**/performance/**/*'

# Security
security:
- changed-files:
- any-glob-to-any-file:
- 'src/middleware/auth*.ts'
- 'src/core/security/**/*'
- '**/auth/**/*'
189 changes: 189 additions & 0 deletions .github/workflows/pr-validation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,189 @@
name: PR Validation

on:
pull_request:
types: [opened, synchronize, reopened]

jobs:
validate-contribution:
name: Validate Contribution
runs-on: ubuntu-latest

steps:
- name: Checkout PR
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '22'
cache: 'npm'

- name: Install Dependencies
run: npm ci

- name: TypeScript Check
run: npm run typecheck

- name: ESLint Check
run: npm run lint

- name: Run Tests
run: npm test

- name: Check for Conflicts
run: |
# Check if PR has conflicts with other open PRs
gh pr list --state open --json number,files -q '.[] | select(.number != ${{ github.event.pull_request.number }})' > other_prs.json

# Get files changed in this PR
gh pr view ${{ github.event.pull_request.number }} --json files -q '.files[].path' > this_pr_files.txt

# Check for overlapping files
node -e "
const fs = require('fs');
const otherPRs = JSON.parse(fs.readFileSync('other_prs.json', 'utf8') || '[]');
const thisPRFiles = fs.readFileSync('this_pr_files.txt', 'utf8').split('\n').filter(Boolean);

const conflicts = [];
for (const pr of otherPRs) {
const prFiles = (pr.files || []).map(f => f.path);
const overlapping = thisPRFiles.filter(f => prFiles.includes(f));
if (overlapping.length > 0) {
conflicts.push({ pr: pr.number, files: overlapping });
}
}

if (conflicts.length > 0) {
console.log('⚠️ Potential conflicts detected:');
conflicts.forEach(c => {
console.log(\` PR #\${c.pr}: \${c.files.join(', ')}\`);
});
process.exit(1);
}
"
env:
GH_TOKEN: ${{ github.token }}
continue-on-error: true

- name: Check Architecture Compliance
run: |
# Check for platform-specific imports in core modules
echo "Checking for platform-specific imports..."

# Look for direct platform imports in src/core
if grep -r "from 'grammy'" src/core/ 2>/dev/null || \
grep -r "from 'discord.js'" src/core/ 2>/dev/null || \
grep -r "from '@slack/'" src/core/ 2>/dev/null; then
echo "❌ Found platform-specific imports in core modules!"
echo "Please use connector pattern instead."
exit 1
fi

echo "βœ… No platform-specific imports in core modules"

- name: Check for Any Types
run: |
# Check for 'any' types in TypeScript files
echo "Checking for 'any' types..."

# Exclude test files and node_modules
if grep -r ": any" src/ --include="*.ts" --include="*.tsx" \
--exclude-dir="__tests__" --exclude-dir="node_modules" | \
grep -v "eslint-disable" | \
grep -v "@typescript-eslint/no-explicit-any"; then
echo "❌ Found 'any' types without proper justification!"
echo "Please use proper types or add eslint-disable with explanation."
exit 1
fi

echo "βœ… No unjustified 'any' types found"

- name: Generate Contribution Report
if: always()
run: |
echo "## πŸ“Š Contribution Analysis" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY

# Count changes
ADDED=$(git diff --numstat origin/main..HEAD | awk '{sum+=$1} END {print sum}')
DELETED=$(git diff --numstat origin/main..HEAD | awk '{sum+=$2} END {print sum}')
FILES_CHANGED=$(git diff --name-only origin/main..HEAD | wc -l)

echo "### Changes Summary" >> $GITHUB_STEP_SUMMARY
echo "- Files changed: $FILES_CHANGED" >> $GITHUB_STEP_SUMMARY
echo "- Lines added: $ADDED" >> $GITHUB_STEP_SUMMARY
echo "- Lines deleted: $DELETED" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY

# Detect contribution type
if git log --oneline origin/main..HEAD | grep -i "perf:"; then
echo "πŸš€ **Type**: Performance Optimization" >> $GITHUB_STEP_SUMMARY
elif git log --oneline origin/main..HEAD | grep -i "fix:"; then
echo "πŸ› **Type**: Bug Fix" >> $GITHUB_STEP_SUMMARY
elif git log --oneline origin/main..HEAD | grep -i "feat:"; then
echo "✨ **Type**: New Feature" >> $GITHUB_STEP_SUMMARY
else
echo "πŸ“ **Type**: Other" >> $GITHUB_STEP_SUMMARY
fi

- name: Comment on PR
if: failure()
uses: actions/github-script@v7
with:
script: |
const message = `## ❌ Validation Failed

Please check the [workflow run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) for details.

Common issues:
- TypeScript errors or warnings
- ESLint violations
- Failing tests
- Platform-specific imports in core modules
- Unjustified \`any\` types

Need help? Check our [Contributing Guide](https://github.com/${{ github.repository }}/blob/main/CONTRIBUTING.md).`;

github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: message
});

label-pr:
name: Auto-label PR
runs-on: ubuntu-latest
if: success()

steps:
- name: Label based on files
uses: actions/labeler@v5
with:
repo-token: '${{ secrets.GITHUB_TOKEN }}'
configuration-path: .github/labeler.yml

- name: Label based on title
uses: actions/github-script@v7
with:
script: |
const title = context.payload.pull_request.title.toLowerCase();
const labels = [];

if (title.includes('perf:')) labels.push('performance');
if (title.includes('fix:')) labels.push('bug');
if (title.includes('feat:')) labels.push('enhancement');
if (title.includes('docs:')) labels.push('documentation');
if (title.includes('test:')) labels.push('testing');

if (labels.length > 0) {
await github.rest.issues.addLabels({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
labels: labels
});
}
12 changes: 12 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -167,10 +167,22 @@ See [Easy Contribute Guide](docs/EASY_CONTRIBUTE.md) for detailed instructions.

## πŸ“š Resources

### Contribution Guides

- [Easy Contribute Guide](docs/EASY_CONTRIBUTE.md) - Automated contribution tools
- [Contribution Review Checklist](docs/CONTRIBUTION_REVIEW_CHECKLIST.md) - For maintainers
- [Successful Contributions](docs/SUCCESSFUL_CONTRIBUTIONS.md) - Examples and hall of fame
- [Development Workflow](docs/DEVELOPMENT_WORKFLOW.md) - Detailed development guide

### Technical Documentation

- [Cloudflare Workers Documentation](https://developers.cloudflare.com/workers/)
- [grammY Documentation](https://grammy.dev/)
- [TypeScript Handbook](https://www.typescriptlang.org/docs/handbook/)
- [Telegram Bot API](https://core.telegram.org/bots/api)

## πŸ† Recent Successful Contributions

Check out our [Successful Contributions Gallery](docs/SUCCESSFUL_CONTRIBUTIONS.md) to see real examples of community contributions that made Wireframe better!

Thank you for contributing to make Wireframe the best universal AI assistant platform!
Loading
Loading