--- a/rollbot.py Thu May 19 21:08:43 2016 +0800
+++ b/rollbot.py Sun May 22 21:48:18 2016 +0800
return '(%s) = %d' % (' + '.join('%d' % r for r in rolls), total)
+ return '%s or %s <1st-option>[ or] <2nd-option>' % (self.name, self.name)
+ def respond(self, words, message):
+ option = self.flip(('heads', 'tails'))
+ option = self.flip(words[1:])
+ elif len(words) == 4 and words[2].lower() == 'or':
+ option = self.flip((words[1], words[3]))
+ return '%s usage: %s' % (self.name, self.usage())
+ return self.format(option)
+ def flip(self, options):
+ return random.choice(options)
+ def format(self, option):
self.add_event_handler('session_start', self.start)