File: antiroot.py

package info (click to toggle)
xchat 1.8.9-0woody3
  • links: PTS
  • area: main
  • in suites: woody
  • size: 6,220 kB
  • ctags: 3,296
  • sloc: ansic: 37,535; sh: 2,672; perl: 578; makefile: 387; asm: 387; sed: 93; python: 76
file content (21 lines) | stat: -rw-r--r-- 630 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import XChat
import string

def join_handler(name, flags, args):
	serv = args[0].get_server()
	chan = args[1].get_string()
	nick = args[2].get_string()
	ip = args[3].get_string()
	if string.find (ip, "root@") != -1:
		try:
			sess = XChat.Session()
			sess.set(serv.info()['hostname'], serv.info()['port'], serv.info()['nick'], chan)
		except LookupError:
			i.get_current_session().print_text("anti-root: Internal error")
			return
	sess.handle_cmd (nick + ": Don't IRC as root!")
	return

i = XChat.XChat()
i.register ("anti-root", "Send a message to someone when they join as *!root@*")
i.hook_signal ("XP_JOIN", join_handler)