<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:

def insult(rest):
	"Generate a random insult from datahamster"
	# not supplying any style will automatically redirect to a random
	url = 'http://autoinsult.datahamster.com/'
	ins_type = random.randrange(4)
	ins_url = url + "?style={ins_type}".format(**locals())
	insre = re.compile('<div class="insult" id="insult">(.*?)</div>')
	resp = requests.get(ins_url)
	resp.raise_for_status()
	insult = insre.search(resp.text).group(1)
	if not insult:
		return
	if rest:
		insultee = rest.strip()
		karma.Karma.store.change(insultee, -1)
		if ins_type in (0, 2):
			cinsre = re.compile(r'\b(your)\b', re.IGNORECASE)
			insult = cinsre.sub("%s's" % insultee, insult)
		elif ins_type in (1, 3):
			cinsre = re.compile(r'^([TY])')
			insult = cinsre.sub(
				lambda m: "%s, %s" % (
					insultee, m.group(1).lower()), insult)
	return insult