From 9448539c73fcd01bbd10e5d042daa9834063b78a Mon Sep 17 00:00:00 2001 From: Nick80835 Date: Thu, 5 Nov 2020 14:05:49 -0500 Subject: [PATCH] add ability to disable link preview for inline articles --- ubot/command.py | 1 + ubot/command_handler.py | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/ubot/command.py b/ubot/command.py index 79630ce..513fecd 100644 --- a/ubot/command.py +++ b/ubot/command.py @@ -48,6 +48,7 @@ class InlineArticleCommand: self.pattern_extra = args.get("pattern_extra", "") self.default = args.get("default", None) self.extra = args.get("extra", None) + self.link_preview = args.get("link_preview", True) class CallbackQueryCommand: diff --git a/ubot/command_handler.py b/ubot/command_handler.py index 714e668..72fa0a7 100644 --- a/ubot/command_handler.py +++ b/ubot/command_handler.py @@ -137,6 +137,7 @@ class CommandHandler(): event.command = pattern_match.groups()[0] event.extra = command.extra event.object = command + event.link_preview = command.link_preview result_list = await command.function(event) @@ -147,7 +148,7 @@ class CommandHandler(): for result in result_list: try: - articles += [await builder.article(title=result["title"], description=result["description"], text=result["text"])] + articles += [await builder.article(title=result["title"], description=result["description"], text=result["text"], link_preview=event.link_preview)] except: print_exc()