mirror of
https://github.com/teloxide/teloxide.git
synced 2025-03-14 11:44:04 +01:00
Remove git dependency
This commit is contained in:
parent
8e011b7e60
commit
6abf571c96
2 changed files with 25 additions and 27 deletions
|
@ -34,8 +34,7 @@ thiserror = "1.0.20"
|
|||
once_cell = "1.5.0"
|
||||
never = "0.1.0"
|
||||
|
||||
# FIXME(waffle): use crates.io once published
|
||||
vecrem = { git = "https://github.com/WaffleLapkin/vecrem", rev = "6b9b6f42342df8b75548c6ed387072ff235429b1" }
|
||||
vecrem = { version = "0.1", optional = true }
|
||||
|
||||
[features]
|
||||
default = []
|
||||
|
@ -47,7 +46,7 @@ default = []
|
|||
nightly = []
|
||||
|
||||
# Throttling bot adaptor
|
||||
throttle = []
|
||||
throttle = ["vecrem"]
|
||||
|
||||
# CacheMe bot adaptor
|
||||
cache_me = []
|
||||
|
|
|
@ -267,34 +267,33 @@ async fn worker(limits: Limits, mut queue_rx: mpsc::Receiver<(Id, Sender<Never>)
|
|||
*hchats_s.entry(*chat).or_insert(0) += 1;
|
||||
}
|
||||
|
||||
let mut queue_rem = queue.removing();
|
||||
while let Some(entry) = queue_rem.next() {
|
||||
let chat = &entry.value().0;
|
||||
let cond = {
|
||||
hchats_s.get(chat).copied().unwrap_or(0) < limits.chat_s
|
||||
&& hchats.get(chat).copied().unwrap_or(0) < limits.chat_m
|
||||
};
|
||||
{
|
||||
let mut queue_rem = queue.removing();
|
||||
while let Some(entry) = queue_rem.next() {
|
||||
let chat = &entry.value().0;
|
||||
let cond = {
|
||||
hchats_s.get(chat).copied().unwrap_or(0) < limits.chat_s
|
||||
&& hchats.get(chat).copied().unwrap_or(0) < limits.chat_m
|
||||
};
|
||||
|
||||
if cond {
|
||||
{
|
||||
*hchats_s.entry(*chat).or_insert(0) += 1;
|
||||
*hchats.entry(*chat).or_insert(0) += 1;
|
||||
history.push_back((*chat, Instant::now()));
|
||||
if cond {
|
||||
{
|
||||
*hchats_s.entry(*chat).or_insert(0) += 1;
|
||||
*hchats.entry(*chat).or_insert(0) += 1;
|
||||
history.push_back((*chat, Instant::now()));
|
||||
}
|
||||
|
||||
// This will close the channel unlocking associated request
|
||||
drop(entry.remove());
|
||||
|
||||
// We've "sent" 1 request, so now we can send 1 less
|
||||
allowed -= 1;
|
||||
if allowed == 0 {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// This will close the channel unlocking associated request
|
||||
drop(entry.remove());
|
||||
|
||||
// We've "sent" 1 request, so now we can send 1 less
|
||||
allowed -= 1;
|
||||
if allowed == 0 {
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
entry.skip();
|
||||
}
|
||||
}
|
||||
drop(queue_rem);
|
||||
|
||||
// It's easier to just recompute last second stats, instead of keeping
|
||||
// track of it alongside with minute stats, so we just throw this away.
|
||||
|
|
Loading…
Add table
Reference in a new issue