Thread Rating:
  • 1 Vote(s) - 4 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Spam Killer [XCHAT PYTHON]
#1
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()

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)
[Image: sig.php]
Reply


Messages In This Thread
Spam Killer [XCHAT PYTHON] - by Nyx- - 12-16-2009, 07:54 PM
RE: Spam Killer [XCHAT PYTHON] - by Gaijin - 12-16-2009, 11:08 PM
RE: Spam Killer [XCHAT PYTHON] - by Nyx- - 12-17-2009, 05:49 PM
RE: Spam Killer [XCHAT PYTHON] - by Gaijin - 12-18-2009, 05:15 PM
RE: Spam Killer [XCHAT PYTHON] - by Nyx- - 12-18-2009, 08:02 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Python Help Dεlluzion 3 1,793 09-30-2019, 12:59 AM
Last Post: samsmith001
  Simple Python Python Compiler Canoris 21 8,480 06-01-2011, 06:30 PM
Last Post: Filefinder
  Python 2 vs 3? Jake 8 2,271 12-11-2010, 04:13 PM
Last Post: Bursihido
  Python help Kharnage 2 767 02-12-2010, 09:07 PM
Last Post: Kharnage
  "==" and "is" in Python Canoris 1 755 02-07-2010, 03:55 PM
Last Post: uber1337

Forum Jump:


Users browsing this thread: 1 Guest(s)