-
Notifications
You must be signed in to change notification settings - Fork 0
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
WIP rate-limiting as middleware per user #2
base: main
Are you sure you want to change the base?
Conversation
83f9fb4
to
87147d8
Compare
@@ -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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider using a more descriptive name for your repository. The name ai-codereviewer
could be more specific to reflect the functionality of the repository.
OPENAI_API_MODEL: "gpt-4" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The model gpt-4
does not exist. Please use a valid model name.
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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a potential for a panic here if the type assertion .(*user.User)
fails. It would be safer to use the comma ok
idiom to check if the type assertion was successful.
return func(c telebot.Context) error { | ||
u := c.Get(string(user.UserInfoContextKey)).(*user.User) | ||
|
||
if u == nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This check for u == nil
is redundant as it will never be nil
if the type assertion at line 12 fails. It would be better to remove this check.
No description provided.