ソースを参照

v1.0.10 accept dice rolls with optional dice number

master
Zac Herd 6年前
コミット
998ec2bf3a
2個のファイルの変更14行の追加2行の削除
  1. +13
    -1
      commands.py
  2. +1
    -1
      common.py

+ 13
- 1
commands.py ファイルの表示

@@ -134,6 +134,7 @@ def cmd_roll(client, msg):
tmp = msg.content[6:]

pattern = re.compile("^([0-9]+)d([0-9]+)$")
pattern2 = re.compile("^d([0-9]+)$")

if pattern.match(tmp):
# extract numbers
@@ -149,8 +150,19 @@ def cmd_roll(client, msg):
rollsum += random.randint(1, nums[1])

response = "Using `{}d{}`, {} rolled: `{}`".format(nums[0], nums[1], msg.author.display_name, rollsum)
elif pattern2.match(tmp):
# extract number
num = [int(s) for s in re.findall(r"\d+", tmp)]

# limit range
num[0] = clamp(num[0], 1, 1000000)

# roll dice
roll = random.randint(1, num[0])

response = "Using `1d{}`, {} rolled `{}`".format(num[0], msg.author.display_name, roll)
else:
response = "Expected format: `<num>d<value>`"
response = "Expected format: `[<num>]d<value>`"

yield from discord_send(client, msg, response)



+ 1
- 1
common.py ファイルの表示

@@ -13,7 +13,7 @@ import json


# bot version
version = "v1.0.9"
version = "v1.0.10"


# TODO: generate this on the fly and make it look acceptable


読み込み中…
キャンセル
保存