12-16-2009, 07:54 PM
If a message is the same the last 5 lines, and if the names are different, then it will put the message into a KOS(kill on site) list for 3 minutes and whoever says the message during that time will automatically get killed. Hopefully will be useful to help combat people who uses bots to spam the IRC since they normally will enter a static message in the spam.
I plan on adding stuff for changing the default time, adding kills on text yourself, viewing the bantexts list, removing items in the list easily, adding unlimited time text kills when adding them yourself. All using an xchat.hook_command()
I plan on adding stuff for changing the default time, adding kills on text yourself, viewing the bantexts list, removing items in the list easily, adding unlimited time text kills when adding them yourself. All using an xchat.hook_command()
Code:
import xchat, threading
__module_name__ = "Bot Kill"
__module_version__ = '1.0'
__module_description__ = "Kills multiple spammers using same message"
lastfour = []
bantexts = []
times = []
def addsec():
timedata = threading.local()
if times[len(times)-1]['time'] == 0:
global b
b = len(times)-1
timedata.pos = b
times[timedata.pos]['time'] += 1
if not times[timedata.pos]['time'] == 179:
t = threading.Timer(1.0,addsec)
t.start()
def SpamCheck(word, word_eol, userdata):
num = 0
cont = True
name, msg = word[0], word[1]
if bantexts:
if msg in bantexts:
xchat.command('KILL '+name+' SpamCheck Script')
cont = False
lastfour.append([name,msg])
if cont:
if len(lastfour) == 5:
del lastfour[0]
while num <= len(lastfour)-2:
if num == 2:
if not name == lastfour[2][0]:
bantexts.append(msg)
times.append({'time':0})
addsec()
xchat.command('echo Adding KOS for "'+msg+'", will remove in 3 minutes.')
xchat.command('KILL '+name+' SpamCheck Script')
xchat.hook_timer(180000,time)
num += 1
if msg == lastfour[num][1]:
num += 1
else:
break
def time(userdata):
global bantexts
xchat.command('echo Removed KOS for "'+bantexts[0]+'".')
del bantexts[0]
del times[0]
return xchat.EAT_NONE
def Menu(word, word_eol, userdata):
cont = False
try:#FOR ADDING ON OTHER OPTIONS NOT YET PRESENT
if word[1] == '-a' | word[1] == '-r':
cont = True
except:
xchat.command('echo --------Kill List--------')
if len(bantexts) == 0:
xchat.command('echo *No kill texts currently.')
else:
for ban in bantexts:
xchat.command('echo *Text: "'+ban+'".')
xchat.command('echo **Time left: '+str(180-times[bantexts.index(ban)]['time'])+' seconds.')
xchat.command('echo -------------------------')
xchat.hook_command('sc', Menu)
xchat.hook_print('Channel Message', SpamCheck)
xchat.hook_print('Channel Action Hilight', SpamCheck)
xchat.hook_print('Channel Msg Hilight', SpamCheck)