Advertisement
gaz_lloyd

Untitled

Jan 11th, 2012
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.28 KB | None | 0 0
  1. __module_name__ = "PhishDetectionWR"
  2. __module_version__ = "1.0.10"
  3. __module_description__ = "Detects phishing links posted to #wikia-runescape and kick-bans users who post them"
  4.  
  5. # by A_proofreader (wikia/A-proofreader) of Freenode #wikia-runescape
  6.  
  7. import re
  8. import xchat
  9.  
  10. # THE FOLLOWING IS CONFIGURABLE
  11. phishing_regex = re.compile(r" (http://|www.)[^/ ]*\.runescape\.com\.[a-z0-9]" # unexpected dot after .com
  12.   + "|runescape\.co\.(?!uk)" # runescape.co.tld, excluding runescape.co.uk (legit)
  13.   + "| (http://|www.)[^/ ]*(-runescape|runescape-)[^/ ]*/" # dashes instead of dots at expected places
  14.   , re.IGNORECASE)
  15.  
  16. def phishtrigger(word, word_eol, userdata):
  17.   # :Source PRIVMSG Target :Message which may contain spaces
  18.   # ^0      ^1      ^2      ^3      ^4[etc.] or use word_eol[3]
  19.   if word[2].lower() == "#wikia-runescape" and phishing_regex.search(word_eol[3]) is not None:
  20.     # xchat.command("QUOTE MODE %s +b *!*@%s" % (word[2], word[0].partition("@")[2]))
  21.     #       MODE channel +b *!*@<what's after the @ in source>
  22.     xchat.command("QUOTE KICK %s %s :%s" % (word[2], word[0].partition("!")[0][1:], "Phishing link detected"))
  23.     #       KICK channel <nick, between : and ! excl.> :Phishing link detected
  24.   return xchat.EAT_NONE
  25.  
  26. xchat.hook_server("PRIVMSG", phishtrigger)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement