__module_name__ = "bot connect ignore"
__module_version__ = "1.0"
__module_description__ = "ignore snomask notices about annoying bots that connect every minute..."

import xchat
import re

def check(word, word_eol, userdata):
	
	connectnotices = ["CONNECT", "REMOTECONNECT", "CONNECT:", "REMOTECONNECT:"]
	quitnotices = ["QUIT", "REMOTEQUIT", "QUIT:", "REMOTEQUIT:"]
	# please add extra notices you may like to be put up to ignore
	customnotices = []
	
	# please add more in this if you have a bot you wish to ignore
			# uses partial regex matching (re.search)
	ignorelist = ['scrawl[0-9]{0,5}!scrawl@data.searchirc.org']
	
	if (len(word) >= 7) and (((word[4] in connectnotices) or (word[4] in quitnotices)) or ((word[4][:-1] in connectnotices) or (word[4][:-1] in quitnotices)) or ((word[4][:-1] in customnotices) or (word[4][:-1] in customnotices))):
		i = len(word) - 1
		while(i > 4):
			for bot in ignorelist:
				try:
					if re.search(bot, word[i]).group(0) != None:
						return xchat.EAT_XCHAT
				except:
					None
			i = i - 1
		
	return xchat.EAT_NONE

xchat.hook_server('NOTICE', check)
print(">>> Annoying bot connect notices are being hidden\n  >>> If you wish to add to the bot connect ignore list, edit the plugin's ignorelist.")

