config flag for having !dice/!random prefix the nick
with the discord-irc bridge in play, the bot was sending all !roll results to the bridge user, which wasn't all that useful
This commit is contained in:
parent
1f5dc50d89
commit
76bcdd5fef
@ -1,7 +1,9 @@
|
|||||||
"""Roll dice when asked, intended for RPGs."""
|
"""Roll dice when asked, intended for RPGs."""
|
||||||
import logging
|
import logging
|
||||||
import re
|
|
||||||
import random
|
import random
|
||||||
|
import re
|
||||||
|
|
||||||
|
from django.conf import settings
|
||||||
|
|
||||||
from irc.client import NickMask
|
from irc.client import NickMask
|
||||||
|
|
||||||
@ -38,23 +40,23 @@ class Dice(Plugin):
|
|||||||
|
|
||||||
def handle_random(self, connection, event, match):
|
def handle_random(self, connection, event, match):
|
||||||
"""Handle the !random command which picks an item from a list."""
|
"""Handle the !random command which picks an item from a list."""
|
||||||
|
|
||||||
nick = NickMask(event.source).nick
|
nick = NickMask(event.source).nick
|
||||||
choices = match.group(1)
|
choices = match.group(1)
|
||||||
|
|
||||||
choices_list = choices.split(' ')
|
choices_list = choices.split(' ')
|
||||||
choice = random.choice(choices_list)
|
choice = random.SystemRandom().choice(choices_list)
|
||||||
|
|
||||||
logger.debug(event.recursing)
|
logger.debug(event.recursing)
|
||||||
if event.recursing:
|
if event.recursing:
|
||||||
reply = "{0:s}".format(choice)
|
reply = "{0:s}".format(choice)
|
||||||
else:
|
elif settings.DICE_PREFIX_ROLLER:
|
||||||
reply = "{0:s}: {1:s}".format(nick, choice)
|
reply = "{0:s}: {1:s}".format(nick, choice)
|
||||||
|
else:
|
||||||
|
reply = "{0:s}".format(choice)
|
||||||
return self.bot.reply(event, reply)
|
return self.bot.reply(event, reply)
|
||||||
|
|
||||||
def handle_roll(self, connection, event, match):
|
def handle_roll(self, connection, event, match):
|
||||||
"""Handle the !roll command which covers most common dice stuff."""
|
"""Handle the !roll command which covers most common dice stuff."""
|
||||||
|
|
||||||
nick = NickMask(event.source).nick
|
nick = NickMask(event.source).nick
|
||||||
dicestr = match.group(1)
|
dicestr = match.group(1)
|
||||||
|
|
||||||
@ -68,8 +70,11 @@ class Dice(Plugin):
|
|||||||
|
|
||||||
if event.recursing:
|
if event.recursing:
|
||||||
reply = "{0:s}".format(reply_str)
|
reply = "{0:s}".format(reply_str)
|
||||||
else:
|
elif settings.DICE_PREFIX_ROLLER:
|
||||||
reply = "{0:s}: {1:s}".format(nick, reply_str)
|
reply = "{0:s}: {1:s}".format(nick, reply_str)
|
||||||
|
else:
|
||||||
|
reply = "{0:s}".format(reply_str)
|
||||||
return self.bot.reply(event, re.sub(r'(\d+)(.*?\s+)(\(.*?\))', r'\1\214\3', reply))
|
return self.bot.reply(event, re.sub(r'(\d+)(.*?\s+)(\(.*?\))', r'\1\214\3', reply))
|
||||||
|
|
||||||
|
|
||||||
plugin = Dice
|
plugin = Dice
|
||||||
|
@ -149,6 +149,10 @@ BOOTSTRAP3 = {
|
|||||||
|
|
||||||
# IRC module stuff
|
# IRC module stuff
|
||||||
|
|
||||||
|
# dice
|
||||||
|
|
||||||
|
DICE_PREFIX_ROLLER = False
|
||||||
|
|
||||||
# karma
|
# karma
|
||||||
|
|
||||||
KARMA_IGNORE_CHATTER_TARGETS = []
|
KARMA_IGNORE_CHATTER_TARGETS = []
|
||||||
|
Loading…
Reference in New Issue
Block a user