X-Chat Custom Kick Commands 0.7

X-Chat Custom Kick Commands 0.7


__module_name__ = "customkicks"
__module_version__ = "0.7"
__module_description__ = "Custom kick commands for convenience."

# Explain how it all works, you say? Very well, good sir!
# Each type of kick is listed here on a new line in 'type':'message' format.
# Every line except the last one MUST have a comma on the end (,)
# The spacing is not important and is currently set to my preference..
# Remember that " cannot be used normally in your reasons.. You need to use \" if you really want to do it.
# Never make a kick type start with b.
#
# As an example, if a type of kick is 'pg' then you would type /kpg nickname to kick them out.
kickreasons = {
'd' : "This is not a pick up room or a dating service.",
'l' : "Please watch the language.",
'pg': "This is a PG-rated chat.",
'pm': "Please quit asking for random PMs. ",
'r' : "Please respect all chatters."
}

import xchat

def display_kicks(word, word_eol, userdata):
xchat.prnt("Displaying %d kick messages:" % (len(kickreasons)))
for item in kickreasons:
xchat.prnt("%-2s => %s" % (item, kickreasons[item]))
xchat.prnt("End of list.")
return xchat.EAT_ALL

def process_kickban(word, word_eol, userdata):
ctx = xchat.get_context()
target = ctx.get_info('channel')
reason = word[0][2:] if word[0][1] == 'b' else word[0][1:]
if reason in kickreasons:
if target[:1] == '#':
if len(word) >= 2:
if (word[0][1] == 'b'):
ctx.command('BAN %s 1' % word[1])
ctx.command('QUOTE KICK %s %s :%s' % (target, word[1], kickreasons[reason]))
else:
ctx.prnt('You didn\'t specify a nickname!')
else:
ctx.prnt('You need to be in a chat room to use that command.')
else:
ctx.prnt('You have somehow managed to trigger a non-existant custom kick (%s). Sorry.' % (word[0]))
return xchat.EAT_ALL

def load():
# Each kick message must be manually added as an event hook since only static commands may be monitored.
for item in kickreasons:
xchat.hook_command('k' + item, process_kickban, help='Convenient kick shortcut (customkicks)')
xchat.hook_command('kb' + item, process_kickban, help='Convenient kick shortcut (customkicks)')
print 'Gummo\'s custom kick script v' + __module_version__ + ' loaded.'

def unload(userdata):
print 'Gummo\'s custom kick script v' + __module_version__ + ' unloaded.'

xchat.hook_command("k",display_kicks,help='Displays all custom kick types and reasons (customkicks)')
xchat.hook_command("kb",display_kicks,help='Displays all custom kick types and reasons (customkicks)')
xchat.hook_unload(unload)
load()

No comments:

Post a Comment