oirc/old_modules/prevention.py

37 lines
1.0 KiB
Python
Raw Normal View History

2020-08-14 17:37:03 +00:00
import random
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]
2020-08-17 23:09:44 +00:00
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']):
2020-08-14 17:37:03 +00:00
# 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:
2020-08-14 17:46:27 +00:00
await self.set_mode(c,self.mutesyntax[0],self.mutesyntax[1].format(n+'!*@*'))
2020-08-14 17:53:01 +00:00
if self.wlevel[n] > 10:
2020-08-14 17:37:03 +00:00
self.wlevel[n] = 0
2020-08-14 17:46:27 +00:00
await self.kick(c,n,'stop spamming thanks')
2020-08-14 17:37:03 +00:00
async def init(self):
self.plog = {}
self.wlevel = {}
self.mutesyntax = ['+b','m:{}'] # ['+q','{}'] on freenode
self.rawm['preventionlog'] = plogger
2020-08-14 17:37:03 +00:00