]> jfr.im git - irc/quakenet/newserv.git/blob - lua/lib/minute_count.lua
CHANSERV: tell user when they can't attempts to auth any more, and drop max attempts...
[irc/quakenet/newserv.git] / lua / lib / minute_count.lua
1 MinuteCount = class(function(obj, minutes)
2 obj.minutes = minutes
3 obj.data = {}
4 obj.current = 0
5 end)
6
7 function MinuteCount:add()
8 self.current = self.current + 1
9 end
10
11 function MinuteCount:moveon()
12 table.insert(self.data, 0, self.current)
13 table.remove(self.data, self.minutes)
14 self.current = 0
15 end
16
17 function MinuteCount:sum()
18 local sum = self.current
19 for _, v in ipairs(self.data) do
20 sum = sum + v
21 end
22
23 return sum
24 end