From 80c67918e1e574d918a6510a45adbcdc78602f3e Mon Sep 17 00:00:00 2001 From: Nick80835 Date: Fri, 26 Jun 2020 15:24:01 -0400 Subject: [PATCH] add a nsfw board check for 4c --- ubot/modules/fourchan.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/ubot/modules/fourchan.py b/ubot/modules/fourchan.py index 8b27ddf..27dba2e 100644 --- a/ubot/modules/fourchan.py +++ b/ubot/modules/fourchan.py @@ -8,14 +8,19 @@ BOARD_URL = "https://a.4cdn.org/{0}/threads.json" POST_URL = "https://a.4cdn.org/{0}/thread/{1}.json" CONTENT_URL = "https://i.4cdn.org/{0}/{1}{2}" VALID_ENDS = (".mp4", ".jpg", ".jpeg", ".png", ".gif") +NSFW_BOARDS = ['aco', 'b', 'bant', 'd', 'e', 'f', 'gif', 'h', 'hc', 'hm', 'hr', 'i', 'ic', 'pol', 'r', 'r9k', 's', 's4s', 'soc', 't', 'trash', 'u', 'wg', 'y'] -@ldr.add("4c(f|)", userlocking=True) +@ldr.add("4c(f|)", userlocking=True, pass_nsfw=True) async def fourchan(event): if not event.args: await event.reply(f"Syntax: {ldr.prefix()}4c(f|) ") return + if event.nsfw_disabled and event.args in NSFW_BOARDS: + await event.reply(f"Sorry, that board is NSFW and NSFW commands are disabled!") + return + as_file = bool(event.other_args[0]) async with ldr.aioclient.get(BOARD_URL.format(event.args)) as response: