2
0
mirror of https://github.com/Nick80835/microbot synced 2025-09-02 15:35:43 +00:00

implement pass_nsfw

This commit is contained in:
Nick80835
2020-06-26 15:02:38 -04:00
parent a4d7dce42a
commit 87dd2934bd
3 changed files with 15 additions and 9 deletions

View File

@@ -48,6 +48,8 @@ class CommandHandler():
if value["nsfw"] and str(event.chat.id) in self.settings.get_list("nsfw_blacklist"): if value["nsfw"] and str(event.chat.id) in self.settings.get_list("nsfw_blacklist"):
print(f"Attempted NSFW command ({event.text}) in blacklisted chat ({event.chat.id}) from ID {event.from_id}") print(f"Attempted NSFW command ({event.text}) in blacklisted chat ({event.chat.id}) from ID {event.from_id}")
continue continue
elif value["pass_nsfw"]:
event.nsfw_disabled = str(event.chat.id) in self.settings.get_list("nsfw_blacklist")
event.pattern_match = pattern_match event.pattern_match = pattern_match
event.args = pattern_match.groups()[-1] event.args = pattern_match.groups()[-1]

View File

@@ -76,6 +76,7 @@ class Loader():
"sudo": args.get('sudo', False), "sudo": args.get('sudo', False),
"extras": args.get('extras', None), "extras": args.get('extras', None),
"nsfw": args.get('nsfw', False), "nsfw": args.get('nsfw', False),
"pass_nsfw": args.get('pass_nsfw', False),
"admin": args.get('admin', False), "admin": args.get('admin', False),
"owner": args.get('owner', False), "owner": args.get('owner', False),
"locking": args.get('locking', False), "locking": args.get('locking', False),

View File

@@ -44,6 +44,9 @@ async def imagefetcher(event, sub):
try: try:
post = REDDIT.subreddit(sub).random() or await imagefetcherfallback(sub) post = REDDIT.subreddit(sub).random() or await imagefetcherfallback(sub)
post.title post.title
if event.nsfw_disabled and post.over_18:
continue
except redex.Forbidden: except redex.Forbidden:
await event.reply(f"**r/{sub}** is private!") await event.reply(f"**r/{sub}** is private!")
return return
@@ -111,7 +114,7 @@ async def bodyfetcher(event, sub):
await event.reply(f"Failed to find any valid content on **r/{sub}**!") await event.reply(f"Failed to find any valid content on **r/{sub}**!")
@ldr.add("red(i|t|b)", userlocking=True) @ldr.add("red(i|t|b)", userlocking=True, pass_nsfw=True)
async def redimg(event): async def redimg(event):
sub = event.args.replace(" ", "_") sub = event.args.replace(" ", "_")
fetch_type = event.other_args[0] fetch_type = event.other_args[0]
@@ -128,27 +131,27 @@ async def redimg(event):
await bodyfetcher(event, sub) await bodyfetcher(event, sub)
@ldr.add("suffer", userlocking=True) @ldr.add("suffer", userlocking=True, pass_nsfw=True)
async def makemesuffer(event): async def makemesuffer(event):
await imagefetcher(event, "MakeMeSuffer") await imagefetcher(event, "MakeMeSuffer")
@ldr.add("snafu", userlocking=True) @ldr.add("snafu", userlocking=True, pass_nsfw=True)
async def coaxedintoasnafu(event): async def coaxedintoasnafu(event):
await imagefetcher(event, "CoaxedIntoASnafu") await imagefetcher(event, "CoaxedIntoASnafu")
@ldr.add("aita", userlocking=True) @ldr.add("aita", userlocking=True, pass_nsfw=True)
async def amitheasshole(event): async def amitheasshole(event):
await bodyfetcher(event, "AmITheAsshole") await bodyfetcher(event, "AmITheAsshole")
@ldr.add("tifu", userlocking=True) @ldr.add("tifu", userlocking=True, pass_nsfw=True)
async def todayifuckedup(event): async def todayifuckedup(event):
await bodyfetcher(event, "TIFU") await bodyfetcher(event, "TIFU")
@ldr.add("jon(x|)", userlocking=True) @ldr.add("jon(x|)", userlocking=True, pass_nsfw=True)
async def imsorryjon(event): async def imsorryjon(event):
if "x" in event.other_args[0]: if "x" in event.other_args[0]:
sub = "ImReallySorryJon" sub = "ImReallySorryJon"
@@ -158,16 +161,16 @@ async def imsorryjon(event):
await imagefetcher(event, sub) await imagefetcher(event, sub)
@ldr.add("tihi", userlocking=True) @ldr.add("tihi", userlocking=True, pass_nsfw=True)
async def thanksihateit(event): async def thanksihateit(event):
await imagefetcher(event, "TIHI") await imagefetcher(event, "TIHI")
@ldr.add("gab", userlocking=True) @ldr.add("gab", userlocking=True, pass_nsfw=True)
async def tenma(event): async def tenma(event):
await imagefetcher(event, "tenma") await imagefetcher(event, "tenma")
@ldr.add("pourn", userlocking=True) @ldr.add("pourn", userlocking=True, pass_nsfw=True)
async def pourn(event): async def pourn(event):
await imagefetcher(event, "PourPainting") await imagefetcher(event, "PourPainting")