Skip to content

Commit

Permalink
WIP rate-limiting as middleware per user
Browse files Browse the repository at this point in the history
  • Loading branch information
NikitosnikN committed Jun 16, 2024
1 parent 1ef35d4 commit 87147d8
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/gpt_pr_review.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ jobs:
uses: actions/checkout@v3

- name: AI Code Reviewer
uses: your-username/ai-code-reviewer@main
uses: freeedcom/ai-codereviewer@v2.7.0
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
OPENAI_API_MODEL: "gpt-4o"
exclude: "**/*.json, **/*.md, **/*.yaml"
OPENAI_API_MODEL: "gpt-4"
exclude: "**/*.json, **/*.md, **/*.yaml"
23 changes: 23 additions & 0 deletions internal/middleware/ratelimit.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package middleware

import (
"github.com/NikitosnikN/go-claude-tg-bot/internal/domain/user"
"gopkg.in/telebot.v3"
)

// RateLimit middleware for tg bot
func RateLimit(requestsPerSecond int) telebot.MiddlewareFunc {
return func(next telebot.HandlerFunc) telebot.HandlerFunc {
return func(c telebot.Context) error {
u := c.Get(string(user.UserInfoContextKey)).(*user.User)

if u == nil {
return next(c)
}

// TODO implement rate limiter

return next(c)
}
}
}

0 comments on commit 87147d8

Please sign in to comment.