diff --git a/LIST_COMMANDS.md b/LIST_COMMANDS.md index 7eeca21..560a83d 100644 --- a/LIST_COMMANDS.md +++ b/LIST_COMMANDS.md @@ -252,7 +252,7 @@ # Other commands... * Pad & Title available to anyone * FuckOff/ComeBack & SetPad available only to GLOBAL_USERS and chan's USERS - * **Exclude regexp :** `'(fuckoff|comeback|.*pad|title)'` + * **Exclude regexp :** `'(fuckoff|comeback|.*pad|title|dice)'` * **List :** + `fuckoff []` @@ -278,6 +278,10 @@ > Prints the title of the webpage at <url>. + + `dice []` + + > Let me toss heads or tails, or give a random number between 1 and <N> if given. + # Admin commands * AddAuth available only to GLOBAL_USERS and chan's USERS * Restart available only to GLOBAL_USERS diff --git a/gazouilleur/bot.py b/gazouilleur/bot.py index b73eef2..62c4702 100644 --- a/gazouilleur/bot.py +++ b/gazouilleur/bot.py @@ -1027,15 +1027,15 @@ def command_showthread(self, rest, channel=None, nick=None): tweets[curid]["text"] = yield self._format_tweet(tweet, light=True) if not tweets: returnD("[twitter] ERROR 404: Cannot find that tweet.") - returnD("\n".join(self.convtree(tweets, root))) + returnD("\n".join(self._convtree(tweets, root))) - def convtree(self, tree, root): + def _convtree(self, tree, root): if "text" not in tree[root]: return [] conv = [tree[root]['text']] tree[root]['repls'].sort() for repl in tree[root]['repls']: - conv += ["-> %s" % t for t in self.convtree(tree, repl)] + conv += ["-> %s" % t for t in self._convtree(tree, repl)] return conv def command_stats(self, rest, channel=None, nick=None): @@ -1448,7 +1448,7 @@ def command_cancel(self, rest, channel=None, *args): # ----------------- ## Pad & Title available to anyone ## FuckOff/ComeBack & SetPad available only to GLOBAL_USERS and chan's USERS - ## Exclude regexp : '(fuckoff|comeback|.*pad|title)' + ## Exclude regexp : '(fuckoff|comeback|.*pad|title|dice)' def command_fuckoff(self, minutes, channel=None, nick=None): """fuckoff [] : Tells me to shut up for the next minutes (defaults to 5)./AUTH""" @@ -1502,6 +1502,13 @@ def _parse_pagetitle(self, page_contents, url): title = title.encode('utf-8') return '%s -- "%s"' % (url, title) + def command_dice(self, rest, *args): + """dice [] : Let me toss heads or tails, or give a random number between 1 and if given.""" + maxval = safeint(rest) + if not maxval: + return "Heads!" if random.randint(0, 1) else "Tails!" + return random.randint(1, maxval) + # Admin commands # --------------