From: CMDR furrycat Date: Tue, 21 Feb 2017 11:51:50 +0000 (+0000) Subject: Support embeds. X-Git-Url: http://git.furryclan.net/?a=commitdiff_plain;h=c461852809921130575ae189c4697ea699a7e427;p=furrycat%2Fcatbot.git Support embeds. --- diff --git a/bot.py b/bot.py index e6bd5f0..b9ec775 100644 --- a/bot.py +++ b/bot.py @@ -362,7 +362,7 @@ def parse_attachment(attachment, filename = None): return parsed @asyncio.coroutine -def maybe_say(channel, text, *, attachment = None, probability = 0.2, wake = True): +def maybe_say(channel, text, *, attachment = None, embed = None, probability = 0.2, wake = True): if random.random() <= probability: yield from client.send_typing(channel) message = None @@ -373,7 +373,7 @@ def maybe_say(channel, text, *, attachment = None, probability = 0.2, wake = Tru else: log.warning("Missing or invalid attachment!") if message is None: - message = yield from client.send_message(channel, text) + message = yield from client.send_message(channel, text, embed = embed) if wake: yield from wake_up() return message @@ -382,17 +382,19 @@ def maybe_say(channel, text, *, attachment = None, probability = 0.2, wake = Tru return None @asyncio.coroutine -def say(channel, text, *, attachment = None, wake = None): +def say(channel, text, *, attachment = None, embed = None, wake = None): args = { 'probability': 1.0 } if attachment is not None: args['attachment'] = attachment + if embed is not None: + args['embed'] = embed if wake is not None: args['wake'] = wake message = yield from maybe_say(channel, text, **args) return message @asyncio.coroutine -def say_many(channel, lines, *, attachment = None, maxlen = 2000): +def say_many(channel, lines, *, attachment = None, embed = None, maxlen = 2000): while len(lines): message_len = 0 n = 0 @@ -404,11 +406,12 @@ def say_many(channel, lines, *, attachment = None, maxlen = 2000): # We can't print too big a message. subset = lines[:n] message = '\n'.join(subset) - result = yield from say(channel, message, attachment = attachment) + result = yield from say(channel, message, attachment = attachment, embed = embed) if not result: break lines = lines[len(subset):] attachment = None + embed = None def voice_channel_for_channel(channel): for voice in client.voice_clients: