<commit_before>""" Script for server moderation

If enabled on the server, spots any text containing the keyword nsfw and a link.
Then tries to delete their message, and post a link to the dedicated nsfw channel.

Commands:
!nsfwchannel
"""

import discord
import asyncio

from pcbot.config import Config

commands = {
    "nsfwchannel": {
        "usage": "!nsfwchannel <action>\n"
                 "Actions:\n"
                 "    set <channel>\n"
                 "    remove",
        "desc": "Sets a channel for nsfw content. **User requires `Manage Server` permission to use command.**\n"
                "*The bot requires `Manage Messages` permission to delete suspected NSFW content.*"
    }
}

moderate = Config("moderate", data={})


@asyncio.coroutine
def on_message(client: discord.Client, message: discord.Message, args: list):
    channel = moderate.data.get(message.server.id, {}).get("nsfw-channel")

    if args[0] == "!nsfwchannel":
        if message.author.permissions_in(message.channel).manage_server:
            m = "Please see `!help nsfwchannel`."
            if len(args) > 1:
                if args[1] == "set" and len(args) > 2:
                    if message.channel_mentions:<commit_msg>Always run<commit_after>""" Script for server moderation

If enabled on the server, spots any text containing the keyword nsfw and a link.
Then tries to delete their message, and post a link to the dedicated nsfw channel.

Commands:
!nsfwchannel
"""

import discord
import asyncio

from pcbot.config import Config

commands = {
    "nsfwchannel": {
        "usage": "!nsfwchannel <action>\n"
                 "Actions:\n"
                 "    set <channel>\n"
                 "    remove",
        "desc": "Sets a channel for nsfw content. **User requires `Manage Server` permission to use command.**\n"
                "*The bot requires `Manage Messages` permission to delete suspected NSFW content.*"
    }
}

always_run = True

moderate = Config("moderate", data={})


@asyncio.coroutine
def on_message(client: discord.Client, message: discord.Message, args: list):
    channel = moderate.data.get(message.server.id, {}).get("nsfw-channel")

    if args[0] == "!nsfwchannel":
        if message.author.permissions_in(message.channel).manage_server:
            m = "Please see `!help nsfwchannel`."
            if len(args) > 1:
                if args[1] == "set" and len(args) > 2:
                    if message.channel_mentions:
{'fraction_non_alphanumeric': 0.11504065040650406, 'fraction_numerical': 0.0032520325203252032, 'mean_word_length': 2.629793510324484, 'pattern_counts': {'":': 8, '<': 7, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5131546', 'n_tokens_mistral': 734, 'n_tokens_neox': 706, 'n_words': 232}