summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authormathieui <mathieui@mathieui.net>2016-07-05 01:39:17 +0200
committermathieui <mathieui@mathieui.net>2016-07-05 01:39:17 +0200
commit0276f2adf7168ac6b77d6aa7cc86801027097625 (patch)
treef351a6df5148d3128b2069493ed0445dffa72b8c /plugins
parentd55ce5b99689c1be0885daf0d2992b795df3e666 (diff)
downloadpoezio-0276f2adf7168ac6b77d6aa7cc86801027097625.tar.gz
poezio-0276f2adf7168ac6b77d6aa7cc86801027097625.tar.bz2
poezio-0276f2adf7168ac6b77d6aa7cc86801027097625.tar.xz
poezio-0276f2adf7168ac6b77d6aa7cc86801027097625.zip
Fix the dice plugin config
Diffstat (limited to 'plugins')
-rw-r--r--plugins/dice.py20
1 files changed, 11 insertions, 9 deletions
diff --git a/plugins/dice.py b/plugins/dice.py
index 67072730..9fed11f9 100644
--- a/plugins/dice.py
+++ b/plugins/dice.py
@@ -8,7 +8,7 @@ Commands
.. glossary::
- /roll <number of dice> [duration of the roll]
+ /roll [number of dice] [duration of the roll]
Roll one or several unicode dice
Configuration
@@ -22,7 +22,7 @@ Configuration
Interval in seconds between each correction (the closest to 0 is the fastest)
- default_duration
+ default_duration
**Default:** ``5``
Total duration of the animation.
@@ -34,7 +34,7 @@ from poezio import tabs
from poezio.decorators import command_args_parser
from poezio.plugin import BasePlugin
-DICE = ('\u2680', '\u2681', '\u2682', '\u2683', '\u2684', '\u2685')
+DICE = '\u2680\u2681\u2682\u2683\u2684\u2685'
class DiceRoll:
__slots__ = ['duration', 'total_duration', 'dice_number', 'msgtype',
@@ -55,22 +55,24 @@ class DiceRoll:
return self.duration >= self.total_duration
class Plugin(BasePlugin):
- default_config = {"roll": {"refresh": 0.5, "default_duration": 5}}
+ default_config = {"dice": {"refresh": 0.5, "default_duration": 5}}
def init(self):
for tab_t in [tabs.MucTab, tabs.ConversationTab, tabs.PrivateTab]:
self.api.add_tab_command(tab_t, 'roll', self.command_dice,
help='Roll a die',
- usage='<number> [duration]')
+ usage='[number] [duration]')
- @command_args_parser.quoted(1, 1, [''], True)
+ @command_args_parser.quoted(0, 2, ['', ''], True)
def command_dice(self, args):
tab = self.api.current_tab()
duration = self.config.get('default_duration')
+ num_dice = 1
try:
- num_dice = int(args[0])
- if args[1]:
- duration = float(args[1])
+ if args[0]:
+ num_dice = int(args[0])
+ if args[1]:
+ duration = float(args[1])
except ValueError:
self.core.command.help("roll")
return