All pastes #395426 Raw Edit

Miscellany

public text v1 · immutable
·published 2007-03-15 00:57 UTC
rendered paste body
# aquote - Used to replay quotes said in the channel
def aquote(word, word_eol, userdata):
	p = re.compile('^!aquote')
	m = p.search(word[1])

	if m and hasAccess(word[0], 10):
		arguments = word[1].split(" ")
		try:
			quoteNumber = arguments[1]
			try:
				quoteFile = open(quotefile, 'r')
				Quotes = quoteFile.readlines(); quoteFile.close()
				Quote = Quotes[int(quoteNumber) - 1]
				xchat.command("say " + Quote)
			except IndexError:
				xchat.command("say " + word[0] + ": I do not have that quote.")

		except IndexError:
			quoteFile = open(quotefile, 'r')
			Quotes = quoteFile.read(); quoteFile.close()
			quoteNumber = random.randint(0, len(Quotes) - 1)
			xchat.command("say Quote #" + str(quoteNumber) + ": " + Quote)

xchat.hook_print("Channel Message", aquote)
xchat.hook_print("Private Message to Dialog", aquote)
xchat.hook_print("Private Message", aquote)