File tree Expand file tree Collapse file tree 2 files changed +30
-2
lines changed Expand file tree Collapse file tree 2 files changed +30
-2
lines changed Original file line number Diff line number Diff line change 69
69
'log_errors ' => [
70
70
'500 '
71
71
],
72
+
73
+ /*
74
+ | --------------------------------------------------------------------------
75
+ | Rate Limiter max attempts
76
+ | --------------------------------------------------------------------------
77
+ |
78
+ | This option defines the maximum number of attempts to send a message
79
+ | to the Telegram Bot API. The default value is 1.
80
+ | Telegram log will send one exemplary message per day.
81
+ |
82
+ */
83
+
84
+ 'max_attempts ' => 1 ,
85
+
86
+ /*
87
+ | --------------------------------------------------------------------------
88
+ | Rate Limiter decay seconds
89
+ | --------------------------------------------------------------------------
90
+ |
91
+ | This option defines the number of seconds to wait before retrying to
92
+ | send a message to the Telegram Bot API. The default value is 1 day.
93
+ |
94
+ */
95
+
96
+ 'decay_seconds ' => 60 * 60 * 24 ,
72
97
];
Original file line number Diff line number Diff line change @@ -46,13 +46,16 @@ public function setChatId(string $chatId): self
46
46
protected function rateLimiter ($ message ): bool
47
47
{
48
48
$ key = md5 ('telegram_logger ' . $ message );
49
+ $ decaySeconds = config ('telegram-logger.decay_seconds ' , 60 * 60 * 24 );
50
+ $ maxAttempts = config ('telegram-logger.max_attempts ' , 1 );
49
51
50
- if (RateLimiter::tooManyAttempts ($ key , 5 )) {
52
+ if (RateLimiter::tooManyAttempts ($ key , $ maxAttempts )) {
51
53
info ('Telegram rate limit exceeded ' );
54
+
52
55
return false ;
53
56
}
54
57
55
- RateLimiter::hit ($ key );
58
+ RateLimiter::hit ($ key, $ decaySeconds );
56
59
57
60
return true ;
58
61
}
You can’t perform that action at this time.
0 commit comments