Browse Source

roxbot's internal nsfw checking depreciated for discord's system. Also reducing relying in cogs that are meant to be modular.

tags/v2.0.0
Roxie Gibson 5 years ago
parent
commit
4276bf7e2c
5 changed files with 15 additions and 60 deletions
  1. +6
    -6
      CHANGELOG.md
  2. +0
    -4
      main.py
  3. +1
    -21
      roxbot/checks.py
  4. +7
    -23
      roxbot/cogs/nsfw.py
  5. +1
    -6
      roxbot/cogs/reddit.py

+ 6
- 6
CHANGELOG.md View File

@@ -4,11 +4,12 @@
- More better open source stuff - pls pr me
- easy setup and get that wiki going

### Big Changes
### Big and Breaking Changes
- All settings have been decentralised between servers and cogs. All changes to the settings have been moved to independant commands. This doesn't effect custom commands or warnings.
- Many commands have had overhalls in how they work. Parameters have changed on a number of commands. Please check documentation on all the commands to familarise yourself with the new way to input params.
- is_anal setting is now depreciated.`;suck` and `;spank` now only work in channels marked NSFW.
- perm_roles setting is now depreciated. All commands will work of Discord's permission system.
- Roxbot will now check for a channel being marked NSFW in Discord rather than her own internal system. Roxbot's NSFW channels have be depreciated.

### Regular Updates
#### New Features
@@ -17,12 +18,12 @@
#### Minor Changes
- Roxbot will remove all redundant settings (removed roles from self assign, etc.).
- Cogs have a message if they fail to load instead of breaking entire bot.
- NSFW commands should have even less chance of dupes.
- All time formatting is now standardised.
- Error messages dont time out anymore.
- NSFW commands should have even less chance of dupes with better caching.
- All datetime formatting is now standardised.
- Error messages don't timeout anymore.

#### Bug Fixes
- `deepfry` command now works all the time.
- `;deepfry` command now works all the time.
- Pride filter filenames fixed.
- As many spelling mistakes as possible.
- If music bot can't find a thumbnail for the now playing embed, it will just not have one; Instead of breaking.
@@ -30,7 +31,6 @@
- NSFW commands fixed.
- Roxbot can now fully function in DMs. Before, she would break. DM's have less commands that can be invoked.
- `;subreddit`'s "subscriptable" error has been fixed.
- is_anal value can be changed again and check now works.
- Common commands that would go over 2000 characters have been paginated to avoid this error.

## v1.8.0

+ 0
- 4
main.py View File

@@ -37,10 +37,6 @@ import roxbot
from roxbot import guild_settings as gs


# REMEMBER TO UNCOMMENT THE GSS LINE, ROXIE
# DO NOT UNCOMMENT GSS IF YOU ARE NOT ROXIE


# Sets up Logging that discord.py does on its own
logger = logging.getLogger('discord')
logger.setLevel(logging.INFO)

+ 1
- 21
roxbot/checks.py View File

@@ -25,13 +25,8 @@ SOFTWARE.
"""


import discord
from discord.ext import commands

import roxbot
from roxbot import guild_settings as gs

# TODO: Clean up this file.
from discord.ext import commands


def has_permission_or_owner(**perms):
@@ -41,18 +36,3 @@ def has_permission_or_owner(**perms):
return commands.has_permissions(**perms)
return commands.check(predicate)


def nsfw_predicate(ctx):
if isinstance(ctx.channel, discord.DMChannel):
return False
nsfw = gs.get(ctx.guild)["nsfw"]
if not nsfw["channels"] and nsfw["enabled"]:
return nsfw["enabled"] == 1
elif nsfw["enabled"] and nsfw["channels"]:
return ctx.channel.id in nsfw["channels"]
else:
return False


def is_nfsw_enabled():
return commands.check(lambda ctx: nsfw_predicate(ctx))

+ 7
- 23
roxbot/cogs/nsfw.py View File

@@ -48,13 +48,12 @@ class NFSW():
self.settings = {
"nsfw": {
"enabled": 0,
"channels": [],
"convert": {"enabled": "bool", "channels": "channel"},
"convert": {"enabled": "bool"},
"blacklist": []
}
}

@roxbot.checks.is_nfsw_enabled()
@commands.is_nsfw()
@commands.command(hidden=True)
async def gelbooru_clone(self, ctx, base_url, post_url, tags):
limit = 150
@@ -92,7 +91,7 @@ class NFSW():
output = await ctx.send(url)
await roxbot.utils.delete_option(self.bot, ctx, output, self.bot.get_emoji(444410658101002261) or "❌")

@roxbot.checks.is_nfsw_enabled()
@commands.is_nsfw()
@commands.command()
async def e621(self, ctx, *, tags=""):
"""
@@ -101,7 +100,7 @@ class NFSW():
base_url = "https://e621.net/post/index.json?tags="
return await ctx.invoke(self.gelbooru_clone, base_url=base_url, post_url="", tags=tags)

@roxbot.checks.is_nfsw_enabled()
@commands.is_nsfw()
@commands.command()
async def rule34(self, ctx, *, tags=""):
"""
@@ -111,7 +110,7 @@ class NFSW():
post_url = "https://img.rule34.xxx/images/"
return await ctx.invoke(self.gelbooru_clone, base_url=base_url, post_url=post_url, tags=tags)

@roxbot.checks.is_nfsw_enabled()
@commands.is_nsfw()
@commands.command()
async def gelbooru(self, ctx, *, tags=""):
"""
@@ -121,8 +120,9 @@ class NFSW():
post_url = "https://simg3.gelbooru.com/images/"
return await ctx.invoke(self.gelbooru_clone, base_url=base_url, post_url=post_url, tags=tags)

@commands.has_permissions(manage_channels=True)
@commands.command()
async def nsfw(self, ctx, setting, channel: typing.Optional[discord.TextChannel] = None, *, changes=None):
async def nsfw(self, ctx, setting, *, changes=None):
"""Edits settings for the nsfw cog and other nsfw commands.
If nsfw is enabled and nsfw channels are added, the bot will only allow nsfw commands in the specified channels.

@@ -143,22 +143,6 @@ class NFSW():
elif setting == "disable":
nsfw["enabled"] = 0
await ctx.send("'nsfw' was disabled :cry:")
elif setting == "addchannel":
if not channel and not changes:
channel = ctx.channel
if channel.id not in nsfw["channels"]:
nsfw["channels"].append(channel.id)
await ctx.send("'{}' has been added to the nsfw channel list.".format(channel.name))
else:
return await ctx.send("'{}' is already in the list.".format(channel.name))
elif setting == "removechannel":
if not channel and not changes:
channel = ctx.channel
try:
nsfw["channels"].remove(channel.id)
await ctx.send("'{}' has been removed from the nsfw channel list.".format(channel.name))
except ValueError:
return await ctx.send("That role was not in the list.")
elif setting == "addbadtag":
if changes not in nsfw["blacklist"]:
nsfw["blacklist"].append(changes)

+ 1
- 6
roxbot/cogs/reddit.py View File

@@ -154,7 +154,7 @@ class Reddit:
x += 1

# Check if post is NSFW, and if it is and this channel doesn't past the NSFW check, then return with the error message.
if (choice["over_18"] and not roxbot.checks.nsfw_predicate(ctx)) and isinstance(ctx.channel, discord.TextChannel):
if (choice["over_18"] and not ctx.channel.is_nsfw()) and isinstance(ctx.channel, discord.TextChannel):
return await ctx.send("This server/channel doesn't have my NSFW stuff enabled. This extends to posting NFSW content from Reddit.")
if not url: # If no image posts could be found with the for loop.
return await ctx.send("I couldn't find any images from that subreddit.")
@@ -230,10 +230,5 @@ class Reddit:
subreddit = "gaysoundsshitposts"
return await ctx.invoke(self.subreddit, subreddit=subreddit)

@commands.command(hidden=True, name="subreddit_dryrun")
async def _subreddit_test(self, ctx, url):
return await ctx.send(await parse_url(url))


def setup(bot_client):
bot_client.add_cog(Reddit(bot_client))

Loading…
Cancel
Save