return DummyContextManager() if typing else channel.typing()
# join may be passed by cat.maybe_purr() etc.
-async def maybe_say(channel, text, *, typing = None, attachment = None, embed = None, probability = 0.2, wake = True, join = None):
+async def maybe_say(channel, text, *, typing = None, attachment = None, embed = None, allowed_mentions = None, reference = None, probability = 0.2, wake = True, join = None):
if random.random() <= probability:
message = None
try:
async with typing_context_manager(channel, typing):
if embed:
send['embed'] = embed
+ if allowed_mentions:
+ send['allowed_mentions'] = allowed_mentions
+ if reference:
+ send['reference'] = reference
if attachment is not None:
parsed = parse_attachment(attachment)
if parsed is not None:
log.debug("Didn't bother to say {}".format(text))
return None
-async def say(channel, text, *, typing = None, attachment = None, embed = None, wake = None, join = None):
+async def say(channel, text, *, typing = None, attachment = None, embed = None, allowed_mentions = None, reference = None, wake = None, join = None):
args = { 'probability': 1.0 }
if typing is not None:
args['typing'] = typing
args['attachment'] = attachment
if embed is not None:
args['embed'] = embed
+ if allowed_mentions:
+ args['allowed_mentions'] = allowed_mentions
+ if reference:
+ args['reference'] = reference
if wake is not None:
args['wake'] = wake
message = await maybe_say(channel, text, **args)
return message
-async def say_many(channel, lines, *, typing = None, attachment = None, embed = None, maxlen = 2000):
+async def say_many(channel, lines, *, typing = None, attachment = None, embed = None, allowed_mentions = None, reference = None, maxlen = 2000):
async with typing_context_manager(channel, typing) as context_manager:
while len(lines):
message_len = 0
# We can't print too big a message.
subset = lines[:n]
message = '\n'.join(subset)
- result = await say(channel, message, typing = context_manager, attachment = attachment, embed = embed)
+ result = await say(channel, message, typing = context_manager, attachment = attachment, embed = embed, allowed_mentions = allowed_mentions, reference = reference)
if not result:
break
lines = lines[len(subset):]