import random
import re

class ChooseModule:
	def __init__(self, circa):
		self.circa = circa

		self.listeners = {
			"cmd.choose": [self.choose],
			"cmd.roll": [self.roll],
		}

	def choose(self, fr, to, params):
		params = " ".join(params).strip()
		if len(params) == 0:
			self.circa.notice(fr, "choose <choice>, ... or <choice>")
		else:
			choices = re.split(r"\s*,\s*|\bor\b", " ".join(params))
			self.circa.say(to, "{0}: {1}".format(fr, random.choice(choices)))

	def roll(self, fr, to, params):
		print(fr, to, params)
		dice = params[0]
		if dice.count("d") > 1:
			self.circa.notice(fr, "roll <n>d<n>")
		a, b = dice.split("d")[0], 6
		if "d" in dice:
			b = dice.split("d")[1]
		numdice, amtdice = 1, 6
		try:
			numdice = int(a)
		except ValueError:
			pass
		try:
			amtdice = int(b)
		except ValueError:
			pass
		self.circa.say(to, "{0}: {1}".format(fr, ", ".join(
			[str(random.randrange(1, amtdice)) for i in range(numdice)])))

module = ChooseModule

@@ -503,32 +503,8 @@
 s):%0A
-%09%09print(fr, to, params)%0A
 %09%09di

remove logging from choose