oirc/old_modules/prevention.py

43 lines
1.2 KiB
Python
Raw Normal View History

2020-08-14 17:37:03 +00:00
import random
2022-01-27 02:22:42 +00:00
async def plogger(self, c, n, m):
if c not in self.plog:
self.plog[c] = []
self.plog[c].append([n, m])
if len(self.plog[c]) > 50:
del self.plog[c][:-50]
if (
c in self.channels
and "o" in self.channels[c]["modes"]
and self.nickname in self.channels[c]["modes"]["o"]
and (
"v" not in self.channels[c]["modes"]
or n not in self.channels[c]["modes"]["v"]
)
):
# fun time
umc = len([i for i in self.plog[c][-10:] if i[0] == n])
# await self.message(c,str(umc))
if umc > 6:
if n in self.wlevel:
self.wlevel[n] += 1
else:
self.wlevel[n] = 0
if self.wlevel[n] == 3:
await self.set_mode(
c, self.mutesyntax[0], self.mutesyntax[1].format(n + "!*@*")
)
if self.wlevel[n] > 10:
self.wlevel[n] = 0
await self.kick(c, n, "stop spamming thanks")
2020-08-14 17:37:03 +00:00
async def init(self):
2022-01-27 02:22:42 +00:00
self.plog = {}
self.wlevel = {}
self.mutesyntax = ["+b", "m:{}"] # ['+q','{}'] on freenode
self.rawm["preventionlog"] = plogger