Untitled

mail@pastecode.io avatar
unknown
python
2 years ago
1.9 kB
2
Indexable
Never
import time
import hexchat

__module_name__ = "Idlers kicker"
__module_version__ = "1.0"
__module_description__ = "This script will kick idlers automatically"

maxidletime = 24 # hour
channel = ""

channelName = hexchat.get_info("channel")

globhelp = "Help: /idle check : check the current max idle time\n      /idle set HOUR : to change the max idle time\n      /idle #channel : will check for idlers in the specified channel"

def idle(word, word_eol, userdata):
	global maxidletime, channel
	try:
		if word[1] == "set":
			try:
				maxidletime = int(word[2])
				hexchat.prnt("Max idle time set to %s hours" % (maxidletime))
			except IndexError:
				hexchat.prnt("Usage: /idle set HOUR")
		elif word[1] == "check":
			hexchat.prnt("Max idle time: %s hours" % (maxidletime))
		else:
			channel = word[1]
	except IndexError:
		hexchat.prnt(globhelp)
	return hexchat.EAT_ALL

hexchat.hook_command("idle", idle, help="Check for idlers in the specified channel")

def whoisIdleLine(word, word_eol, userdata):
	context = hexchat.find_context(channel=channel)
	if hexchat.get_info('network') == "AnonOps":
		idleHour = word[1].split(':')[0]
		if int(idleHour) > maxidletime:
			send("idle", "%s\t\x0312My idle time is: \x0303%s \x034\x02[IDLE LIMIT REACHED!]" % (word[0], word[1]))
			context.command("kick %s idle" % (word[0]))

		else:
			send("idle", "<%s>\t\x0312My idle time is: \x0303%s" % (word[0], word[1]))

hexchat.hook_print("WhoIs Idle Line with Signon", whoisIdleLine)

def send(window, message):
	window = "$" + window
	context = hexchat.find_context(server="AnonOps", channel=window)
	if context:
		context.prnt(message)
		context.command("gui color 2")
	else:
		hexchat.command("query -nofocus " + window)
		context = hexchat.find_context(channel=window)
		context.prnt(message)
		context.command("gui color 2")

#idlecheck()